diff --git a/.github/workflows/Set-CoverageReport.yml b/.github/workflows/Set-CoverageReport.yml
index 46583707..e7f5c295 100644
--- a/.github/workflows/Set-CoverageReport.yml
+++ b/.github/workflows/Set-CoverageReport.yml
@@ -16,6 +16,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
+ - name: Initialize-PSModule
+ uses: PSModule/Initialize-PSModule@v1
+
- name: Update coverage report
uses: PSModule/GitHub-Script@v1
with:
diff --git a/Coverage.md b/Coverage.md
index 5dc35128..1a59c8f4 100644
--- a/Coverage.md
+++ b/Coverage.md
@@ -9,15 +9,15 @@
Covered functions |
- 155 |
+ 156 |
Missing functions |
- 825 |
+ 824 |
Coverage |
- 15.82% |
+ 15.92% |
@@ -54,7 +54,7 @@
| `/emojis` | | :white_check_mark: | | | |
| `/enterprises/{enterprise}/dependabot/alerts` | | :x: | | | |
| `/enterprises/{enterprise}/secret-scanning/alerts` | | :x: | | | |
-| `/events` | | :x: | | | |
+| `/events` | | :white_check_mark: | | | |
| `/feeds` | | :x: | | | |
| `/gists` | | :x: | | :x: | |
| `/gists/public` | | :x: | | | |
diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1
new file mode 100644
index 00000000..9032bef8
--- /dev/null
+++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1
@@ -0,0 +1,138 @@
+filter Get-GitHubWorkflowRunByRepo {
+ <#
+ .SYNOPSIS
+ List workflow runs for a repository
+
+ .DESCRIPTION
+ Lists all workflow runs for a repository. You can use parameters to narrow the list of results. For more information about using parameters,
+ see [Parameters](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#parameters).
+ Anyone with read access to the repository can use this endpoint.
+ OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
+ This endpoint will return up to 1,000 results for each search when using the following parameters: `actor`, `branch`, `check_suite_id`,
+ `created`, `event`, `head_sha`, `status`.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repo 'repo'
+
+ Lists all workflow runs for a repository.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repo 'repo' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success'
+
+ Lists all workflow runs for a repository with the specified actor, branch, event, and status.
+
+ .NOTES
+ [List workflow runs for a repository](https://docs.github.com/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository)
+ #>
+ [CmdletBinding(DefaultParameterSetName = 'Repo')]
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'Event',
+ Justification = 'A parameter that is used in the api call.')]
+ param(
+ # The account owner of the repository. The name is not case sensitive.
+ [Parameter(Mandatory)]
+ [string] $Owner,
+
+ # The name of the repository. The name is not case sensitive.
+ [Parameter(Mandatory)]
+ [string] $Repo,
+
+ # Returns someone's workflow runs. Use the login for the user who created the push associated with the check suite or workflow run.
+ [Parameter()]
+ [string] $Actor,
+
+ # Returns workflow runs associated with a branch. Use the name of the branch of the `push`.
+ [Parameter()]
+ [string] $Branch,
+
+ # Returns workflow run triggered by the event you specify. For example, `push`, `pull_request` or `issue`. For more information, see
+ # "[Events that trigger workflows])(https://docs.github.com/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows)."
+ [Parameter()]
+ [string] $Event,
+
+ # Returns workflow runs with the check run status or conclusion that you specify. For example, a conclusion can be success or a status can be
+ # `in_progress`. Only GitHub Actions can set a status of `waiting`, `pending`, or `requested`.
+ # Can be one of: `completed`, `action_required`, `cancelled`, `failure`, `neutral`, `skipped`, `stale`, `success`, `timed_out`, `in_progress`,
+ # `queued`, `requested`, `waiting`, `pending`.
+ [Parameter()]
+ [ValidateSet('completed', 'action_required', 'cancelled', 'failure', 'neutral', 'skipped', 'stale', 'success', 'timed_out', 'in_progress',
+ 'queued', 'requested', 'waiting', 'pending')]
+ [string] $Status,
+
+ # Returns workflow runs created within the given date-time range. For more information on the syntax, see
+ # "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates)."
+ [Parameter()]
+ [datetime] $Created,
+
+ # If `true` pull requests are omitted from the response (empty array).
+ [Parameter()]
+ [switch] $ExcludePullRequests,
+
+ # Returns workflow runs with the check_suite_id that you specify.
+ [Parameter()]
+ [int] $CheckSuiteID,
+
+ # Only returns workflow runs that are associated with the specified head_sha.
+ [Parameter()]
+ [string] $HeadSHA,
+
+ # The number of results per page (max 100).
+ [Parameter()]
+ [ValidateRange(0, 100)]
+ [int] $PerPage,
+
+ # The context to run the command in. Used to get the details for the API call.
+ # Can be either a string or a GitHubContext object.
+ [Parameter()]
+ [object] $Context = (Get-GitHubContext)
+ )
+
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
+ }
+
+ process {
+ try {
+ $body = @{
+ actor = $Actor
+ branch = $Branch
+ event = $Event
+ status = $Status
+ created = $Created
+ exclude_pull_requests = $ExcludePullRequests
+ check_suite_id = $CheckSuiteID
+ head_sha = $HeadSHA
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/actions/runs"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.workflow_runs
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
+}
diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1
new file mode 100644
index 00000000..e07a5fbc
--- /dev/null
+++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1
@@ -0,0 +1,145 @@
+filter Get-GitHubWorkflowRunByWorkflow {
+ <#
+ .SYNOPSIS
+ List workflow runs for a workflow
+
+ .DESCRIPTION
+ List all workflow runs for a workflow. You can replace `workflow_id` with the workflow filename. For example, you could use `main.yaml`.
+ You can use parameters to narrow the list of results. For more information about using parameters, see
+ [Parameters](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#parameters).
+ Anyone with read access to the repository can use this endpoint
+ OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
+ This endpoint will return up to 1,000 results for each search when using the following parameters: `actor`, `branch`, `check_suite_id`,
+ `created`, `event`, `head_sha`, `status`.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repo 'Hello-World' -ID '42'
+
+ Gets all workflow runs for the workflow with the ID `42` in the repository `Hello-World` owned by `octocat`.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repo 'Hello-World' -ID '42' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success'
+
+ Gets all workflow runs for the workflow with the ID `42` in the repository `Hello-World` owned by `octocat` that were triggered by the user
+ `octocat` on the branch `main` and have the status `success`.
+
+ .NOTES
+ [List workflow runs for a workflow](https://docs.github.com/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow)
+ #>
+ [CmdletBinding(DefaultParameterSetName = 'Repo')]
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'Event',
+ Justification = 'A parameter that is used in the api call.')]
+ param(
+ # The account owner of the repository. The name is not case sensitive.
+ [Parameter(Mandatory)]
+ [string] $Owner,
+
+ # The name of the repository. The name is not case sensitive.
+ [Parameter(Mandatory)]
+ [string] $Repo,
+
+ # The ID of the workflow. You can also pass the workflow filename as a string.
+ [Parameter(Mandatory)]
+ [Alias('workflow_id', 'WorkflowID')]
+ [string] $ID,
+
+ # Returns someone's workflow runs. Use the login for the user who created the push associated with the check suite or workflow run.
+ [Parameter()]
+ [string] $Actor,
+
+ # Returns workflow runs associated with a branch. Use the name of the branch of the `push`.
+ [Parameter()]
+ [string] $Branch,
+
+ # Returns workflow run triggered by the event you specify. For example, `push`, `pull_request` or `issue`. For more information, see
+ # "[Events that trigger workflows])(https://docs.github.com/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows)."
+ [Parameter()]
+ [string] $Event,
+
+ # Returns workflow runs with the check run status or conclusion that you specify. For example, a conclusion can be success or a status can be
+ # `in_progress`. Only GitHub Actions can set a status of `waiting`, `pending`, or `requested`.
+ # Can be one of: `completed`, `action_required`, `cancelled`, `failure`, `neutral`, `skipped`, `stale`, `success`, `timed_out`, `in_progress`,
+ # `queued`, `requested`, `waiting`, `pending`.
+ [Parameter()]
+ [ValidateSet('completed', 'action_required', 'cancelled', 'failure', 'neutral', 'skipped', 'stale', 'success', 'timed_out', 'in_progress',
+ 'queued', 'requested', 'waiting', 'pending')]
+ [string] $Status,
+
+ # Returns workflow runs created within the given date-time range. For more information on the syntax, see
+ # "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates)."
+ [Parameter()]
+ [datetime] $Created,
+
+ # If `true` pull requests are omitted from the response (empty array).
+ [Parameter()]
+ [switch] $ExcludePullRequests,
+
+ # Returns workflow runs with the check_suite_id that you specify.
+ [Parameter()]
+ [int] $CheckSuiteID,
+
+ # Only returns workflow runs that are associated with the specified head_sha.
+ [Parameter()]
+ [string] $HeadSHA,
+
+ # The number of results per page (max 100).
+ [Parameter()]
+ [ValidateRange(0, 100)]
+ [int] $PerPage,
+
+ # The context to run the command in. Used to get the details for the API call.
+ # Can be either a string or a GitHubContext object.
+ [Parameter()]
+ [object] $Context = (Get-GitHubContext)
+ )
+
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
+ }
+
+ process {
+ try {
+ $body = @{
+ actor = $Actor
+ branch = $Branch
+ event = $Event
+ status = $Status
+ created = $Created
+ exclude_pull_requests = $ExcludePullRequests
+ check_suite_id = $CheckSuiteID
+ head_sha = $HeadSHA
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/runs"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.workflow_runs
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
+}
diff --git a/src/functions/private/Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/Get-GitHubAppByName.ps1
index cf9ac29d..df1b98df 100644
--- a/src/functions/private/Apps/Get-GitHubAppByName.ps1
+++ b/src/functions/private/Apps/Get-GitHubAppByName.ps1
@@ -31,24 +31,28 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/apps/$AppSlug"
- Method = 'GET'
- }
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/apps/$AppSlug"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/Get-GitHubAuthenticatedApp.ps1
index cf0fb44b..c32b49a4 100644
--- a/src/functions/private/Apps/Get-GitHubAuthenticatedApp.ps1
+++ b/src/functions/private/Apps/Get-GitHubAuthenticatedApp.ps1
@@ -29,15 +29,31 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/app'
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType App
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $Context = Resolve-GitHubContext -Context $Context
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/app'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
+ }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Assert-GitHubContext.ps1 b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1
similarity index 87%
rename from src/functions/public/Auth/Assert-GitHubContext.ps1
rename to src/functions/private/Auth/Context/Assert-GitHubContext.ps1
index ffa46dd3..d5484454 100644
--- a/src/functions/public/Auth/Assert-GitHubContext.ps1
+++ b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1
@@ -26,8 +26,8 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
process {
@@ -39,6 +39,6 @@
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Context/Remove-GitHubContext.ps1 b/src/functions/private/Auth/Context/Remove-GitHubContext.ps1
similarity index 87%
rename from src/functions/public/Auth/Context/Remove-GitHubContext.ps1
rename to src/functions/private/Auth/Context/Remove-GitHubContext.ps1
index abe5a116..72b5b424 100644
--- a/src/functions/public/Auth/Context/Remove-GitHubContext.ps1
+++ b/src/functions/private/Auth/Context/Remove-GitHubContext.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.3' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
filter Remove-GitHubContext {
<#
@@ -30,8 +30,8 @@ filter Remove-GitHubContext {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$null = Get-GitHubConfig
}
@@ -44,6 +44,6 @@ filter Remove-GitHubContext {
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1
index 1302d806..dffd3960 100644
--- a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1
+++ b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1
@@ -30,38 +30,42 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
Initialize-GitHubConfig
}
process {
- if ($Context -is [string]) {
- $contextName = $Context
- Write-Verbose "Getting context: [$contextName]"
- $Context = Get-GitHubContext -Context $contextName
- }
+ try {
+ if ($Context -is [string]) {
+ $contextName = $Context
+ Write-Debug "Getting context: [$contextName]"
+ $Context = Get-GitHubContext -Context $contextName
+ }
- if (-not $Context) {
- throw "Please provide a valid context or log in using 'Connect-GitHub'."
- }
+ if (-not $Context) {
+ throw "Please provide a valid context or log in using 'Connect-GitHub'."
+ }
- # switch ($Context.Type) {
- # 'App' {
- # $availableContexts = Get-GitHubContext -ListAvailable |
- # Where-Object { $_.Type -eq 'Installation' -and $_.ClientID -eq $Context.ClientID }
- # $params = Get-FunctionParameter -Scope 2
- # Write-Verbose 'Resolving parameters used in called function'
- # Write-Verbose ($params | Out-String)
- # if ($params.Keys -in 'Owner', 'Organization') {
- # $Context = $availableContexts | Where-Object { $_.Owner -eq $params.Owner }
- # }
- # }
- # }
+ # switch ($Context.Type) {
+ # 'App' {
+ # $availableContexts = Get-GitHubContext -ListAvailable |
+ # Where-Object { $_.Type -eq 'Installation' -and $_.ClientID -eq $Context.ClientID }
+ # $params = Get-FunctionParameter -Scope 2
+ # Write-Debug 'Resolving parameters used in called function'
+ # Write-Debug ($params | Out-String)
+ # if ($params.Keys -in 'Owner', 'Organization') {
+ # $Context = $availableContexts | Where-Object { $_.Owner -eq $params.Owner }
+ # }
+ # }
+ # }
+ } catch {
+ throw $_
+ }
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
Write-Output $Context
}
}
diff --git a/src/functions/public/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1
similarity index 87%
rename from src/functions/public/Auth/Context/Set-GitHubContext.ps1
rename to src/functions/private/Auth/Context/Set-GitHubContext.ps1
index cb420df5..902f7604 100644
--- a/src/functions/public/Auth/Context/Set-GitHubContext.ps1
+++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.3' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
function Set-GitHubContext {
<#
@@ -39,23 +39,23 @@ function Set-GitHubContext {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$null = Get-GitHubConfig
$contextObj = @{} + $Context
}
process {
- Write-Verbose 'Context:'
- $contextObj | Out-String -Stream | ForEach-Object { Write-Verbose $_ }
+ Write-Debug 'Context:'
+ $contextObj | Out-String -Stream | ForEach-Object { Write-Debug $_ }
# Run functions to get info on the temporary context.
try {
- Write-Verbose "Getting info on the context [$($contextObj['AuthType'])]."
+ Write-Debug "Getting info on the context [$($contextObj['AuthType'])]."
switch -Regex ($($contextObj['AuthType'])) {
'PAT|UAT|IAT' {
$viewer = Get-GitHubViewer -Context $contextObj
- $viewer | Out-String -Stream | ForEach-Object { Write-Verbose $_ }
+ $viewer | Out-String -Stream | ForEach-Object { Write-Debug $_ }
if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) {
$contextObj['DisplayName'] = [string]$viewer.name
}
@@ -94,12 +94,12 @@ function Set-GitHubContext {
$owner = $gitHubEvent.repository.owner.login
$repo = $gitHubEvent.repository.name
$gh_sender = $gitHubEvent.sender.login # sender is an automatic variable in Powershell
- Write-Verbose "Enterprise: $enterprise"
- Write-Verbose "Organization: $organization"
- Write-Verbose "Repository: $repo"
- Write-Verbose "Repository Owner: $owner"
- Write-Verbose "Repository Owner Type: $targetType"
- Write-Verbose "Sender: $gh_sender"
+ Write-Debug "Enterprise: $enterprise"
+ Write-Debug "Organization: $organization"
+ Write-Debug "Repository: $repo"
+ Write-Debug "Repository Owner: $owner"
+ Write-Debug "Repository Owner Type: $targetType"
+ Write-Debug "Sender: $gh_sender"
if ([string]::IsNullOrEmpty($contextObj['Enterprise'])) {
$contextObj['Enterprise'] = [string]$enterprise
}
@@ -139,11 +139,11 @@ function Set-GitHubContext {
throw 'Failed to get info on the context. Unknown logon type.'
}
}
- Write-Verbose "Found [$($contextObj['Type'])] with login: [$($contextObj['Name'])]"
- $contextObj | Out-String -Stream | ForEach-Object { Write-Verbose $_ }
- Write-Verbose '----------------------------------------------------'
+ Write-Debug "Found [$($contextObj['Type'])] with login: [$($contextObj['Name'])]"
+ $contextObj | Out-String -Stream | ForEach-Object { Write-Debug $_ }
+ Write-Debug '----------------------------------------------------'
if ($PSCmdlet.ShouldProcess('Context', 'Set')) {
- Write-Verbose "Saving context: [$($script:GitHub.Config.ID)/$($contextObj['Name'])]"
+ Write-Debug "Saving context: [$($script:GitHub.Config.ID)/$($contextObj['Name'])]"
Set-Context -ID "$($script:GitHub.Config.ID)/$($contextObj['Name'])" -Context $contextObj
if ($Default) {
Set-GitHubDefaultContext -Context $contextObj['Name']
@@ -164,6 +164,6 @@ function Set-GitHubContext {
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1 b/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1
index e4b349d3..abce7271 100644
--- a/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1
+++ b/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1
@@ -41,25 +41,40 @@
[securestring] $RefreshToken
)
- do {
- if ($RefreshToken) {
- $tokenResponse = Wait-GitHubAccessToken -ClientID $ClientID -RefreshToken $RefreshToken -HostName $HostName
- } else {
- $deviceCodeResponse = Request-GitHubDeviceCode -ClientID $ClientID -Scope $Scope -HostName $HostName
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
- $deviceCode = $deviceCodeResponse.device_code
- $interval = $deviceCodeResponse.interval
- $userCode = $deviceCodeResponse.user_code
- $verificationUri = $deviceCodeResponse.verification_uri
+ process {
+ try {
+ do {
+ if ($RefreshToken) {
+ $tokenResponse = Wait-GitHubAccessToken -ClientID $ClientID -RefreshToken $RefreshToken -HostName $HostName
+ } else {
+ $deviceCodeResponse = Request-GitHubDeviceCode -ClientID $ClientID -Scope $Scope -HostName $HostName
- Write-Host '! ' -ForegroundColor DarkYellow -NoNewline
- Write-Host "We added the code to your clipboard: [$userCode]"
- $userCode | Set-Clipboard
- Read-Host "Press Enter to open $HostName in your browser..."
- Start-Process $verificationUri
+ $deviceCode = $deviceCodeResponse.device_code
+ $interval = $deviceCodeResponse.interval
+ $userCode = $deviceCodeResponse.user_code
+ $verificationUri = $deviceCodeResponse.verification_uri
- $tokenResponse = Wait-GitHubAccessToken -DeviceCode $deviceCode -ClientID $ClientID -Interval $interval -HostName $HostName
+ Write-Host '! ' -ForegroundColor DarkYellow -NoNewline
+ Write-Host "We added the code to your clipboard: [$userCode]"
+ $userCode | Set-Clipboard
+ Read-Host "Press Enter to open $HostName in your browser..."
+ Start-Process $verificationUri
+
+ $tokenResponse = Wait-GitHubAccessToken -DeviceCode $deviceCode -ClientID $ClientID -Interval $interval -HostName $HostName
+ }
+ } while ($tokenResponse.error)
+ $tokenResponse
+ } catch {
+ throw $_
}
- } while ($tokenResponse.error)
- $tokenResponse
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1
index c193c81d..5592d1e7 100644
--- a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1
+++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1
@@ -42,40 +42,51 @@
[string] $HostName
)
- $body = @{
- 'client_id' = $ClientID
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- if ($PSBoundParameters.ContainsKey('RefreshToken')) {
- $body += @{
- 'refresh_token' = (ConvertFrom-SecureString $RefreshToken -AsPlainText)
- 'grant_type' = 'refresh_token'
+ process {
+ $body = @{
+ 'client_id' = $ClientID
}
- }
- if ($PSBoundParameters.ContainsKey('DeviceCode')) {
- $body += @{
- 'device_code' = $DeviceCode
- 'grant_type' = 'urn:ietf:params:oauth:grant-type:device_code'
+ if ($PSBoundParameters.ContainsKey('RefreshToken')) {
+ $body += @{
+ 'refresh_token' = (ConvertFrom-SecureString $RefreshToken -AsPlainText)
+ 'grant_type' = 'refresh_token'
+ }
}
- }
- $RESTParams = @{
- Uri = "https://$HostName/login/oauth/access_token"
- Method = 'POST'
- Body = $body
- Headers = @{ 'Accept' = 'application/json' }
- }
+ if ($PSBoundParameters.ContainsKey('DeviceCode')) {
+ $body += @{
+ 'device_code' = $DeviceCode
+ 'grant_type' = 'urn:ietf:params:oauth:grant-type:device_code'
+ }
+ }
- try {
- Write-Debug ($RESTParams.GetEnumerator() | Out-String)
+ $RESTParams = @{
+ Uri = "https://$HostName/login/oauth/access_token"
+ Method = 'POST'
+ Body = $body
+ Headers = @{ 'Accept' = 'application/json' }
+ }
- $tokenResponse = Invoke-RestMethod @RESTParams -Verbose:$false
+ try {
+ Write-Debug ($RESTParams.GetEnumerator() | Out-String)
+
+ $tokenResponse = Invoke-RestMethod @RESTParams -Verbose:$false
+
+ Write-Debug ($tokenResponse | ConvertTo-Json | Out-String)
+ return $tokenResponse
+ } catch {
+ Write-Error $_
+ throw $_
+ }
+ }
- Write-Debug ($tokenResponse | ConvertTo-Json | Out-String)
- return $tokenResponse
- } catch {
- Write-Error $_
- throw $_
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1
index 28280f0a..8a0b2266 100644
--- a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1
+++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1
@@ -34,29 +34,40 @@
[string] $HostName
)
- $headers = @{
- Accept = 'application/json'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- $body = @{
- client_id = $ClientID
- scope = $Scope
- }
+ process {
+ $headers = @{
+ Accept = 'application/json'
+ }
- $RESTParams = @{
- Uri = "https://$HostName/login/device/code"
- Method = 'POST'
- Body = $body
- Headers = $headers
- }
+ $body = @{
+ client_id = $ClientID
+ scope = $Scope
+ }
+
+ $RESTParams = @{
+ Uri = "https://$HostName/login/device/code"
+ Method = 'POST'
+ Body = $body
+ Headers = $headers
+ }
- try {
- Write-Debug ($RESTParams.GetEnumerator() | Out-String)
+ try {
+ Write-Debug ($RESTParams.GetEnumerator() | Out-String)
+
+ $deviceCodeResponse = Invoke-RestMethod @RESTParams -Verbose:$false
+ return $deviceCodeResponse
+ } catch {
+ Write-Error $_
+ throw $_
+ }
+ }
- $deviceCodeResponse = Invoke-RestMethod @RESTParams -Verbose:$false
- return $deviceCodeResponse
- } catch {
- Write-Error $_
- throw $_
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1
index bba2179d..a4e6f305 100644
--- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1
+++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1
@@ -20,10 +20,24 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
- $tokenExpirationDate = $Context.TokenExpirationDate
- $currentDateTime = Get-Date
- $remainingDuration = [datetime]$tokenExpirationDate - $currentDateTime
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ }
- $remainingDuration.TotalHours -lt $script:GitHub.Config.AccessTokenGracePeriodInHours
+ process {
+ try {
+ $tokenExpirationDate = $Context.TokenExpirationDate
+ $currentDateTime = Get-Date
+ $remainingDuration = [datetime]$tokenExpirationDate - $currentDateTime
+ $remainingDuration.TotalHours -lt $script:GitHub.Config.AccessTokenGracePeriodInHours
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1
index 74d60286..d5742619 100644
--- a/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1
+++ b/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1
@@ -49,68 +49,83 @@
[int] $Interval = 5
)
- do {
- if ($RefreshToken) {
- $response = Request-GitHubAccessToken -ClientID $ClientID -RefreshToken $RefreshToken -HostName $HostName
- } else {
- $response = Request-GitHubAccessToken -ClientID $ClientID -DeviceCode $DeviceCode -HostName $HostName
- }
- if ($response.error) {
- switch ($response.error) {
- 'authorization_pending' {
- # The user has not yet entered the code.
- # Wait, then poll again.
- Write-Debug $response.error_description
- Start-Sleep -Seconds $interval
- continue
- }
- 'slow_down' {
- # The app polled too fast.
- # Wait for the interval plus 5 seconds, then poll again.
- Write-Debug $response.error_description
- Start-Sleep -Seconds ($interval + 5)
- continue
- }
- 'expired_token' {
- # The 'device_code' expired, and the process needs to restart.
- Write-Error $response.error_description
- exit 1
- }
- 'unsupported_grant_type' {
- # The 'grant_type' is not supported.
- Write-Error $response.error_description
- exit 1
- }
- 'incorrect_client_credentials' {
- # The 'client_id' is not valid.
- Write-Error $response.error_description
- exit 1
- }
- 'incorrect_device_code' {
- # The 'device_code' is not valid.
- Write-Error $response.error_description
- exit 2
- }
- 'access_denied' {
- # The user cancelled the process. Stop polling.
- Write-Error $response.error_description
- exit 1
- }
- 'device_flow_disabled' {
- # The GitHub App does not support the Device Flow.
- Write-Error $response.error_description
- exit 1
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ do {
+ if ($RefreshToken) {
+ $response = Request-GitHubAccessToken -ClientID $ClientID -RefreshToken $RefreshToken -HostName $HostName
+ } else {
+ $response = Request-GitHubAccessToken -ClientID $ClientID -DeviceCode $DeviceCode -HostName $HostName
}
- default {
- # The response contains an access token. Stop polling.
- Write-Error 'Unknown error:'
- Write-Error $response.error
- Write-Error $response.error_description
- Write-Error $response.error_uri
- break
+ if ($response.error) {
+ switch ($response.error) {
+ 'authorization_pending' {
+ # The user has not yet entered the code.
+ # Wait, then poll again.
+ Write-Debug $response.error_description
+ Start-Sleep -Seconds $interval
+ continue
+ }
+ 'slow_down' {
+ # The app polled too fast.
+ # Wait for the interval plus 5 seconds, then poll again.
+ Write-Debug $response.error_description
+ Start-Sleep -Seconds ($interval + 5)
+ continue
+ }
+ 'expired_token' {
+ # The 'device_code' expired, and the process needs to restart.
+ Write-Error $response.error_description
+ exit 1
+ }
+ 'unsupported_grant_type' {
+ # The 'grant_type' is not supported.
+ Write-Error $response.error_description
+ exit 1
+ }
+ 'incorrect_client_credentials' {
+ # The 'client_id' is not valid.
+ Write-Error $response.error_description
+ exit 1
+ }
+ 'incorrect_device_code' {
+ # The 'device_code' is not valid.
+ Write-Error $response.error_description
+ exit 2
+ }
+ 'access_denied' {
+ # The user cancelled the process. Stop polling.
+ Write-Error $response.error_description
+ exit 1
+ }
+ 'device_flow_disabled' {
+ # The GitHub App does not support the Device Flow.
+ Write-Error $response.error_description
+ exit 1
+ }
+ default {
+ # The response contains an access token. Stop polling.
+ Write-Error 'Unknown error:'
+ Write-Error $response.error
+ Write-Error $response.error_description
+ Write-Error $response.error_uri
+ break
+ }
+ }
}
- }
+ } until ($response.access_token)
+ $response
+ } catch {
+ throw $_
}
- } until ($response.access_token)
- $response
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1 b/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1
index f267a7d4..03eec227 100644
--- a/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1
+++ b/src/functions/private/Commands/ConvertFrom-GitHubOutput.ps1
@@ -49,6 +49,8 @@
)
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$lines = @()
}
@@ -128,8 +130,10 @@
$i++
}
if ($AsHashtable) {
- return $result
+ $result
+ } else {
+ [PSCustomObject]$result
}
- [PSCustomObject]$result
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1 b/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1
index 0b9d7236..1562b1dc 100644
--- a/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1
+++ b/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1
@@ -46,32 +46,47 @@
[object] $InputObject
)
- $outputLines = @()
-
- if ($InputObject -is [hashtable]) {
- $InputObject = [PSCustomObject]$InputObject
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- foreach ($property in $InputObject.PSObject.Properties) {
- $key = $property.Name
- $value = $property.Value
+ process {
+ try {
+ $outputLines = @()
- # Convert hashtable or PSCustomObject to compressed JSON
- if ($value -is [hashtable] -or $value -is [PSCustomObject]) {
- $value = $value | ConvertTo-Json -Compress
- }
+ if ($InputObject -is [hashtable]) {
+ $InputObject = [PSCustomObject]$InputObject
+ }
+
+ foreach ($property in $InputObject.PSObject.Properties) {
+ $key = $property.Name
+ $value = $property.Value
- if ($value -is [string] -and $value.Contains("`n")) {
- # Multi-line value
- $guid = [Guid]::NewGuid().ToString()
- $EOFMarker = "EOF_$guid"
- $outputLines += "$key<<$EOFMarker"
- $outputLines += $value
- $outputLines += $EOFMarker
- } else {
- # Single-line value
- $outputLines += "$key=$value"
+ # Convert hashtable or PSCustomObject to compressed JSON
+ if ($value -is [hashtable] -or $value -is [PSCustomObject]) {
+ $value = $value | ConvertTo-Json -Compress
+ }
+
+ if ($value -is [string] -and $value.Contains("`n")) {
+ # Multi-line value
+ $guid = [Guid]::NewGuid().ToString()
+ $EOFMarker = "EOF_$guid"
+ $outputLines += "$key<<$EOFMarker"
+ $outputLines += $value
+ $outputLines += $EOFMarker
+ } else {
+ # Single-line value
+ $outputLines += "$key=$value"
+ }
+ }
+ $outputLines
+ } catch {
+ throw $_
}
}
- $outputLines
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Config/Initialize-GitHubConfig.ps1 b/src/functions/private/Config/Initialize-GitHubConfig.ps1
index 4bbc8bab..84aaab67 100644
--- a/src/functions/private/Config/Initialize-GitHubConfig.ps1
+++ b/src/functions/private/Config/Initialize-GitHubConfig.ps1
@@ -24,33 +24,33 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Debug "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
process {
- Write-Verbose "GitHubConfig ID: [$($script:GitHub.Config.ID)]"
- Write-Verbose "Force: [$Force]"
+ Write-Debug "GitHubConfig ID: [$($script:GitHub.Config.ID)]"
+ Write-Debug "Force: [$Force]"
if (-not $script:GitHub.Config.ID -or $Force) {
try {
- Write-Verbose 'Attempt to load the stored GitHubConfig from ContextVault'
+ Write-Debug 'Attempt to load the stored GitHubConfig from ContextVault'
$context = [GitHubConfig](Get-Context -ID $script:GitHub.Config.ID)
if (-not $context -or $Force) {
- Write-Verbose 'No stored config found. Loading GitHubConfig from defaults'
+ Write-Debug 'No stored config found. Loading GitHubConfig from defaults'
$context = Set-Context -ID $script:GitHub.DefaultConfig.ID -Context $script:GitHub.DefaultConfig -PassThru
}
- Write-Verbose 'GitHubConfig loaded into memory.'
+ Write-Debug 'GitHubConfig loaded into memory.'
$script:GitHub.Config = [GitHubConfig]$context
} catch {
Write-Error $_
throw 'Failed to initialize GitHub config'
}
} else {
- Write-Verbose 'GitHubConfig already initialized and available in memory.'
+ Write-Debug 'GitHubConfig already initialized and available in memory.'
}
}
end {
- Write-Debug "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1
index 777cb263..e3c0fbc1 100644
--- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1
+++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1
@@ -28,19 +28,30 @@
)
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/gitignore/templates/$Name"
- Accept = 'application/vnd.github.raw+json'
- Method = 'GET'
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/gitignore/templates/$Name"
+ Accept = 'application/vnd.github.raw+json'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1
index 1f522c51..7d1c7094 100644
--- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1
+++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1
@@ -26,18 +26,29 @@
)
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/gitignore/templates'
- Method = 'GET'
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/gitignore/templates'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1
index e14974dd..a058020c 100644
--- a/src/functions/private/License/Get-GitHubLicenseByName.ps1
+++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1
@@ -31,19 +31,30 @@
)
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/licenses/$Name"
- Accept = 'application/vnd.github+json'
- Method = 'GET'
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/licenses/$Name"
+ Accept = 'application/vnd.github+json'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1
index 6cefaf8b..42506ae1 100644
--- a/src/functions/private/License/Get-GitHubLicenseList.ps1
+++ b/src/functions/private/License/Get-GitHubLicenseList.ps1
@@ -25,14 +25,30 @@
[string] $Context
)
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/licenses'
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/licenses'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1
index 351daa60..e4e60901 100644
--- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1
+++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1
@@ -34,29 +34,43 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/license"
- Accept = 'application/vnd.github+json'
- Method = 'GET'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/license"
+ Accept = 'application/vnd.github+json'
+ Method = 'GET'
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- $Response = $_.Response
- $rawContent = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Response.content))
- $Response | Add-Member -NotePropertyName 'raw_content' -NotePropertyValue $rawContent -Force
- $Response
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ $Response = $_.Response
+ $rawContent = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Response.content))
+ $Response | Add-Member -NotePropertyName 'raw_content' -NotePropertyValue $rawContent -Force
+ $Response
+ }
+ } catch {
+ throw $_
+ }
+ }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1
index e57d6334..109173ff 100644
--- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1
@@ -44,24 +44,36 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/blocks/$Username"
- Method = 'PUT'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- try {
- $null = (Invoke-GitHubAPI @inputObject)
- # Should we check if user is already blocked and return true if so?
- return $true
- } catch {
- if ($_.Exception.Response.StatusCode.Value__ -eq 422) {
- return $false
- } else {
- Write-Error $_.Exception.Response
- throw $_
+ process {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/blocks/$Username"
+ Method = 'PUT'
+ }
+
+ try {
+ $null = (Invoke-GitHubAPI @inputObject)
+ # Should we check if user is already blocked and return true if so?
+ return $true
+ } catch {
+ if ($_.Exception.Response.StatusCode.Value__ -eq 422) {
+ return $false
+ } else {
+ Write-Error $_.Exception.Response
+ throw $_
+ }
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
+
diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1
index bdcac202..d99be05e 100644
--- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1
@@ -35,20 +35,34 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/blocks"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/blocks"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
+ }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1
index b838e199..928be843 100644
--- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1
@@ -43,21 +43,33 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/blocks/$Username"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- try {
- (Invoke-GitHubAPI @inputObject).StatusCode -eq 204
- } catch {
- if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
- return $false
- } else {
- throw $_
+ process {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/blocks/$Username"
+ Method = 'GET'
+ }
+
+ try {
+ (Invoke-GitHubAPI @inputObject).StatusCode -eq 204
+ } catch {
+ if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
+ return $false
+ } else {
+ throw $_
+ }
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
+
diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1
index 18314fb3..97836029 100644
--- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1
@@ -44,19 +44,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
+
+ process {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/blocks/$Username"
+ Method = 'DELETE'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/blocks/$Username"
- Method = 'DELETE'
+ try {
+ $null = (Invoke-GitHubAPI @inputObject)
+ return $true
+ } catch {
+ Write-Error $_.Exception.Response
+ throw $_
+ }
}
- try {
- $null = (Invoke-GitHubAPI @inputObject)
- return $true
- } catch {
- Write-Error $_.Exception.Response
- throw $_
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1
index 2c5f4fb5..d8a1102d 100644
--- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1
+++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1
@@ -37,22 +37,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- since = $Since
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/organizations'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ since = $Since
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/organizations'
+ Method = 'GET'
+ Body = $body
+ }
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
+ }
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1
index 1a514936..b561dcb6 100644
--- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1
+++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1
@@ -36,20 +36,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/orgs'
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/orgs'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1
index b7826882..bceada5a 100644
--- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1
+++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1
@@ -42,15 +42,29 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
+ }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1
index a3544e76..e66124df 100644
--- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1
+++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1
@@ -38,20 +38,34 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/orgs"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/orgs"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
+ }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1
index 6bcbbf6d..c4069235 100644
--- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1
+++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1
@@ -39,25 +39,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
+ Method = 'GET'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
- Method = 'GET'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1
index 3fa1252a..8e9fcc7f 100644
--- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1
+++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1
@@ -44,29 +44,43 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = @{
- per_page = $PerPage
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets"
- Method = 'GET'
- Body = $body
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets"
+ Method = 'GET'
+ Body = $body
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
+ }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1
index e1305754..c35157bb 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1
@@ -38,31 +38,43 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- $body = @{
- per_page = $PerPage
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases"
+ Method = 'GET'
+ Body = $body
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases"
- Method = 'GET'
- Body = $body
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1
index c80412ba..5f60d311 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1
@@ -37,26 +37,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
+ Method = 'GET'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
- Method = 'GET'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1
index e6befa41..156454bc 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1
@@ -36,26 +36,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag"
+ Method = 'GET'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag"
- Method = 'GET'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1
index 738f6fb5..8c032589 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1
@@ -33,25 +33,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/latest"
+ Method = 'GET'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/latest"
- Method = 'GET'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1
index 1557c4ce..3a93ca72 100644
--- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1
+++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1
@@ -40,25 +40,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId"
+ Method = 'GET'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId"
- Method = 'GET'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1
index 92a44ed3..d4273641 100644
--- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1
+++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1
@@ -34,25 +34,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/autolinks"
+ Method = 'GET'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/autolinks"
- Method = 'GET'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1
index 3538e5ac..0a1e85d8 100644
--- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1
+++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1
@@ -68,38 +68,53 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullorEmpty($Name)) {
- $Name = $Repo
- }
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
- $body = @{
- organization = $Organization
- name = $Name
- default_branch_only = $DefaultBranchOnly
+ if ([string]::IsNullorEmpty($Name)) {
+ $Name = $Repo
+ }
+ Write-Debug "Name: [$Name]"
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/forks"
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ organization = $Organization
+ name = $Name
+ default_branch_only = $DefaultBranchOnly
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/forks"
+ Method = 'POST'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1
index 169fc58f..da8719bc 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1
@@ -113,34 +113,48 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- type = $Type
- sort = $Sort
- direction = $Direction
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- if ($PSBoundParameters.ContainsKey('Affiliation')) {
- $body['affiliation'] = $Affiliation -join ','
- }
- if ($PSBoundParameters.ContainsKey('Since')) {
- $body['since'] = $Since.ToString('yyyy-MM-ddTHH:mm:ssZ')
- }
- if ($PSBoundParameters.ContainsKey('Before')) {
- $body['before'] = $Before.ToString('yyyy-MM-ddTHH:mm:ssZ')
- }
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/repos'
- Method = 'GET'
- body = $body
+ process {
+ try {
+ $body = @{
+ type = $Type
+ sort = $Sort
+ direction = $Direction
+ per_page = $PerPage
+ }
+
+ if ($PSBoundParameters.ContainsKey('Affiliation')) {
+ $body['affiliation'] = $Affiliation -join ','
+ }
+ if ($PSBoundParameters.ContainsKey('Since')) {
+ $body['since'] = $Since.ToString('yyyy-MM-ddTHH:mm:ssZ')
+ }
+ if ($PSBoundParameters.ContainsKey('Before')) {
+ $body['before'] = $Before.ToString('yyyy-MM-ddTHH:mm:ssZ')
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/repos'
+ Method = 'GET'
+ body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1
index 1d0f92d5..ff9b5f24 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1
@@ -36,26 +36,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo"
- Method = 'GET'
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo"
+ Method = 'GET'
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1
index c145124c..f3cd5268 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1
@@ -33,21 +33,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- since = $Since
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/repositories'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ since = $Since
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/repositories'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1
index e8ad3ed6..2e24b3ac 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1
@@ -62,28 +62,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- $body = @{
- sort = $Sort
- type = $Type
- direction = $Direction
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Owner/repos"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ sort = $Sort
+ type = $Type
+ direction = $Direction
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Owner/repos"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1
index 3aa6a7e5..70d5133e 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1
@@ -64,23 +64,47 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- sort = $Sort
- type = $Type
- direction = $Direction
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/repos"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ sort = $Sort
+ type = $Type
+ direction = $Direction
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/repos"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1
index f58e8e89..f9bfe16b 100644
--- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1
+++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1
@@ -78,36 +78,45 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $body = @{
- owner = $Owner
- name = $Name
- description = $Description
- include_all_branches = $IncludeAllBranches
- private = $Private
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$TemplateOwner/$TemplateRepo/generate"
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ owner = $Owner
+ name = $Name
+ description = $Description
+ include_all_branches = $IncludeAllBranches
+ private = $Private
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$TemplateOwner/$TemplateRepo/generate"
+ Method = 'POST'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1
index f5366ca7..1eddfd0b 100644
--- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1
+++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1
@@ -212,60 +212,62 @@ filter New-GitHubRepositoryOrg {
}
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
$GitignoreTemplate = $PSBoundParameters['GitignoreTemplate']
$LicenseTemplate = $PSBoundParameters['LicenseTemplate']
if ([string]::IsNullOrEmpty($Owner)) {
$Owner = $Context.Owner
}
- Write-Debug "Owner : [$($Context.Owner)]"
+ Write-Debug "Owner: [$Owner]"
}
process {
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Debug "[$paramName]"
- Write-Debug " - Default: [$paramDefaultValue]"
- Write-Debug " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Debug ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Debug ' - Using provided value'
+ try {
+ $body = @{
+ name = $Name
+ description = $Description
+ homepage = $Homepage
+ visibility = $Visibility
+ has_issues = $HasIssues
+ has_projects = $HasProjects
+ has_wiki = $HasWiki
+ has_downloads = $HasDownloads
+ is_template = $IsTemplate
+ team_id = $TeamId
+ auto_init = $AutoInit
+ allow_squash_merge = $AllowSquashMerge
+ allow_merge_commit = $AllowMergeCommit
+ allow_rebase_merge = $AllowRebaseMerge
+ allow_auto_merge = $AllowAutoMerge
+ delete_branch_on_merge = $DeleteBranchOnMerge
+ squash_merge_commit_title = $SquashMergeCommitTitle
+ squash_merge_commit_message = $SquashMergeCommitMessage
+ merge_commit_title = $MergeCommitTitle
+ merge_commit_message = $MergeCommitMessage
+ private = $Visibility -eq 'private'
}
- }
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner' -RemoveTypes 'SwitchParameter'
-
- $body['private'] = $Visibility -eq 'private'
- $body['has_issues'] = if ($HasIssues.IsPresent) { $HasIssues } else { $false }
- $body['has_wiki'] = if ($HasWiki.IsPresent) { $HasWiki } else { $false }
- $body['has_projects'] = if ($HasProjects.IsPresent) { $HasProjects } else { $false }
- $body['has_downloads'] = if ($HasDownloads.IsPresent) { $HasDownloads } else { $false }
- $body['is_template'] = if ($IsTemplate.IsPresent) { $IsTemplate } else { $false }
- $body['auto_init'] = if ($AutoInit.IsPresent) { $AutoInit } else { $false }
- $body['allow_squash_merge'] = if ($AllowSquashMerge.IsPresent) { $AllowSquashMerge } else { $false }
- $body['allow_merge_commit'] = if ($AllowMergeCommit.IsPresent) { $AllowMergeCommit } else { $false }
- $body['allow_rebase_merge'] = if ($AllowRebaseMerge.IsPresent) { $AllowRebaseMerge } else { $false }
- $body['allow_auto_merge'] = if ($AllowAutoMerge.IsPresent) { $AllowAutoMerge } else { $false }
- $body['delete_branch_on_merge'] = if ($DeleteBranchOnMerge.IsPresent) { $DeleteBranchOnMerge } else { $false }
-
- Remove-HashtableEntry -Hashtable $body -NullOrEmptyValues
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Owner/repos"
- Method = 'POST'
- Body = $body
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Owner/repos"
+ Method = 'POST'
+ Body = $body
+ }
- if ($PSCmdlet.ShouldProcess("Repository in organization $Owner", 'Create')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Repository in organization $Owner", 'Create')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
}
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1
index a8346ea2..3405128a 100644
--- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1
+++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1
@@ -206,57 +206,58 @@ filter New-GitHubRepositoryUser {
}
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
$GitignoreTemplate = $PSBoundParameters['GitignoreTemplate']
$LicenseTemplate = $PSBoundParameters['LicenseTemplate']
}
process {
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Debug "[$paramName]"
- Write-Debug " - Default: [$paramDefaultValue]"
- Write-Debug " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Debug ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Debug ' - Using provided value'
+ try {
+ $body = @{
+ name = $Name
+ description = $Description
+ homepage = $Homepage
+ visibility = $Visibility
+ has_issues = $HasIssues
+ has_projects = $HasProjects
+ has_wiki = $HasWiki
+ has_downloads = $HasDownloads
+ is_template = $IsTemplate
+ team_id = $TeamId
+ auto_init = $AutoInit
+ allow_squash_merge = $AllowSquashMerge
+ allow_merge_commit = $AllowMergeCommit
+ allow_rebase_merge = $AllowRebaseMerge
+ allow_auto_merge = $AllowAutoMerge
+ delete_branch_on_merge = $DeleteBranchOnMerge
+ squash_merge_commit_title = $SquashMergeCommitTitle
+ squash_merge_commit_message = $SquashMergeCommitMessage
+ merge_commit_title = $MergeCommitTitle
+ merge_commit_message = $MergeCommitMessage
+ private = $Visibility -eq 'private'
}
- }
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'visibility' -RemoveTypes 'SwitchParameter'
-
- $body['private'] = $Visibility -eq 'private'
- $body['has_issues'] = if ($HasIssues.IsPresent) { $HasIssues } else { $false }
- $body['has_wiki'] = if ($HasWiki.IsPresent) { $HasWiki } else { $false }
- $body['has_projects'] = if ($HasProjects.IsPresent) { $HasProjects } else { $false }
- $body['has_downloads'] = if ($HasDownloads.IsPresent) { $HasDownloads } else { $false }
- $body['is_template'] = if ($IsTemplate.IsPresent) { $IsTemplate } else { $false }
- $body['auto_init'] = if ($AutoInit.IsPresent) { $AutoInit } else { $false }
- $body['allow_squash_merge'] = if ($AllowSquashMerge.IsPresent) { $AllowSquashMerge } else { $false }
- $body['allow_merge_commit'] = if ($AllowMergeCommit.IsPresent) { $AllowMergeCommit } else { $false }
- $body['allow_rebase_merge'] = if ($AllowRebaseMerge.IsPresent) { $AllowRebaseMerge } else { $false }
- $body['allow_auto_merge'] = if ($AllowAutoMerge.IsPresent) { $AllowAutoMerge } else { $false }
- $body['delete_branch_on_merge'] = if ($DeleteBranchOnMerge.IsPresent) { $DeleteBranchOnMerge } else { $false }
-
- Remove-HashtableEntry -Hashtable $body -NullOrEmptyValues
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/repos'
- Method = 'POST'
- Body = $body
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/repos'
+ Method = 'POST'
+ Body = $body
+ }
- if ($PSCmdlet.ShouldProcess('Repository for user', 'Create')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess('Repository for user', 'Create')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
}
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1
index 1958b385..4f5846da 100644
--- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1
@@ -33,24 +33,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/blocks/$Username"
- Method = 'PUT'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- try {
- $null = (Invoke-GitHubAPI @inputObject)
- # Should we check if user is already blocked and return true if so?
- return $true
- } catch {
- if ($_.Exception.Response.StatusCode.Value__ -eq 422) {
- return $false
- } else {
- Write-Error $_.Exception.Response
- throw $_
+ process {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/blocks/$Username"
+ Method = 'PUT'
+ }
+
+ try {
+ $null = (Invoke-GitHubAPI @inputObject)
+ # Should we check if user is already blocked and return true if so?
+ return $true
+ } catch {
+ if ($_.Exception.Response.StatusCode.Value__ -eq 422) {
+ return $false
+ } else {
+ Write-Error $_.Exception.Response
+ throw $_
+ }
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1
index 070070e3..76861487 100644
--- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1
@@ -28,21 +28,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/blocks'
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/blocks'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1
index d524f20c..ebd64b1f 100644
--- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1
@@ -40,27 +40,41 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/blocks/$Username"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- try {
- (Invoke-GitHubAPI @inputObject).StatusCode -eq 204
- } catch {
- if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
- return $false
- } else {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/blocks/$Username"
+ Method = 'GET'
+ Body = $body
+ }
+
+ try {
+ (Invoke-GitHubAPI @inputObject).StatusCode -eq 204
+ } catch {
+ if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
+ return $false
+ } else {
+ throw $_
+ }
+ }
+ } catch {
throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1
index 55e11c29..ef2916a5 100644
--- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1
@@ -33,19 +33,34 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
+
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/blocks/$Username"
+ Method = 'DELETE'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/blocks/$Username"
- Method = 'DELETE'
+ try {
+ $null = (Invoke-GitHubAPI @inputObject)
+ return $true
+ } catch {
+ Write-Error $_.Exception.Response
+ throw $_
+ }
+ } catch {
+ throw $_
+ }
}
- try {
- $null = (Invoke-GitHubAPI @inputObject)
- return $true
- } catch {
- Write-Error $_.Exception.Response
- throw $_
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1
index 3920bc53..9929a4dc 100644
--- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1
+++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1
@@ -30,20 +30,34 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
- }
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/emails'
- Method = 'GET'
- Body = $body
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/emails'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1
index 8c2deebf..d810b061 100644
--- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1
+++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1
@@ -32,21 +32,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/public_emails'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/public_emails'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1
index dbf9efaa..5651515d 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1
@@ -38,21 +38,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/followers"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/followers"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1
index e229a5ad..7de86587 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1
@@ -29,21 +29,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/following'
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/following'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1
index 66dff1aa..90f9ded8 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1
@@ -38,21 +38,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/following"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/following"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1
index e11bf920..1d9af601 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1
@@ -30,21 +30,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/followers'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/followers'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1
index 2f3cf828..483e7d52 100644
--- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1
+++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1
@@ -32,22 +32,33 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/following/$Username"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- try {
- $null = (Invoke-GitHubAPI @inputObject)
- return $true
- } catch {
- if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
- return $false
- } else {
- throw $_
+ process {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/following/$Username"
+ Method = 'GET'
+ }
+
+ try {
+ $null = (Invoke-GitHubAPI @inputObject)
+ return $true
+ } catch {
+ if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
+ return $false
+ } else {
+ throw $_
+ }
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1
index 49bde7d9..e816d018 100644
--- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1
+++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1
@@ -38,22 +38,33 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/following/$Follows"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- try {
- $null = (Invoke-GitHubAPI @inputObject)
- return $true
- } catch {
- if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
- return $false
- } else {
- throw $_
+ process {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/following/$Follows"
+ Method = 'GET'
+ }
+
+ try {
+ $null = (Invoke-GitHubAPI @inputObject)
+ return $true
+ } catch {
+ if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
+ return $false
+ } else {
+ throw $_
+ }
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1
index e137fb97..2d21817b 100644
--- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1
+++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1
@@ -36,21 +36,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/gpg_keys"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/gpg_keys"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1
index 45fdbe31..dfdc6d03 100644
--- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1
+++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1
@@ -31,21 +31,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/gpg_keys'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/gpg_keys'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1
index 5f88b848..01ffbe5c 100644
--- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1
+++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1
@@ -33,16 +33,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/gpg_keys/$ID"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/gpg_keys/$ID"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1
index 45512ae1..1a6d095e 100644
--- a/src/functions/private/Users/Get-GitHubAllUser.ps1
+++ b/src/functions/private/Users/Get-GitHubAllUser.ps1
@@ -36,22 +36,36 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- since = $Since
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/users'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ since = $Since
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/users'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1
index 31fca26d..b58ad6ed 100644
--- a/src/functions/private/Users/Get-GitHubMyUser.ps1
+++ b/src/functions/private/Users/Get-GitHubMyUser.ps1
@@ -26,16 +26,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user'
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1
index 23fbcf0a..be4c82bd 100644
--- a/src/functions/private/Users/Get-GitHubUserByName.ps1
+++ b/src/functions/private/Users/Get-GitHubUserByName.ps1
@@ -44,16 +44,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1
index 387d0286..ce4ebdcc 100644
--- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1
+++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1
@@ -36,21 +36,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/keys"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/keys"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1
index 6ac7cc4f..2ebe8ac8 100644
--- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1
+++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1
@@ -31,21 +31,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/keys'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/keys'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1
index 708366a6..32642acc 100644
--- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1
+++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1
@@ -33,16 +33,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/keys/$ID"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/keys/$ID"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1
index be19c95c..30706acd 100644
--- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1
+++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1
@@ -31,21 +31,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/ssh_signing_keys'
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/ssh_signing_keys'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1
index 3fb5d79a..d4db058f 100644
--- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1
+++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1
@@ -34,16 +34,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/ssh_signing_keys/$ID"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/ssh_signing_keys/$ID"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1
index 742388a2..fccf461e 100644
--- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1
+++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1
@@ -36,21 +36,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/ssh_signing_keys"
- Method = 'GET'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/ssh_signing_keys"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1
index b888f2ae..f9ff2102 100644
--- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1
+++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1
@@ -29,21 +29,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/social_accounts'
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/social_accounts'
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1
index 9289d985..4cff51bd 100644
--- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1
+++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1
@@ -32,16 +32,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/social_accounts"
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/social_accounts"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1 b/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1
index 38968847..0827535c 100644
--- a/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1
+++ b/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1
@@ -41,5 +41,21 @@
[AllowNull()]
[object] $InputObject
)
- $InputObject | ConvertTo-Json -Depth 100 | ConvertFrom-Json
+
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ $InputObject | ConvertTo-Json -Depth 100 | ConvertFrom-Json
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1 b/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1
index 8b5e71f4..edcfa481 100644
--- a/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1
+++ b/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1
@@ -57,11 +57,26 @@
)]
[string]$NameCasingStyle
)
- [hashtable]$hashtable = @{}
- foreach ($item in $InputObject.PSObject.Properties) {
- $name = if ($NameCasingStyle) { ($item.Name | Convert-StringCasingStyle -To $NameCasingStyle) } else { $item.Name }
- $hashtable[$name] = $item.Value
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ [hashtable]$hashtable = @{}
+ }
+
+ process {
+ try {
+ foreach ($item in $InputObject.PSObject.Properties) {
+ $name = if ($NameCasingStyle) { ($item.Name | Convert-StringCasingStyle -To $NameCasingStyle) } else { $item.Name }
+ $hashtable[$name] = $item.Value
+ }
+ $hashtable
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
- $hashtable
}
diff --git a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 b/src/functions/private/Utilities/Hashtable/Join-Object.ps1
index 18306e04..3e90ae27 100644
--- a/src/functions/private/Utilities/Hashtable/Join-Object.ps1
+++ b/src/functions/private/Utilities/Hashtable/Join-Object.ps1
@@ -73,24 +73,40 @@
[switch] $AsHashtable
)
- if ($Main -isnot [hashtable]) {
- $Main = $Main | ConvertTo-HashTable
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- $hashtable = $Main.clone()
- foreach ($Override in $Overrides) {
- if ($Override -isnot [hashtable]) {
- $Override = $Override | ConvertTo-HashTable
- }
+ process {
+ try {
+
+ if ($Main -isnot [hashtable]) {
+ $Main = $Main | ConvertTo-HashTable
+ }
+ $hashtable = $Main.clone()
+
+ foreach ($Override in $Overrides) {
+ if ($Override -isnot [hashtable]) {
+ $Override = $Override | ConvertTo-HashTable
+ }
- $Override.Keys | ForEach-Object {
- $hashtable[$_] = $Override[$_]
+ $Override.Keys | ForEach-Object {
+ $hashtable[$_] = $Override[$_]
+ }
+ }
+
+ if ($AsHashtable) {
+ return $hashtable
+ }
+
+ $hashtable | ConvertFrom-HashTable
+ } catch {
+ throw $_
}
}
- if ($AsHashtable) {
- return $hashtable
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
- $hashtable | ConvertFrom-HashTable
}
diff --git a/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 b/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1
index fc37c769..9b8e1c6d 100644
--- a/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1
+++ b/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1
@@ -54,39 +54,54 @@
[string[]] $KeepNames
)
- if ($NullOrEmptyValues) {
- Write-Debug 'Remove keys with null or empty values'
- ($Hashtable.GetEnumerator() | Where-Object { [string]::IsNullOrEmpty($_.Value) }) | ForEach-Object {
- Write-Debug " - [$($_.Name)] - Value: [$($_.Value)] - Remove"
- $Hashtable.Remove($_.Name)
- }
- }
- if ($RemoveTypes) {
- Write-Debug "Remove keys of type: [$RemoveTypes]"
- ($Hashtable.GetEnumerator() | Where-Object { ($_.Value.GetType().Name -in $RemoveTypes) }) | ForEach-Object {
- Write-Debug " - [$($_.Name)] - Type: [$($_.Value.GetType().Name)] - Remove"
- $Hashtable.Remove($_.Name)
- }
- }
- if ($KeepTypes) {
- Write-Debug "Remove keys NOT of type: [$KeepTypes]"
- ($Hashtable.GetEnumerator() | Where-Object { ($_.Value.GetType().Name -notin $KeepTypes) }) | ForEach-Object {
- Write-Debug " - [$($_.Name)] - Type: [$($_.Value.GetType().Name)] - Remove"
- $Hashtable.Remove($_.Name)
- }
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- if ($RemoveNames) {
- Write-Debug "Remove keys named: [$RemoveNames]"
- ($Hashtable.GetEnumerator() | Where-Object { $_.Name -in $RemoveNames }) | ForEach-Object {
- Write-Debug " - [$($_.Name)] - Remove"
- $Hashtable.Remove($_.Name)
+
+ process {
+ try {
+ if ($NullOrEmptyValues) {
+ Write-Debug 'Remove keys with null or empty values'
+ ($Hashtable.GetEnumerator() | Where-Object { [string]::IsNullOrEmpty($_.Value) }) | ForEach-Object {
+ Write-Debug " - [$($_.Name)] - Value: [$($_.Value)] - Remove"
+ $Hashtable.Remove($_.Name)
+ }
+ }
+ if ($RemoveTypes) {
+ Write-Debug "Remove keys of type: [$RemoveTypes]"
+ ($Hashtable.GetEnumerator() | Where-Object { ($_.Value.GetType().Name -in $RemoveTypes) }) | ForEach-Object {
+ Write-Debug " - [$($_.Name)] - Type: [$($_.Value.GetType().Name)] - Remove"
+ $Hashtable.Remove($_.Name)
+ }
+ }
+ if ($KeepTypes) {
+ Write-Debug "Remove keys NOT of type: [$KeepTypes]"
+ ($Hashtable.GetEnumerator() | Where-Object { ($_.Value.GetType().Name -notin $KeepTypes) }) | ForEach-Object {
+ Write-Debug " - [$($_.Name)] - Type: [$($_.Value.GetType().Name)] - Remove"
+ $Hashtable.Remove($_.Name)
+ }
+ }
+ if ($RemoveNames) {
+ Write-Debug "Remove keys named: [$RemoveNames]"
+ ($Hashtable.GetEnumerator() | Where-Object { $_.Name -in $RemoveNames }) | ForEach-Object {
+ Write-Debug " - [$($_.Name)] - Remove"
+ $Hashtable.Remove($_.Name)
+ }
+ }
+ if ($KeepNames) {
+ Write-Debug "Remove keys NOT named: [$KeepNames]"
+ ($Hashtable.GetEnumerator() | Where-Object { $_.Name -notin $KeepNames }) | ForEach-Object {
+ Write-Debug " - [$($_.Name)] - Remove"
+ $Hashtable.Remove($_.Name)
+ }
+ }
+ } catch {
+ throw $_
}
}
- if ($KeepNames) {
- Write-Debug "Remove keys NOT named: [$KeepNames]"
- ($Hashtable.GetEnumerator() | Where-Object { $_.Name -notin $KeepNames }) | ForEach-Object {
- Write-Debug " - [$($_.Name)] - Remove"
- $Hashtable.Remove($_.Name)
- }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/private/Utilities/PowerShell/Get-PSCallStackPath.ps1 b/src/functions/private/Utilities/PowerShell/Get-PSCallStackPath.ps1
new file mode 100644
index 00000000..ab2b3e97
--- /dev/null
+++ b/src/functions/private/Utilities/PowerShell/Get-PSCallStackPath.ps1
@@ -0,0 +1,48 @@
+function Get-PSCallStackPath {
+ <#
+ .SYNOPSIS
+ Create a string representation of the current call stack.
+
+ .DESCRIPTION
+ This function creates a string representation of the current call stack.
+ You can use the SkipFirst and SkipLatest parameters to skip the first and last.
+ By default it will skip the first (what called the initial function, typically ),
+ and the last (the current function, Get-PSCallStackPath).
+
+ .EXAMPLE
+ Get-PSCallStackPath
+ First-Function\Second-Function\Third-Function
+
+ Shows the call stack of the last function called, Third-Function, with the first () and last (Get-PSCallStackPath) functions removed.
+
+ .EXAMPLE
+ Get-PSCallStackPath -SkipFirst 0
+ \First-Function\Second-Function\Third-Function
+
+ Shows the call stack of the last function called, Third-Function, with the first function included (typically ).
+
+ .EXAMPLE
+ Get-PSCallStackPath -SkipLatest 0
+ First-Function\Second-Function\Third-Function\Get-PSCallStackPath
+
+ Shows the call stack of the last function called, Third-Function, with the last function included (Get-PSCallStackPath).
+ #>
+ [CmdletBinding()]
+ param(
+ # Number of the functions to skip from the last function called.
+ # Last function is this function, Get-PSCallStackPath.
+ [Parameter()]
+ [int] $SkipLatest = 1,
+
+ # Number of the functions to skip from the first function called.
+ # First function is typically .
+ [Parameter()]
+ [int] $SkipFirst = 1
+ )
+ $skipFirst++
+ $cmds = (Get-PSCallStack).Command
+ $functionPath = $cmds[($cmds.Count - $skipFirst)..$SkipLatest] -join '\'
+ $functionPath = $functionPath -replace '^.*\\'
+ $functionPath = $functionPath -replace '^.*.ps1\\'
+ return $functionPath
+}
diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1
index 1c71f940..af1dd5cc 100644
--- a/src/functions/public/API/Invoke-GitHubAPI.ps1
+++ b/src/functions/public/API/Invoke-GitHubAPI.ps1
@@ -83,8 +83,8 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
Write-Debug 'Invoking GitHub API...'
Write-Debug 'Parameters:'
@@ -105,12 +105,12 @@
if ([string]::IsNullOrEmpty($ApiBaseUri)) {
$ApiBaseUri = $Context.ApiBaseUri
}
- Write-Debug "ApiBaseUri : [$($Context.ApiBaseUri)]"
+ Write-Debug "ApiBaseUri: [$($Context.ApiBaseUri)]"
if ([string]::IsNullOrEmpty($ApiVersion)) {
$ApiVersion = $Context.ApiVersion
}
- Write-Debug "ApiVersion : [$($Context.ApiVersion)]"
+ Write-Debug "ApiVersion: [$($Context.ApiVersion)]"
switch ($TokenType) {
'ghu' {
@@ -251,6 +251,6 @@
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1
index 781d94c2..62baac08 100644
--- a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1
@@ -26,24 +26,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/disable"
+ Method = 'PUT'
+ }
+
+ $null = Invoke-GitHubAPI @inputObject
+ } catch {
+ throw $_
+ }
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/disable"
- Method = 'PUT'
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
- $null = Invoke-GitHubAPI @inputObject
-
}
diff --git a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1
index bea1ef5d..45c72dfb 100644
--- a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1
@@ -23,23 +23,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/enable"
+ Method = 'PUT'
+ }
+
+ $null = Invoke-GitHubAPI @inputObject
+ } catch {
+ throw $_
+ }
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/enable"
- Method = 'PUT'
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
- $null = Invoke-GitHubAPI @inputObject
}
diff --git a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Get-GitHubWorkflow.ps1
index 3c687390..fb86ae7b 100644
--- a/src/functions/public/Actions/Get-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Get-GitHubWorkflow.ps1
@@ -40,31 +40,44 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = @{
- per_page = $PerPage
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/actions/workflows"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.workflows
+ }
+ } catch {
+ throw $_
+ }
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/actions/workflows"
- Method = 'GET'
- Body = $body
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response.workflows
- }
-
}
diff --git a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1
index cfe456e5..ca87abfd 100644
--- a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1
@@ -1,23 +1,107 @@
filter Get-GitHubWorkflowRun {
<#
+ .SYNOPSIS
+ List workflow runs for a repository or a workflow
+
+ .DESCRIPTION
+ Lists all workflow runs for a repository or a workflow. You can use parameters to narrow the list of results. For more information about using
+ parameters, see [Parameters](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#parameters).
+ Anyone with read access to the repository can use this endpoint.
+ OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint with a private repository.
+ This endpoint will return up to 1,000 results for each search when using the following parameters: `actor`, `branch`, `check_suite_id`, `created`,
+ `event`, `head_sha`, `status`.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRun -Owner 'owner' -Repo 'repo'
+
+ Lists all workflow runs for a repository.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRun -Owner 'owner' -Repo 'repo' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success'
+
+ Lists all workflow runs for a repository with the specified actor, branch, event, and status.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRun -Owner 'octocat' -Repo 'Hello-World' -ID '42'
+
+ Gets all workflow runs for the workflow with the ID `42` in the repository `Hello-World` owned by `octocat`.
+
+ .EXAMPLE
+ Get-GitHubWorkflowRun -Owner 'octocat' -Repo 'Hello-World' -Name 'nightly.yml' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success'
+
+ Gets all workflow runs for the workflow with the name `nightly.yml` in the repository `Hello-World` owned by `octocat` that were triggered by
+ the user `octocat` on the branch `main` and have the status `success`.
+
.NOTES
[List workflow runs for a workflow](https://docs.github.com/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-workflow)
[List workflow runs for a repository](https://docs.github.com/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository)
#>
- [CmdletBinding(DefaultParameterSetName = 'Repo')]
+ [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'Event',
+ Justification = 'A parameter that is used in the api call.')]
param(
- [Parameter()]
+ # The account owner of the repository. The name is not case sensitive.
+ [Parameter(Mandatory)]
[string] $Owner,
- [Parameter()]
+ # The name of the repository. The name is not case sensitive.
+ [Parameter(Mandatory)]
[string] $Repo,
- [Parameter(ParameterSetName = 'ByName')]
+ # The ID of the workflow. You can also pass the workflow filename as a string.
+ [Parameter(
+ Mandatory,
+ ParameterSetName = 'ByID'
+ )]
+ [Alias('workflow_id', 'WorkflowID')]
+ [string] $ID,
+
+ # The name of the workflow.
+ [Parameter(
+ Mandatory,
+ ParameterSetName = 'ByName'
+ )]
[string] $Name,
- [Parameter(ParameterSetName = 'ByID')]
- [string] $ID,
+ # Returns someone's workflow runs. Use the login for the user who created the push associated with the check suite or workflow run.
+ [Parameter()]
+ [string] $Actor,
+
+ # Returns workflow runs associated with a branch. Use the name of the branch of the `push`.
+ [Parameter()]
+ [string] $Branch,
+
+ # Returns workflow run triggered by the event you specify. For example, `push`, `pull_request` or `issue`. For more information, see
+ # "[Events that trigger workflows](https://docs.github.com/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows)."
+ [Parameter()]
+ [string] $Event,
+
+ # Returns workflow runs with the check run status or conclusion that you specify. For example, a conclusion can be success or a status can be
+ # `in_progress`. Only GitHub Actions can set a status of `waiting`, `pending`, or `requested`.
+ # Can be one of: `completed`, `action_required`, `cancelled`, `failure`, `neutral`, `skipped`, `stale`, `success`, `timed_out`, `in_progress`,
+ # `queued`, `requested`, `waiting`, `pending`.
+ [Parameter()]
+ [ValidateSet('completed', 'action_required', 'cancelled', 'failure', 'neutral', 'skipped', 'stale', 'success', 'timed_out', 'in_progress',
+ 'queued', 'requested', 'waiting', 'pending')]
+ [string] $Status,
+
+ # Returns workflow runs created within the given date-time range. For more information on the syntax, see
+ # "[Understanding the search syntax](https://docs.github.com/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates)."
+ [Parameter()]
+ [datetime] $Created,
+
+ # If `true` pull requests are omitted from the response (empty array).
+ [Parameter()]
+ [switch] $ExcludePullRequests,
+
+ # Returns workflow runs with the check_suite_id that you specify.
+ [Parameter()]
+ [int] $CheckSuiteID,
+
+ # Only returns workflow runs that are associated with the specified head_sha.
+ [Parameter()]
+ [string] $HeadSHA,
# The number of results per page (max 100).
[Parameter()]
@@ -30,41 +114,59 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $params = @{
+ Owner = $Owner
+ Repo = $Repo
+ Actor = $Actor
+ Branch = $Branch
+ Event = $Event
+ Status = $Status
+ Created = $Created
+ ExcludePullRequests = $ExcludePullRequests
+ CheckSuiteID = $CheckSuiteID
+ HeadSHA = $HeadSHA
+ PerPage = $PerPage
+ }
- $body = @{
- per_page = $PerPage
- }
+ switch ($PSCmdlet.ParameterSetName) {
+ 'ByID' {
+ $params['ID'] = $ID
+ Get-GitHubWorkflowRunByWorkflow @params
+ }
- if ($Name) {
- $ID = (Get-GitHubWorkflow -Owner $Owner -Repo $Repo -Name $Name).id
- }
-
- if ($ID) {
- $Uri = "/repos/$Owner/$Repo/actions/workflows/$ID/runs"
- } else {
- $Uri = "/repos/$Owner/$Repo/actions/runs"
- }
+ 'ByName' {
+ $params['ID'] = (Get-GitHubWorkflow -Owner $Owner -Repo $Repo -Name $Name).id
+ Get-GitHubWorkflowRunByWorkflow @params
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = $Uri
- Method = 'GET'
- Body = $body
+ '__AllParameterSets' {
+ Get-GitHubWorkflowRunByRepo @params
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response.workflow_runs
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1
index 2749659e..47fa47ad 100644
--- a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1
+++ b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1
@@ -34,26 +34,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
- $inputObject = @{
- Context = $Context
- Method = 'GET'
- APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/timing"
- }
+ $inputObject = @{
+ Context = $Context
+ Method = 'GET'
+ APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/timing"
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response.billable
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.billable
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1
index b8909886..230f5094 100644
--- a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1
@@ -40,28 +40,41 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "repos/$Owner/$Repo/actions/runs/$RunID"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "repos/$Owner/$Repo/actions/runs/$RunID"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("workflow run with ID [$RunID] in [$Owner/$Repo]", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("workflow run with ID [$RunID] in [$Owner/$Repo]", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Start-GitHubWorkflow.ps1
index 96dfe00f..67cae215 100644
--- a/src/functions/public/Actions/Start-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Start-GitHubWorkflow.ps1
@@ -52,34 +52,47 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $body = @{
+ ref = $Ref
+ inputs = $Inputs
+ }
- $body = @{
- ref = $Ref
- inputs = $Inputs
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/dispatches"
+ Method = 'POST'
+ Body = $body
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/dispatches"
- Method = 'POST'
- Body = $body
- }
-
- if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Start')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Start')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1
index a5209b1b..183775e2 100644
--- a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1
+++ b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1
@@ -36,27 +36,41 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ Method = 'POST'
+ APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/rerun"
+ }
- $inputObject = @{
- Context = $Context
- Method = 'POST'
- APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/rerun"
+ if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Re-run')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Re-run')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1
index 2138de50..57ee67c6 100644
--- a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1
@@ -36,27 +36,41 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ Method = 'POST'
+ APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/cancel"
+ }
- $inputObject = @{
- Context = $Context
- Method = 'POST'
- APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/cancel"
+ if ($PSCmdlet.ShouldProcess("workflow run with ID [$ID] in [$Owner/$Repo]", 'Cancel/Stop')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("workflow run with ID [$ID] in [$Owner/$Repo]", 'Cancel/Stop')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Apps/Get-GitHubAppJSONWebToken.ps1 b/src/functions/public/Apps/Get-GitHubAppJSONWebToken.ps1
index 18318fe7..24fdbb1d 100644
--- a/src/functions/public/Apps/Get-GitHubAppJSONWebToken.ps1
+++ b/src/functions/public/Apps/Get-GitHubAppJSONWebToken.ps1
@@ -67,8 +67,8 @@ function Get-GitHubAppJSONWebToken {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
process {
@@ -129,8 +129,7 @@ function Get-GitHubAppJSONWebToken {
}
end {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
clean {
diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1
index bbcd89b3..f77eb9b1 100644
--- a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1
+++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1
@@ -39,15 +39,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
- Assert-GitHubContext -Context $Context -AuthType App
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
- switch ($PSCmdlet.ParameterSetName) {
- 'BySlug' {
- Get-GitHubAppByName -AppSlug $AppSlug -Context $Context
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
}
- default {
- Get-GitHubAuthenticatedApp -Context $Context
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
+ }
+
+ process {
+ try {
+ switch ($PSCmdlet.ParameterSetName) {
+ 'BySlug' {
+ Get-GitHubAppByName -AppSlug $AppSlug -Context $Context
+ }
+ default {
+ Get-GitHubAuthenticatedApp -Context $Context
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
+
diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1
index fb8c1aef..d65c0e5f 100644
--- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1
+++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1
@@ -25,16 +25,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
- Assert-GitHubContext -Context $Context -AuthType App
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType APP
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/app/installations'
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/app/installations'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1
index 34bf8658..3e09fe39 100644
--- a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1
+++ b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1
@@ -65,21 +65,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
- Assert-GitHubContext -Context $Context -AuthType App
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/app/installations/$InstallationID/access_tokens"
- Method = 'Post'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType APP
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- [pscustomobject]@{
- Token = $_.Response.token | ConvertTo-SecureString -AsPlainText -Force
- ExpiresAt = $_.Response.expires_at.ToLocalTime()
- Permissions = $_.Response.permissions
- RepositorySelection = $_.Response.repository_selection
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/app/installations/$InstallationID/access_tokens"
+ Method = 'Post'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ [pscustomobject]@{
+ Token = $_.Response.token | ConvertTo-SecureString -AsPlainText -Force
+ ExpiresAt = $_.Response.expires_at.ToLocalTime()
+ Permissions = $_.Response.permissions
+ RepositorySelection = $_.Response.repository_selection
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
+
+ clean {
+ [System.GC]::Collect()
+ }
}
diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1
index 163b65fd..94c3b3f1 100644
--- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1
+++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1
@@ -26,16 +26,31 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
- Assert-GitHubContext -Context $Context -AuthType App
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType APP
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/app/hook/config'
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/app/hook/config'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
+
diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1
index e5a25609..a548e8e9 100644
--- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1
+++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1
@@ -25,16 +25,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
- Assert-GitHubContext -Context $Context -AuthType App
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType APP
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/app/hook/deliveries'
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/app/hook/deliveries'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1
index d760ee17..cc5ae25c 100644
--- a/src/functions/public/Auth/Connect-GitHubAccount.ps1
+++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1
@@ -148,8 +148,8 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
process {
@@ -315,7 +315,7 @@
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
clean {
diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1
index 0fa7235f..457fb779 100644
--- a/src/functions/public/Auth/Connect-GitHubApp.ps1
+++ b/src/functions/public/Auth/Connect-GitHubApp.ps1
@@ -68,8 +68,8 @@ function Connect-GitHubApp {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
process {
@@ -139,11 +139,11 @@ function Connect-GitHubApp {
}
} catch {
Write-Error $_
- Write-Error (Get-PSCallStack | Format-Table | Out-String)
throw 'Failed to connect to GitHub using a GitHub App.'
}
}
+
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Context/Get-GitHubContext.ps1 b/src/functions/public/Auth/Context/Get-GitHubContext.ps1
index ef228537..f14da0dd 100644
--- a/src/functions/public/Auth/Context/Get-GitHubContext.ps1
+++ b/src/functions/public/Auth/Context/Get-GitHubContext.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.3' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
function Get-GitHubContext {
<#
@@ -37,13 +37,12 @@ function Get-GitHubContext {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$null = Get-GitHubConfig
}
process {
-
switch ($PSCmdlet.ParameterSetName) {
'NamedContext' {
Write-Verbose "NamedContext: [$Context]"
@@ -89,6 +88,6 @@ function Get-GitHubContext {
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1 b/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1
index 82a51d3b..095ea62e 100644
--- a/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1
+++ b/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1
@@ -18,8 +18,8 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
}
@@ -30,6 +30,6 @@
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1
index f970da72..28e891ac 100644
--- a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1
+++ b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1
@@ -47,27 +47,31 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
}
process {
- Remove-GitHubContext -Context $Context
- $isDefaultContext = $Context.Name -eq $script:GitHub.Config.DefaultContext
- if ($isDefaultContext) {
- Remove-GitHubConfig -Name 'DefaultContext'
- Write-Warning 'There is no longer a default context!'
- Write-Warning "Please set a new default context using 'Set-GitHubDefaultContext -Name '"
- }
+ try {
+ Remove-GitHubContext -Context $Context
+ $isDefaultContext = $Context.Name -eq $script:GitHub.Config.DefaultContext
+ if ($isDefaultContext) {
+ Remove-GitHubConfig -Name 'DefaultContext'
+ Write-Warning 'There is no longer a default context!'
+ Write-Warning "Please set a new default context using 'Set-GitHubDefaultContext -Name '"
+ }
- if (-not $Silent) {
- Write-Host '✓ ' -ForegroundColor Green -NoNewline
- Write-Host "Logged out of GitHub! [$Context]"
+ if (-not $Silent) {
+ Write-Host '✓ ' -ForegroundColor Green -NoNewline
+ Write-Host "Logged out of GitHub! [$Context]"
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Get-GitHubViewer.ps1 b/src/functions/public/Auth/Get-GitHubViewer.ps1
index 7faf9602..658e4fc3 100644
--- a/src/functions/public/Auth/Get-GitHubViewer.ps1
+++ b/src/functions/public/Auth/Get-GitHubViewer.ps1
@@ -27,26 +27,29 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
}
process {
-
- $query = @"
+ try {
+ $query = @"
query {
viewer {
$($Fields -join "`n")
}
}
"@
- $results = Invoke-GitHubGraphQLQuery -Query $query -Context $Context
+ $results = Invoke-GitHubGraphQLQuery -Query $query -Context $Context
- $results.data.viewer
+ $results.data.viewer
+ } catch {
+ throw $_
+ }
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1 b/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1
index 8e600b12..b104736f 100644
--- a/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1
+++ b/src/functions/public/Auth/Update-GitHubUserAccessToken.ps1
@@ -35,54 +35,70 @@
[switch] $PassThru
)
- $Context = Resolve-GitHubContext -Context $Context
- Write-Verbose "Reusing previously stored ClientID: [$($Context.AuthClientID)]"
- $authClientID = $Context.AuthClientID
- $accessTokenValidity = [datetime]($Context.TokenExpirationDate) - (Get-Date)
- $accessTokenIsValid = $accessTokenValidity.Seconds -gt 0
- $hours = $accessTokenValidity.Hours.ToString().PadLeft(2, '0')
- $minutes = $accessTokenValidity.Minutes.ToString().PadLeft(2, '0')
- $seconds = $accessTokenValidity.Seconds.ToString().PadLeft(2, '0')
- $accessTokenValidityText = "$hours`:$minutes`:$seconds"
- if ($accessTokenIsValid) {
- if ($accessTokenValidity.TotalHours -gt $script:GitHub.Config.AccessTokenGracePeriodInHours) {
- if (-not $Silent) {
- Write-Host '✓ ' -ForegroundColor Green -NoNewline
- Write-Host "Access token is still valid for $accessTokenValidityText ..."
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType UAT
+ }
+
+ process {
+ try {
+ Write-Verbose "Reusing previously stored ClientID: [$($Context.AuthClientID)]"
+ $authClientID = $Context.AuthClientID
+ $accessTokenValidity = [datetime]($Context.TokenExpirationDate) - (Get-Date)
+ $accessTokenIsValid = $accessTokenValidity.Seconds -gt 0
+ $hours = $accessTokenValidity.Hours.ToString().PadLeft(2, '0')
+ $minutes = $accessTokenValidity.Minutes.ToString().PadLeft(2, '0')
+ $seconds = $accessTokenValidity.Seconds.ToString().PadLeft(2, '0')
+ $accessTokenValidityText = "$hours`:$minutes`:$seconds"
+ if ($accessTokenIsValid) {
+ if ($accessTokenValidity.TotalHours -gt $script:GitHub.Config.AccessTokenGracePeriodInHours) {
+ if (-not $Silent) {
+ Write-Host '✓ ' -ForegroundColor Green -NoNewline
+ Write-Host "Access token is still valid for $accessTokenValidityText ..."
+ }
+ return
+ } else {
+ if (-not $Silent) {
+ Write-Host '⚠ ' -ForegroundColor Yellow -NoNewline
+ Write-Host "Access token remaining validity $accessTokenValidityText. Refreshing access token..."
+ }
+ $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -RefreshToken ($Context.RefreshToken) -HostName $Context.HostName
+ }
+ } else {
+ $refreshTokenValidity = [datetime]($Context.RefreshTokenExpirationDate) - (Get-Date)
+ $refreshTokenIsValid = $refreshTokenValidity.Seconds -gt 0
+ if ($refreshTokenIsValid) {
+ if (-not $Silent) {
+ Write-Host '⚠ ' -ForegroundColor Yellow -NoNewline
+ Write-Host 'Access token expired. Refreshing access token...'
+ }
+ $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -RefreshToken ($Context.RefreshToken) -HostName $Context.HostName
+ } else {
+ Write-Verbose "Using $Mode authentication..."
+ $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -Scope $Scope -HostName $Context.HostName
+ }
}
- return
- } else {
- if (-not $Silent) {
- Write-Host '⚠ ' -ForegroundColor Yellow -NoNewline
- Write-Host "Access token remaining validity $accessTokenValidityText. Refreshing access token..."
+ $Context.Token = ConvertTo-SecureString -AsPlainText $tokenResponse.access_token
+ $Context.TokenExpirationDate = (Get-Date).AddSeconds($tokenResponse.expires_in)
+ $Context.TokenType = $tokenResponse.access_token -replace $script:GitHub.TokenPrefixPattern
+ $Context.RefreshToken = ConvertTo-SecureString -AsPlainText $tokenResponse.refresh_token
+ $Context.RefreshTokenExpirationDate = (Get-Date).AddSeconds($tokenResponse.refresh_token_expires_in)
+
+ if ($PSCmdlet.ShouldProcess('Access token', 'Update/refresh')) {
+ Set-GitHubContext -Context $Context
}
- $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -RefreshToken ($Context.RefreshToken) -HostName $Context.HostName
- }
- } else {
- $refreshTokenValidity = [datetime]($Context.RefreshTokenExpirationDate) - (Get-Date)
- $refreshTokenIsValid = $refreshTokenValidity.Seconds -gt 0
- if ($refreshTokenIsValid) {
- if (-not $Silent) {
- Write-Host '⚠ ' -ForegroundColor Yellow -NoNewline
- Write-Host 'Access token expired. Refreshing access token...'
+
+ if ($PassThru) {
+ $Context.Token
}
- $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -RefreshToken ($Context.RefreshToken) -HostName $Context.HostName
- } else {
- Write-Verbose "Using $Mode authentication..."
- $tokenResponse = Invoke-GitHubDeviceFlowLogin -ClientID $authClientID -Scope $Scope -HostName $Context.HostName
+ } catch {
+ throw $_
}
}
- $Context.Token = ConvertTo-SecureString -AsPlainText $tokenResponse.access_token
- $Context.TokenExpirationDate = (Get-Date).AddSeconds($tokenResponse.expires_in)
- $Context.TokenType = $tokenResponse.access_token -replace $script:GitHub.TokenPrefixPattern
- $Context.RefreshToken = ConvertTo-SecureString -AsPlainText $tokenResponse.refresh_token
- $Context.RefreshTokenExpirationDate = (Get-Date).AddSeconds($tokenResponse.refresh_token_expires_in)
-
- if ($PSCmdlet.ShouldProcess('Access token', 'Update/refresh')) {
- Set-GitHubContext -Context $Context
- }
- if ($PassThru) {
- $Context.Token
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1
index 5a3c25c3..eea9e1b8 100644
--- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1
+++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1
@@ -30,25 +30,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/branches"
+ Method = 'GET'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/branches"
- Method = 'GET'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
+
diff --git a/src/functions/public/Commands/Add-GitHubMask.ps1 b/src/functions/public/Commands/Add-GitHubMask.ps1
index 85f257b1..8b156f64 100644
--- a/src/functions/public/Commands/Add-GitHubMask.ps1
+++ b/src/functions/public/Commands/Add-GitHubMask.ps1
@@ -46,7 +46,22 @@
[string[]] $Value
)
- foreach ($item in $Value) {
- Write-Host "::add-mask::$item"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ foreach ($item in $Value) {
+ Write-Host "::add-mask::$item"
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Commands/Add-GitHubSystemPath.ps1 b/src/functions/public/Commands/Add-GitHubSystemPath.ps1
index 02154c13..2465ac7a 100644
--- a/src/functions/public/Commands/Add-GitHubSystemPath.ps1
+++ b/src/functions/public/Commands/Add-GitHubSystemPath.ps1
@@ -24,8 +24,23 @@
[string]$Path
)
- Write-Verbose "Current PATH: $env:PATH"
- Write-Verbose "Adding system path: $Path"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
- $Path | Out-File -FilePath $env:GITHUB_PATH -Append
+ process {
+ try {
+ Write-Verbose "Current PATH: $env:PATH"
+ Write-Verbose "Adding system path: $Path"
+
+ $Path | Out-File -FilePath $env:GITHUB_PATH -Append
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Commands/Disable-GitHubCommand.ps1 b/src/functions/public/Commands/Disable-GitHubCommand.ps1
index bfc89d4f..0c8a6e1c 100644
--- a/src/functions/public/Commands/Disable-GitHubCommand.ps1
+++ b/src/functions/public/Commands/Disable-GitHubCommand.ps1
@@ -34,9 +34,24 @@
[string] $String
)
- $String = $String.ToLower()
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ $String = $String.ToLower()
+
+ if ($env:GITHUB_ACTIONS -eq 'true') {
+ Write-Host "::stop-commands::$String"
+ }
+ } catch {
+ throw $_
+ }
+ }
- if ($env:GITHUB_ACTIONS -eq 'true') {
- Write-Host "::stop-commands::$String"
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Commands/Enable-GitHubCommand.ps1 b/src/functions/public/Commands/Enable-GitHubCommand.ps1
index 2fa7e2f0..d1a0e6ee 100644
--- a/src/functions/public/Commands/Enable-GitHubCommand.ps1
+++ b/src/functions/public/Commands/Enable-GitHubCommand.ps1
@@ -33,9 +33,24 @@
[string] $String
)
- $String = $String.ToLower()
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ $String = $String.ToLower()
+
+ if ($env:GITHUB_ACTIONS -eq 'true') {
+ Write-Host "::$String::"
+ }
+ } catch {
+ throw $_
+ }
+ }
- if ($env:GITHUB_ACTIONS -eq 'true') {
- Write-Host "::$String::"
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Commands/Get-GitHubOutput.ps1 b/src/functions/public/Commands/Get-GitHubOutput.ps1
index d881803d..ed7b7ff6 100644
--- a/src/functions/public/Commands/Get-GitHubOutput.ps1
+++ b/src/functions/public/Commands/Get-GitHubOutput.ps1
@@ -40,9 +40,24 @@
[string] $Path = $env:GITHUB_OUTPUT
)
- if (-not (Test-Path -Path $Path)) {
- throw "File not found: $Path"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- Get-Content -Path $Path | ConvertFrom-GitHubOutput -AsHashtable:$AsHashtable
+ process {
+ try {
+ if (-not (Test-Path -Path $Path)) {
+ throw "File not found: $Path"
+ }
+
+ Get-Content -Path $Path | ConvertFrom-GitHubOutput -AsHashtable:$AsHashtable
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1 b/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1
index 38646ba4..204d4e17 100644
--- a/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1
+++ b/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1
@@ -34,13 +34,28 @@
[string] $Value
)
- Write-Verbose "Env: [$Name] = [$Value]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
- $guid = [guid]::NewGuid().Guid
- $content = @"
+ process {
+ try {
+ Write-Verbose "Env: [$Name] = [$Value]"
+
+ $guid = [guid]::NewGuid().Guid
+ $content = @"
$Name<<$guid
$Value
$guid
"@
- $content | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
+ $content | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Commands/Set-GitHubLogGroup.ps1 b/src/functions/public/Commands/Set-GitHubLogGroup.ps1
index a3516a76..4e1c4865 100644
--- a/src/functions/public/Commands/Set-GitHubLogGroup.ps1
+++ b/src/functions/public/Commands/Set-GitHubLogGroup.ps1
@@ -40,11 +40,22 @@
[scriptblock] $ScriptBlock
)
- Start-GitHubLogGroup -Name $Name
- try {
- . $ScriptBlock
- } catch {
- throw $_
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ Start-GitHubLogGroup -Name $Name
+ try {
+ . $ScriptBlock
+ } catch {
+ throw $_
+ }
+ Stop-GitHubLogGroup
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
- Stop-GitHubLogGroup
}
diff --git a/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1 b/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1
index de57f2d3..4384c7a9 100644
--- a/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1
+++ b/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1
@@ -42,9 +42,24 @@
[scriptblock] $ScriptBlock
)
- $guid = [string][guid]::NewGuid().Guid
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
- Disable-GitHubCommand -String $guid
- . $ScriptBlock
- Enable-GitHubCommand -String $guid
+ process {
+ $guid = [string][guid]::NewGuid().Guid
+
+ Disable-GitHubCommand -String $guid
+ try {
+ . $ScriptBlock
+ } catch {
+ throw $_
+ }
+ Enable-GitHubCommand -String $guid
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Commands/Set-GitHubOutput.ps1 b/src/functions/public/Commands/Set-GitHubOutput.ps1
index 992ce488..b29f7a57 100644
--- a/src/functions/public/Commands/Set-GitHubOutput.ps1
+++ b/src/functions/public/Commands/Set-GitHubOutput.ps1
@@ -36,39 +36,54 @@
[string] $Path = $env:GITHUB_OUTPUT
)
- if (-not (Test-Path -Path $Path)) {
- throw "File not found: $Path"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- $outputs = Get-GitHubOutput -Path $Path -AsHashtable
+ process {
+ try {
+ if (-not (Test-Path -Path $Path)) {
+ throw "File not found: $Path"
+ }
- if ($Value -Is [securestring]) {
- $Value = $Value | ConvertFrom-SecureString -AsPlainText -Force
- Add-Mask -Value $Value
- }
+ $outputs = Get-GitHubOutput -Path $Path -AsHashtable
- if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) {
- Write-Warning 'Cannot create output as the step has no ID.'
- }
+ if ($Value -Is [securestring]) {
+ $Value = $Value | ConvertFrom-SecureString -AsPlainText -Force
+ Add-Mask -Value $Value
+ }
+
+ if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) {
+ Write-Warning 'Cannot create output as the step has no ID.'
+ }
- Write-Verbose "Output: [$Name] = [$Value]"
+ Write-Verbose "Output: [$Name] = [$Value]"
- # If the script is running in a GitHub composite action, accumulate the output under the 'result' key, else append the key-value pair directly.
- if ($env:PSMODULE_GITHUB_SCRIPT) {
- if (-not $outputs.result) {
- $outputs.result = @{
- $Name = $Value
+ # If the script is running in a GitHub composite action, accumulate the output under the 'result' key, else append the key-value pair directly.
+ if ($env:PSMODULE_GITHUB_SCRIPT) {
+ if (-not $outputs.result) {
+ $outputs.result = @{
+ $Name = $Value
+ }
+ } else {
+ $outputs.result[$Name] = $Value
+ }
+ } else {
+ $outputs[$Name] = $Value
}
- } else {
- $outputs.result[$Name] = $Value
+
+ Write-Verbose "Output: [$Name] avaiable as `${{ steps.$env:GITHUB_ACTION.outputs.$Name }}'"
+
+ if ($PSCmdlet.ShouldProcess('GitHub Output', 'Set')) {
+ $outputs | ConvertTo-GitHubOutput | Set-Content -Path $Path
+ }
+ } catch {
+ throw $_
}
- } else {
- $outputs[$Name] = $Value
}
- Write-Verbose "Output: [$Name] avaiable as `${{ steps.$env:GITHUB_ACTION.outputs.$Name }}'"
-
- if ($PSCmdlet.ShouldProcess('GitHub Output', 'Set')) {
- $outputs | ConvertTo-GitHubOutput | Set-Content -Path $Path
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Commands/Set-GitHubStepSummary.ps1 b/src/functions/public/Commands/Set-GitHubStepSummary.ps1
index c987e526..d04e0dd2 100644
--- a/src/functions/public/Commands/Set-GitHubStepSummary.ps1
+++ b/src/functions/public/Commands/Set-GitHubStepSummary.ps1
@@ -42,9 +42,24 @@
[switch] $Overwrite
)
- Write-Verbose 'Step summary:'
- Write-Verbose $Summary
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
- $Append = -not $Overwrite
- $Summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append:$Append
+ process {
+ try {
+ Write-Verbose 'Step summary:'
+ Write-Verbose $Summary
+
+ $Append = -not $Overwrite
+ $Summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append:$Append
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Commands/Start-GitHubLogGroup.ps1 b/src/functions/public/Commands/Start-GitHubLogGroup.ps1
index a32b4525..00f4f00a 100644
--- a/src/functions/public/Commands/Start-GitHubLogGroup.ps1
+++ b/src/functions/public/Commands/Start-GitHubLogGroup.ps1
@@ -27,5 +27,20 @@
[string] $Name
)
- Write-Host "::group::$Name"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ Write-Host "::group::$Name"
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Commands/Stop-GitHubLogGroup.ps1 b/src/functions/public/Commands/Stop-GitHubLogGroup.ps1
index 04d6229d..2d5b8220 100644
--- a/src/functions/public/Commands/Stop-GitHubLogGroup.ps1
+++ b/src/functions/public/Commands/Stop-GitHubLogGroup.ps1
@@ -23,5 +23,20 @@
[Alias('Stop-LogGroup')]
param()
- Write-Host '::endgroup::'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ Write-Host '::endgroup::'
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Commands/Write-GitHubDebug.ps1 b/src/functions/public/Commands/Write-GitHubDebug.ps1
index 4001415b..e473db31 100644
--- a/src/functions/public/Commands/Write-GitHubDebug.ps1
+++ b/src/functions/public/Commands/Write-GitHubDebug.ps1
@@ -35,9 +35,24 @@
[string] $Message
)
- if ($env:GITHUB_ACTIONS -eq 'true') {
- Write-Host "::debug::$Message"
- } else {
- Write-Debug "$Message"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ if ($env:GITHUB_ACTIONS -eq 'true') {
+ Write-Host "::debug::$Message"
+ } else {
+ Write-Debug "$Message"
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Commands/Write-GitHubError.ps1 b/src/functions/public/Commands/Write-GitHubError.ps1
index de1743fd..3ab1c6d8 100644
--- a/src/functions/public/Commands/Write-GitHubError.ps1
+++ b/src/functions/public/Commands/Write-GitHubError.ps1
@@ -55,9 +55,24 @@
[string] $Title
)
- if ($env:GITHUB_ACTIONS -eq 'true') {
- Write-Host "::error file=$Name,line=$Line,col=$Column,endColumn=$EndColumn,endLine=$EndLine,title=$Title::$Message"
- } else {
- Write-Error $Message
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ if ($env:GITHUB_ACTIONS -eq 'true') {
+ Write-Host "::error file=$Name,line=$Line,col=$Column,endColumn=$EndColumn,endLine=$EndLine,title=$Title::$Message"
+ } else {
+ Write-Error $Message
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Commands/Write-GitHubNotice.ps1 b/src/functions/public/Commands/Write-GitHubNotice.ps1
index 51b3ac9e..d206f439 100644
--- a/src/functions/public/Commands/Write-GitHubNotice.ps1
+++ b/src/functions/public/Commands/Write-GitHubNotice.ps1
@@ -55,9 +55,24 @@
[string] $Title
)
- if ($env:GITHUB_ACTIONS -eq 'true') {
- Write-Host "::notice file=$Name,line=$Line,col=$Column,endColumn=$EndColumn,endLine=$EndLine,title=$Title::$Message"
- } else {
- Write-Host $Message
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ if ($env:GITHUB_ACTIONS -eq 'true') {
+ Write-Host "::notice file=$Name,line=$Line,col=$Column,endColumn=$EndColumn,endLine=$EndLine,title=$Title::$Message"
+ } else {
+ Write-Host $Message
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Commands/Write-GitHubWarning.ps1 b/src/functions/public/Commands/Write-GitHubWarning.ps1
index c4fb8f50..22de869a 100644
--- a/src/functions/public/Commands/Write-GitHubWarning.ps1
+++ b/src/functions/public/Commands/Write-GitHubWarning.ps1
@@ -55,9 +55,24 @@
[string] $Title
)
- if ($env:GITHUB_ACTIONS -eq 'true') {
- Write-Host "::warning file=$Name,line=$Line,col=$Column,endColumn=$EndColumn,endLine=$EndLine,title=$Title::$Message"
- } else {
- Write-Warning $Message
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ if ($env:GITHUB_ACTIONS -eq 'true') {
+ Write-Host "::warning file=$Name,line=$Line,col=$Column,endColumn=$EndColumn,endLine=$EndLine,title=$Title::$Message"
+ } else {
+ Write-Warning $Message
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Config/Get-GitHubConfig.ps1 b/src/functions/public/Config/Get-GitHubConfig.ps1
index f854c5b5..80ad7190 100644
--- a/src/functions/public/Config/Get-GitHubConfig.ps1
+++ b/src/functions/public/Config/Get-GitHubConfig.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.3' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
function Get-GitHubConfig {
<#
@@ -22,20 +22,24 @@ function Get-GitHubConfig {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
Initialize-GitHubConfig
}
process {
- if (-not $Name) {
- return [GitHubConfig]($script:GitHub.Config)
+ try {
+ if (-not $Name) {
+ return [GitHubConfig]($script:GitHub.Config)
+ }
+
+ $script:GitHub.Config.$Name
+ } catch {
+ throw $_
}
-
- $script:GitHub.Config.$Name
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Config/Remove-GitHubConfig.ps1 b/src/functions/public/Config/Remove-GitHubConfig.ps1
index 54159e27..fc882ed6 100644
--- a/src/functions/public/Config/Remove-GitHubConfig.ps1
+++ b/src/functions/public/Config/Remove-GitHubConfig.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.3' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
function Remove-GitHubConfig {
<#
@@ -21,8 +21,8 @@ function Remove-GitHubConfig {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
Initialize-GitHubConfig
}
@@ -40,6 +40,6 @@ function Remove-GitHubConfig {
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Config/Reset-GitHubConfig.ps1 b/src/functions/public/Config/Reset-GitHubConfig.ps1
index 06befa70..8b2d979f 100644
--- a/src/functions/public/Config/Reset-GitHubConfig.ps1
+++ b/src/functions/public/Config/Reset-GitHubConfig.ps1
@@ -16,8 +16,8 @@
param ()
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Debug "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
process {
@@ -32,6 +32,6 @@
}
end {
- Write-Debug "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Config/Set-GitHubConfig.ps1 b/src/functions/public/Config/Set-GitHubConfig.ps1
index 5f0816ae..feebfc01 100644
--- a/src/functions/public/Config/Set-GitHubConfig.ps1
+++ b/src/functions/public/Config/Set-GitHubConfig.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.3' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '5.0.4' }
function Set-GitHubConfig {
<#
@@ -25,15 +25,15 @@ function Set-GitHubConfig {
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
Initialize-GitHubConfig
}
process {
- Write-Verbose "Setting [$Name] to [$Value]"
- $script:GitHub.Config.$Name = $Value
try {
+ Write-Verbose "Setting [$Name] to [$Value]"
+ $script:GitHub.Config.$Name = $Value
if ($PSCmdlet.ShouldProcess('ContextSetting', 'Set')) {
Set-Context -ID $script:GitHub.Config.ID -Context $script:GitHub.Config
}
@@ -44,6 +44,6 @@ function Set-GitHubConfig {
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 b/src/functions/public/Emojis/Get-GitHubEmoji.ps1
index 19696c7c..3db00fbb 100644
--- a/src/functions/public/Emojis/Get-GitHubEmoji.ps1
+++ b/src/functions/public/Emojis/Get-GitHubEmoji.ps1
@@ -32,23 +32,38 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/emojis'
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $response = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/emojis'
+ Method = 'GET'
+ }
+
+ $response = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
- if (Test-Path -Path $Destination) {
- $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel {
- Invoke-WebRequest -Uri $_.Value -OutFile "$using:Destination/$($_.Name).png"
+ if (Test-Path -Path $Destination) {
+ $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel {
+ Invoke-WebRequest -Uri $_.Value -OutFile "$using:Destination/$($_.Name).png"
+ }
+ } else {
+ $response
+ }
+ } catch {
+ throw $_
}
- } else {
- $response
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1
index 1b6ec8d4..526e6938 100644
--- a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1
+++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1
@@ -24,20 +24,34 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Enterprise)) {
- $Enterprise = $Context.Enterprise
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Enterprise)) {
+ $Enterprise = $Context.Enterprise
+ }
+ Write-Debug "Enterprise: [$Enterprise]"
}
- Write-Debug "Enterprise : [$($Context.Enterprise)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations"
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1
index 8d269dd7..adbb0deb 100644
--- a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1
+++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1
@@ -20,15 +20,20 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Enterprise)) {
- $Enterprise = $Context.Enterprise
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Enterprise)) {
+ $Enterprise = $Context.Enterprise
+ }
+ Write-Debug "Enterprise: [$Enterprise]"
}
- Write-Debug "Enterprise : [$($Context.Enterprise)]"
- # Define GraphQL query
- $query = @"
+ process {
+ try {
+ $query = @"
query(`$enterpriseSlug: String!, `$first: Int = 100, `$after: String) {
enterprise(slug: `$enterpriseSlug) {
organizations(first: `$first, after: `$after) {
@@ -47,34 +52,42 @@ query(`$enterpriseSlug: String!, `$first: Int = 100, `$after: String) {
}
"@
- # Initialize pagination variables
- $variables = @{
- 'enterpriseSlug' = $Enterprise
- 'first' = 100
- 'after' = $null
- }
- $allOrgs = @()
+ # Initialize pagination variables
+ $variables = @{
+ 'enterpriseSlug' = $Enterprise
+ 'first' = 100
+ 'after' = $null
+ }
+ $allOrgs = @()
- # Loop through pages to retrieve all organizations
- do {
- $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context
- # Check for errors
- if ($response.errors) {
- Write-Error "Error: $($response.errors[0].message)"
- break
- }
+ # Loop through pages to retrieve all organizations
+ do {
+ $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context
+ # Check for errors
+ if ($response.errors) {
+ Write-Error "Error: $($response.errors[0].message)"
+ break
+ }
- # Extract organization names and add to the list
- foreach ($org in $response.data.enterprise.organizations.edges) {
- $allOrgs += $org.node.name
- }
+ # Extract organization names and add to the list
+ foreach ($org in $response.data.enterprise.organizations.edges) {
+ $allOrgs += $org.node.name
+ }
- # Update pagination cursor
- $pageInfo = $response.data.enterprise.organizations.pageInfo
- $variables.after = $pageInfo.endCursor
+ # Update pagination cursor
+ $pageInfo = $response.data.enterprise.organizations.pageInfo
+ $variables.after = $pageInfo.endCursor
- } while ($pageInfo.hasNextPage -eq $true)
+ } while ($pageInfo.hasNextPage -eq $true)
- # Output the list of organization names
- $allOrgs | ForEach-Object { Write-Output $_ }
+ # Output the list of organization names
+ $allOrgs | ForEach-Object { Write-Output $_ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1
index db88f80f..3b6d6df5 100644
--- a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1
+++ b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1
@@ -42,28 +42,41 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Enterprise)) {
- $Enterprise = $Context.Enterprise
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Enterprise)) {
+ $Enterprise = $Context.Enterprise
+ }
+ Write-Debug "Enterprise: [$Enterprise]"
}
- Write-Debug "Enterprise : [$($Context.Enterprise)]"
- $body = @{
- client_id = $ClientID
- repository_selection = $RepositorySelection
- repositories = $Repositories
- }
- $body | Remove-HashtableEntry -NullOrEmptyValues
+ process {
+ try {
+ $body = @{
+ client_id = $ClientID
+ repository_selection = $RepositorySelection
+ repositories = $Repositories
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations"
+ Method = 'Post'
+ Body = $body
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations"
- Method = 'Post'
- Body = $body
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Git/Get-GitHubGitConfig.ps1 b/src/functions/public/Git/Get-GitHubGitConfig.ps1
index e2b9e148..0d7da767 100644
--- a/src/functions/public/Git/Get-GitHubGitConfig.ps1
+++ b/src/functions/public/Git/Get-GitHubGitConfig.ps1
@@ -15,22 +15,33 @@
[CmdletBinding()]
param()
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
-
- $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue
- if (-not $gitExists) {
- throw 'Git is not installed. Please install Git before running this command.'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- git config --local --list | ForEach-Object {
- (
- [pscustomobject]@{
- Name = $_.Split('=')[0]
- Value = $_.Split('=')[1]
+ process {
+ try {
+
+ $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue
+ if (-not $gitExists) {
+ throw 'Git is not installed. Please install Git before running this command.'
}
- )
+
+ git config --local --list | ForEach-Object {
+ (
+ [pscustomobject]@{
+ Name = $_.Split('=')[0]
+ Value = $_.Split('=')[1]
+ }
+ )
+ }
+ } catch {
+ throw $_
+ }
}
- Write-Verbose "[$commandName] - End"
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Git/Set-GitHubGitConfig.ps1 b/src/functions/public/Git/Set-GitHubGitConfig.ps1
index ef13448f..3778ca7b 100644
--- a/src/functions/public/Git/Set-GitHubGitConfig.ps1
+++ b/src/functions/public/Git/Set-GitHubGitConfig.ps1
@@ -25,35 +25,39 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
}
process {
- $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue
- if (-not $gitExists) {
- throw 'Git is not installed. Please install Git before running this command.'
- }
-
- $username = $Context.UserName
- $id = $Context.DatabaseID
- $token = $Context.Token | ConvertFrom-SecureString -AsPlainText
- $hostName = $Context.HostName
-
- if ($PSCmdlet.ShouldProcess("$Name", 'Set Git configuration')) {
- Write-Verbose "git config --local user.name '$username'"
- git config --local user.name "$username"
-
- Write-Verbose "git config --local user.email '$id+$username@users.noreply.github.com'"
- git config --local user.email "$id+$username@users.noreply.github.com"
-
- Write-Verbose "git config --local 'url.https://oauth2:$token@$hostName.insteadOf' 'https://$hostName'"
- git config --local "url.https://oauth2:$token@$hostName.insteadOf" "https://$hostName"
+ try {
+ $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue
+ if (-not $gitExists) {
+ throw 'Git is not installed. Please install Git before running this command.'
+ }
+
+ $username = $Context.UserName
+ $id = $Context.DatabaseID
+ $token = $Context.Token | ConvertFrom-SecureString -AsPlainText
+ $hostName = $Context.HostName
+
+ if ($PSCmdlet.ShouldProcess("$Name", 'Set Git configuration')) {
+ Write-Verbose "git config --local user.name '$username'"
+ git config --local user.name "$username"
+
+ Write-Verbose "git config --local user.email '$id+$username@users.noreply.github.com'"
+ git config --local user.email "$id+$username@users.noreply.github.com"
+
+ Write-Verbose "git config --local 'url.https://oauth2:$token@$hostName.insteadOf' 'https://$hostName'"
+ git config --local "url.https://oauth2:$token@$hostName.insteadOf" "https://$hostName"
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1
index 4a1a3ad5..70ae5b2f 100644
--- a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1
+++ b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1
@@ -49,18 +49,33 @@ filter Get-GitHubGitignore {
}
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ if ([string]::IsNullOrEmpty($Enterprise)) {
+ $Enterprise = $Context.Enterprise
+ }
+ Write-Debug "Enterprise: [$Enterprise]"
}
process {
- $Name = $PSBoundParameters['Name']
- switch ($PSCmdlet.ParameterSetName) {
- 'List' {
- Get-GitHubGitignoreList -Context $Context
- }
- 'Name' {
- Get-GitHubGitignoreByName -Name $Name -Context $Context
+ try {
+ $Name = $PSBoundParameters['Name']
+ switch ($PSCmdlet.ParameterSetName) {
+ 'List' {
+ Get-GitHubGitignoreList -Context $Context
+ }
+ 'Name' {
+ Get-GitHubGitignoreByName -Name $Name -Context $Context
+ }
}
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1
index e6050a83..49e6a887 100644
--- a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1
+++ b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1
@@ -26,28 +26,33 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/graphql'
- Method = 'Post'
- Body = @{
- 'query' = $Query
- 'variables' = $Variables
- } | ConvertTo-Json
- }
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/graphql'
+ Method = 'Post'
+ Body = @{
+ 'query' = $Query
+ 'variables' = $Variables
+ } | ConvertTo-Json
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/License/Get-GitHubLicense.ps1 b/src/functions/public/License/Get-GitHubLicense.ps1
index 14bf025b..1b3bd66b 100644
--- a/src/functions/public/License/Get-GitHubLicense.ps1
+++ b/src/functions/public/License/Get-GitHubLicense.ps1
@@ -67,31 +67,41 @@ filter Get-GitHubLicense {
}
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
-
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
if ([string]::IsNullOrEmpty($Owner)) {
$Owner = $Context.Owner
}
- Write-Debug "Owner : [$($Context.Owner)]"
+ Write-Debug "Owner: [$Owner]"
if ([string]::IsNullOrEmpty($Repo)) {
$Repo = $Context.Repo
}
- Write-Debug "Repo : [$($Context.Repo)]"
+ Write-Debug "Repo: [$Repo]"
}
process {
- $Name = $PSBoundParameters['Name']
- switch ($PSCmdlet.ParameterSetName) {
- 'List' {
- Get-GitHubLicenseList -Context $Context
- }
- 'Name' {
- Get-GitHubLicenseByName -Name $Name -Context $Context
- }
- 'Repository' {
- Get-GitHubRepositoryLicense -Owner $Owner -Repo $Repo -Context $Context
+ try {
+ $Name = $PSBoundParameters['Name']
+ switch ($PSCmdlet.ParameterSetName) {
+ 'List' {
+ Get-GitHubLicenseList -Context $Context
+ }
+ 'Name' {
+ Get-GitHubLicenseByName -Name $Name -Context $Context
+ }
+ 'Repository' {
+ Get-GitHubRepositoryLicense -Owner $Owner -Repo $Repo -Context $Context
+ }
}
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1
index 03842919..bf7a64dd 100644
--- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1
+++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1
@@ -1,10 +1,24 @@
filter Get-GitHubMarkdown {
<#
+ .SYNOPSIS
+ Render a Markdown document
+
+ .DESCRIPTION
+ Converts Markdown to HTML
+
+ .EXAMPLE
+ Get-GitHubMarkdown -Text "Hello **world**"
+ "Hello world
"
+
+ Renders the Markdown text "Hello **world**" to HTML.
+
.NOTES
[Render a Markdown document](https://docs.github.com/en/rest/markdown/markdown#render-a-markdown-document)
#>
+ [OutputType([string])]
[CmdletBinding()]
param(
+ # The Markdown text to render in HTML.
[Parameter(
Mandatory,
ValueFromPipeline,
@@ -12,11 +26,13 @@
)]
[switch] $Text,
+ # The rendering mode.
[Parameter()]
[ValidateSet('markdown', 'gfm')]
[string] $Mode,
- #TODO: Need docs
+ # The repository context to use when creating references in `gfm` mode. For example, setting `context` to `octo-org/octo-repo` will change the
+ # text `#42` into an HTML link to issue 42 in the `octo-org/octo-repo` repository.
[Parameter()]
[string] $RepoContext,
@@ -26,23 +42,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- context = $RepoContext
- mode = $Mode
- text = $Text
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/markdown'
- Method = 'POST'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ context = $RepoContext
+ mode = $Mode
+ text = $Text
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/markdown'
+ Method = 'POST'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1
index 77a5817b..e6cd8850 100644
--- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1
+++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1
@@ -1,11 +1,25 @@
filter Get-GitHubMarkdownRaw {
<#
+ .SYNOPSIS
+ Render a Markdown document in raw mode
+
+ .DESCRIPTION
+ You must send Markdown as plain text (using a `Content-Type` header of `text/plain` or `text/x-markdown`) to this endpoint, rather than using
+ JSON format. In raw mode, [GitHub Flavored Markdown](https://github.github.com/gfm/) is not supported and Markdown will be rendered in plain
+ format like a README.md file. Markdown content must be 400 KB or less.
+
+ .EXAMPLE
+ Get-GitHubMarkdownRaw -Text 'Hello, world!'
+ "Hello world
"
+
+ Render the Markdown text 'Hello, world!' in raw mode.
+
.NOTES
[Render a Markdown document in raw mode](https://docs.github.com/rest/reference/meta#github-api-root)
#>
[CmdletBinding()]
param(
- #TODO: Need docs
+ # The Markdown text to render in HTML.
[Parameter()]
[string] $Text,
@@ -15,17 +29,32 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
+
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/markdown/raw'
+ ContentType = 'text/plain'
+ Body = $Text
+ Method = 'POST'
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/markdown/raw'
- ContentType = 'text/plain'
- Body = $Text
- Method = 'POST'
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 b/src/functions/public/Meta/Get-GitHubApiVersion.ps1
index baedc6a3..6b97d9e2 100644
--- a/src/functions/public/Meta/Get-GitHubApiVersion.ps1
+++ b/src/functions/public/Meta/Get-GitHubApiVersion.ps1
@@ -24,24 +24,29 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- ApiEndpoint = '/versions'
- Method = 'GET'
- }
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ try {
+ $inputObject = @{
+ Context = $Context
+ ApiEndpoint = '/versions'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Meta/Get-GitHubMeta.ps1 b/src/functions/public/Meta/Get-GitHubMeta.ps1
index 25ac1ca2..1aa4ece0 100644
--- a/src/functions/public/Meta/Get-GitHubMeta.ps1
+++ b/src/functions/public/Meta/Get-GitHubMeta.ps1
@@ -32,24 +32,29 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- ApiEndpoint = '/meta'
- Method = 'GET'
- }
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ try {
+ $inputObject = @{
+ Context = $Context
+ ApiEndpoint = '/meta'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Meta/Get-GitHubOctocat.ps1 b/src/functions/public/Meta/Get-GitHubOctocat.ps1
index 1f8f3120..9ea7534f 100644
--- a/src/functions/public/Meta/Get-GitHubOctocat.ps1
+++ b/src/functions/public/Meta/Get-GitHubOctocat.ps1
@@ -35,29 +35,34 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $body = @{
- s = $S
- }
+ try {
+ $body = @{
+ s = $S
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/octocat'
- Method = 'GET'
- Body = $body
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/octocat'
+ Method = 'GET'
+ Body = $body
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Meta/Get-GitHubRoot.ps1 b/src/functions/public/Meta/Get-GitHubRoot.ps1
index 9a1129a5..566100b1 100644
--- a/src/functions/public/Meta/Get-GitHubRoot.ps1
+++ b/src/functions/public/Meta/Get-GitHubRoot.ps1
@@ -23,24 +23,29 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/'
- Method = 'GET'
- }
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Meta/Get-GitHubZen.ps1 b/src/functions/public/Meta/Get-GitHubZen.ps1
index 54baf46a..63cb0015 100644
--- a/src/functions/public/Meta/Get-GitHubZen.ps1
+++ b/src/functions/public/Meta/Get-GitHubZen.ps1
@@ -23,24 +23,29 @@
)
begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Verbose "[$commandName] - Start"
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/zen'
- Method = 'GET'
- }
-
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/zen'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
}
}
end {
- Write-Verbose "[$commandName] - End"
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1
index b28609c6..962f7194 100644
--- a/src/functions/public/Organization/Get-GitHubOrganization.ps1
+++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1
@@ -79,25 +79,41 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- switch ($PSCmdlet.ParameterSetName) {
- '__DefaultSet' {
- Get-GitHubMyOrganization -PerPage $PerPage -Context $Context | Get-GitHubOrganizationByName -Context $Context
- }
- 'NamedOrg' {
- Get-GitHubOrganizationByName -Organization $Organization -Context $Context
- }
- 'NamedUser' {
- Get-GitHubUserOrganization -Username $Username -Context $Context
- }
- 'AllOrg' {
- Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context
+ process {
+ try {
+
+ switch ($PSCmdlet.ParameterSetName) {
+ '__DefaultSet' {
+ Get-GitHubMyOrganization -PerPage $PerPage -Context $Context | Get-GitHubOrganizationByName -Context $Context
+ }
+ 'NamedOrg' {
+ Get-GitHubOrganizationByName -Organization $Organization -Context $Context
+ }
+ 'NamedUser' {
+ Get-GitHubUserOrganization -Username $Username -Context $Context
+ }
+ 'AllOrg' {
+ Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1
index 5c373d02..6df2ab51 100644
--- a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1
+++ b/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1
@@ -41,25 +41,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- $body = @{
- per_page = $PerPage
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/installations"
+ Method = 'GET'
+ Body = $body
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/installations"
- Method = 'GET'
- Body = $body
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.installations
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response.installations
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1
index 24f6ef5c..05f0f1c5 100644
--- a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1
+++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1
@@ -41,27 +41,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- $body = @{
- filter = $Filter
- role = $Role
- per_page = $PerPage
- }
+ process {
+ try {
+ $body = @{
+ filter = $Filter
+ role = $Role
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ Body = $body
+ Method = 'Get'
+ APIEndpoint = "/orgs/$Organization/members"
+ }
- $inputObject = @{
- Context = $Context
- Body = $body
- Method = 'Get'
- APIEndpoint = "/orgs/$Organization/members"
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1
index e8f6baec..a9c4f8ac 100644
--- a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1
+++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1
@@ -40,27 +40,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- $body = @{
- role = $Role
- invitation_source = $InvitationSource
- per_page = $PerPage
- }
+ process {
+ try {
+ $body = @{
+ role = $Role
+ invitation_source = $InvitationSource
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ Body = $body
+ Method = 'Get'
+ APIEndpoint = "/orgs/$Organization/invitations"
+ }
- $inputObject = @{
- Context = $Context
- Body = $body
- Method = 'Get'
- APIEndpoint = "/orgs/$Organization/invitations"
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1
index 8de6e35b..810fceef 100644
--- a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1
+++ b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1
@@ -59,33 +59,46 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
-
- $body = @{
- invitee_id = $InviteeID
- email = $Email
- role = $Role
- team_ids = $TeamIDs
- }
+ process {
+ try {
+ $body = @{
+ invitee_id = $InviteeID
+ email = $Email
+ role = $Role
+ team_ids = $TeamIDs
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
- $body | Remove-HashtableEntry -NullOrEmptyValues
+ $inputObject = @{
+ Context = $Context
+ Body = $body
+ Method = 'post'
+ APIEndpoint = "/orgs/$Organization/invitations"
+ }
- $inputObject = @{
- Context = $Context
- Body = $body
- Method = 'post'
- APIEndpoint = "/orgs/$Organization/invitations"
+ if ($PSCmdlet.ShouldProcess("$InviteeID$Email to organization $Organization", 'Invite')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("$InviteeID$Email to organization $Organization", 'Invite')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 b/src/functions/public/Organization/Remove-GitHubOrganization.ps1
index 9755e0a9..55bc153c 100644
--- a/src/functions/public/Organization/Remove-GitHubOrganization.ps1
+++ b/src/functions/public/Organization/Remove-GitHubOrganization.ps1
@@ -37,23 +37,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Organization/Set-GitHubOrganization.ps1 b/src/functions/public/Organization/Set-GitHubOrganization.ps1
index e79e4038..8849558b 100644
--- a/src/functions/public/Organization/Set-GitHubOrganization.ps1
+++ b/src/functions/public/Organization/Set-GitHubOrganization.ps1
@@ -36,6 +36,10 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSAvoidLongLines', '',
+ Justification = 'Long parameter names'
+ )]
param(
# The organization name. The name is not case sensitive.
[Parameter(
@@ -223,27 +227,70 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
- }
- Write-Debug "Organization : [$($Context.Owner)]"
-
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'organization_name'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization"
- Method = 'PATCH'
- Body = $body
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Set')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $body = @{
+ billing_email = $BillingEmail
+ company = $Company
+ email = $Email
+ twitter_username = $TwitterUsername
+ location = $Location
+ name = $Name
+ description = $Description
+ has_organization_projects = $HasOrganizationProjects
+ has_repository_projects = $HasRepositoryProjects
+ default_repository_permission = $DefaultRepositoryPermission
+ members_can_create_repositories = $MembersCanCreateRepositories ? $MembersCanCreateRepositories : $true
+ members_can_create_internal_repositories = $MembersCanCreateInternalRepositories
+ members_can_create_private_repositories = $MembersCanCreatePrivateRepositories
+ members_can_create_public_repositories = $MembersCanCreatePublicRepositories
+ members_allowed_repository_creation_type = $MembersAllowedRepositoryCreationType
+ members_can_create_pages = $MembersCanCreatePages ? $MembersCanCreatePages : $true
+ members_can_create_public_pages = $MembersCanCreatePublicPages ? $MembersCanCreatePublicPages : $true
+ members_can_create_private_pages = $MembersCanCreatePrivatePages ? $MembersCanCreatePrivatePages : $true
+ members_can_fork_private_repositories = $MembersCanForkPrivateRepositories ? $MembersCanForkPrivateRepositories : $false
+ web_commit_signoff_required = $WebCommitSignoffRequired ? $WebCommitSignoffRequired : $false
+ blog = $Blog
+ advanced_security_enabled_for_new_repositories = $AdvancedSecurityEnabledForNewRepositories ? $AdvancedSecurityEnabledForNewRepositories : $false
+ dependabot_alerts_enabled_for_new_repositories = $DependabotAlertsEnabledForNewRepositories ? $DependabotAlertsEnabledForNewRepositories : $false
+ dependabot_security_updates_enabled_for_new_repositories = $DependabotSecurityUpdatesEnabledForNewRepositories ? $DependabotSecurityUpdatesEnabledForNewRepositories : $false
+ dependency_graph_enabled_for_new_repositories = $DependencyGraphEnabledForNewRepositories ? $DependencyGraphEnabledForNewRepositories : $false
+ secret_scanning_enabled_for_new_repositories = $SecretScanningEnabledForNewRepositories ? $SecretScanningEnabledForNewRepositories : $false
+ secret_scanning_push_protection_enabled_for_new_repositories = $SecretScanningPushProtectionEnabledForNewRepositories ? $SecretScanningPushProtectionEnabledForNewRepositories : $false
+ secret_scanning_push_protection_custom_link_enabled = $SecretScanningPushProtectionCustomLinkEnabled ? $SecretScanningPushProtectionCustomLinkEnabled : $false
+ secret_scanning_push_protection_custom_link = $SecretScanningPushProtectionCustomLink
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization"
+ Method = 'PATCH'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Set')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1 b/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1
index f30c45e1..b87d0d20 100644
--- a/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1
+++ b/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1
@@ -74,27 +74,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
- }
- Write-Debug "Organization : [$($Context.Owner)]"
-
- $body = @{
- query_suite = $QuerySuite
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement"
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ query_suite = $QuerySuite
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement"
+ Method = 'POST'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("security feature [$SecurityProduct] on organization [$Organization]", 'Set')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("security feature [$SecurityProduct] on organization [$Organization]", 'Set')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1
index 19e587f6..4fbb270c 100644
--- a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1
+++ b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1
@@ -40,16 +40,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/rate_limit'
- Method = 'GET'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response.Resources
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/rate_limit'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.Resources
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1
index cb35c76d..8e0e02e7 100644
--- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1
@@ -83,72 +83,79 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- # If name is not provided, use the name of the file
- if (!$Name) {
- $Name = (Get-Item $FilePath).Name
- }
-
- # If label is not provided, use the name of the file
- if (!$Label) {
- $Label = (Get-Item $FilePath).Name
- }
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- # If content type is not provided, use the file extension
- if (!$ContentType) {
- $ContentType = switch ((Get-Item $FilePath).Extension) {
- '.zip' { 'application/zip' }
- '.tar' { 'application/x-tar' }
- '.gz' { 'application/gzip' }
- '.bz2' { 'application/x-bzip2' }
- '.xz' { 'application/x-xz' }
- '.7z' { 'application/x-7z-compressed' }
- '.rar' { 'application/vnd.rar' }
- '.tar.gz' { 'application/gzip' }
- '.tgz' { 'application/gzip' }
- '.tar.bz2' { 'application/x-bzip2' }
- '.tar.xz' { 'application/x-xz' }
- '.tar.7z' { 'application/x-7z-compressed' }
- '.tar.rar' { 'application/vnd.rar' }
- '.png' { 'image/png' }
- '.json' { 'application/json' }
- '.txt' { 'text/plain' }
- '.md' { 'text/markdown' }
- '.html' { 'text/html' }
- default { 'application/octet-stream' }
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo', 'ID', 'FilePath'
-
- $body['name'] = $Name
- $body['label'] = $Label
-
- Remove-HashtableEntry -Hashtable $body -NullOrEmptyValues
-
- $release = Get-GitHubRelease -Owner $Owner -Repo $Repo -ID $ID
- $uploadURI = $release.upload_url -replace '{\?name,label}', "?name=$($Name)&label=$($Label)"
-
- $inputObject = @{
- URI = $uploadURI
- Method = 'POST'
- ContentType = $ContentType
- UploadFilePath = $FilePath
+ process {
+ try {
+ # If name is not provided, use the name of the file
+ if (!$Name) {
+ $Name = (Get-Item $FilePath).Name
+ }
+
+ # If label is not provided, use the name of the file
+ if (!$Label) {
+ $Label = (Get-Item $FilePath).Name
+ }
+
+ # If content type is not provided, use the file extension
+ if (!$ContentType) {
+ $ContentType = switch ((Get-Item $FilePath).Extension) {
+ '.zip' { 'application/zip' }
+ '.tar' { 'application/x-tar' }
+ '.gz' { 'application/gzip' }
+ '.bz2' { 'application/x-bzip2' }
+ '.xz' { 'application/x-xz' }
+ '.7z' { 'application/x-7z-compressed' }
+ '.rar' { 'application/vnd.rar' }
+ '.tar.gz' { 'application/gzip' }
+ '.tgz' { 'application/gzip' }
+ '.tar.bz2' { 'application/x-bzip2' }
+ '.tar.xz' { 'application/x-xz' }
+ '.tar.7z' { 'application/x-7z-compressed' }
+ '.tar.rar' { 'application/vnd.rar' }
+ '.png' { 'image/png' }
+ '.json' { 'application/json' }
+ '.txt' { 'text/plain' }
+ '.md' { 'text/markdown' }
+ '.html' { 'text/html' }
+ default { 'application/octet-stream' }
+ }
+ }
+
+ $release = Get-GitHubRelease -Owner $Owner -Repo $Repo -ID $ID
+ $uploadURI = $release.upload_url -replace '{\?name,label}', "?name=$($Name)&label=$($Label)"
+
+ $inputObject = @{
+ URI = $uploadURI
+ Method = 'POST'
+ ContentType = $ContentType
+ UploadFilePath = $FilePath
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1
index 7964b0bb..d98588aa 100644
--- a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1
@@ -53,23 +53,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ process {
+ try {
+ if ($ReleaseID) {
+ Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repo $Repo -ReleaseID $ReleaseID -Context $Context
+ }
+ if ($ID) {
+ Get-GitHubReleaseAssetByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context
+ }
+ } catch {
+ throw $_
+ }
}
- Write-Debug "Repo : [$($Context.Repo)]"
- if ($ReleaseID) {
- Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repo $Repo -ReleaseID $ReleaseID -Context $Context
- }
- if ($ID) {
- Get-GitHubReleaseAssetByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context
+ end {
+ Write-Debug "[$stackPath] - End"
}
-
}
diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1
index 03e5dc6e..c0b93b9e 100644
--- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1
@@ -36,28 +36,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("Asset with ID [$ID] in [$Owner/$Repo]", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Asset with ID [$ID] in [$Owner/$Repo]", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1
index 7f061994..5c5e4a32 100644
--- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1
@@ -49,31 +49,50 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo', 'ID'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
- Method = 'PATCH'
- Body = $requestBody
+ process {
+ try {
+ $body = @{
+ name = $Name
+ label = $Label
+ state = $State
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
+ Method = 'PATCH'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repo]", 'Set')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repo]", 'Set')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1
index 05e77d8d..e6c77e67 100644
--- a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1
@@ -78,30 +78,45 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ process {
+ try {
+ switch ($PSCmdlet.ParameterSetName) {
+ 'All' {
+ Get-GitHubReleaseAll -Owner $Owner -Repo $Repo -PerPage $PerPage -Context $Context
+ }
+ 'Latest' {
+ Get-GitHubReleaseLatest -Owner $Owner -Repo $Repo -Context $Context
+ }
+ 'Tag' {
+ Get-GitHubReleaseByTagName -Owner $Owner -Repo $Repo -Tag $Tag -Context $Context
+ }
+ 'ID' {
+ Get-GitHubReleaseByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- Write-Debug "Repo : [$($Context.Repo)]"
- switch ($PSCmdlet.ParameterSetName) {
- 'All' {
- Get-GitHubReleaseAll -Owner $Owner -Repo $Repo -PerPage $PerPage -Context $Context
- }
- 'Latest' {
- Get-GitHubReleaseLatest -Owner $Owner -Repo $Repo -Context $Context
- }
- 'Tag' {
- Get-GitHubReleaseByTagName -Owner $Owner -Repo $Repo -Tag $Tag -Context $Context
- }
- 'ID' {
- Get-GitHubReleaseByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1
index adff128c..b24e8dd1 100644
--- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1
@@ -83,37 +83,56 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $requestBody = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $requestBody -RemoveNames 'Owner', 'Repo', 'GenerateReleaseNotes', 'Draft', 'Prerelease'
- $requestBody = Join-Object -AsHashtable -Main $requestBody -Overrides @{
- generate_release_notes = $GenerateReleaseNotes.IsPresent
- draft = $Draft.IsPresent
- prerelease = $Prerelease.IsPresent
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Remove-HashtableEntry -Hashtable $requestBody -NullOrEmptyValues
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases"
- Method = 'POST'
- Body = $requestBody
+ process {
+ try {
+ $requestBody = @{
+ tag_name = $TagName
+ target_commitish = $TargetCommitish
+ name = $Name
+ body = $Body
+ discussion_category_name = $DiscussionCategoryName
+ make_latest = $MakeLatest
+ generate_release_notes = $GenerateReleaseNotes
+ draft = $Draft
+ prerelease = $Prerelease
+ }
+ $requestBody | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases"
+ Method = 'POST'
+ Body = $requestBody
+ }
+
+ if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create a release')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create a release')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1
index 7645fb3d..7404cd08 100644
--- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1
+++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1
@@ -97,30 +97,50 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo'
-
- $inputObject = @{
- APIEndpoint = "/repos/$Owner/$Repo/releases/generate-notes"
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $requestBody = @{
+ tag_name = $TagName
+ target_commitish = $TargetCommitish
+ previous_tag_name = $PreviousTagName
+ configuration_file_path = $ConfigurationFilePath
+ }
+ $requestBody | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ APIEndpoint = "/repos/$Owner/$Repo/releases/generate-notes"
+ Method = 'POST'
+ Body = $requestBody
+ }
+
+ if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create release notes')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create release notes')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1
index 00b646db..4f3f739e 100644
--- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1
@@ -39,28 +39,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("Release with ID [$ID] in [$Owner/$Repo]", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Release with ID [$ID] in [$Owner/$Repo]", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1
index 29740d94..9b48fe06 100644
--- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1
@@ -80,35 +80,55 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- $requestBody = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $requestBody -RemoveNames 'Owner', 'Repo', 'Draft', 'Prerelease'
- $requestBody = Join-Object -AsHashtable -Main $requestBody -Overrides @{
- draft = if ($Draft.IsPresent) { $Draft } else { $false }
- prerelease = if ($Prerelease.IsPresent) { $Prerelease } else { $false }
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
- Method = 'PATCH'
- Body = $requestBody
+ process {
+ try {
+ $requestBody = @{
+ tag_name = $TagName
+ target_commitish = $TargetCommitish
+ name = $Name
+ body = $Body
+ discussion_category_name = $DiscussionCategoryName
+ make_latest = $MakeLatest
+ draft = $Draft
+ prerelease = $Prerelease
+ }
+ $requestBody | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
+ Method = 'PATCH'
+ Body = $requestBody
+ }
+
+ if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repo]", 'Update')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repo]", 'Update')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1
index 43e36a20..0763bccd 100644
--- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1
+++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1
@@ -49,24 +49,39 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- switch ($PSCmdlet.ParameterSetName) {
- 'ById' {
- Get-GitHubRepositoryAutolinkById -Owner $Owner -Repo $Repo -ID $AutolinkId -Context $Context
- }
- default {
- Get-GitHubRepositoryAutolinkList -Owner $Owner -Repo $Repo -Context $Context
+ process {
+ try {
+ switch ($PSCmdlet.ParameterSetName) {
+ 'ById' {
+ Get-GitHubRepositoryAutolinkById -Owner $Owner -Repo $Repo -ID $AutolinkId -Context $Context
+ }
+ default {
+ Get-GitHubRepositoryAutolinkList -Owner $Owner -Repo $Repo -Context $Context
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1
index a51ca8c8..b8c40b9b 100644
--- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1
+++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1
@@ -49,46 +49,49 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/autolinks"
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ key_prefix = $KeyPrefix
+ url_template = $UrlTemplate
+ is_alphanumeric = $IsAlphanumeric
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/autolinks"
+ Method = 'POST'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repo]", 'Create')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repo]", 'Create')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1
index 7a0f2029..ff169a8b 100644
--- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1
+++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1
@@ -40,28 +40,43 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId"
- Method = 'DELETE'
- Body = $body
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId"
+ Method = 'DELETE'
+ Body = $body
+ }
- if ($PSCmdlet.ShouldProcess("Autolink with ID [$AutolinkId] for repository [$Owner/$Repo]", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Autolink with ID [$AutolinkId] for repository [$Owner/$Repo]", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1
index cc78d297..3d931004 100644
--- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1
+++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1
@@ -36,25 +36,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/properties/values"
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/properties/values"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
index 91656093..a071b3bc 100644
--- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
+++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
@@ -35,27 +35,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Disable')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Disable')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1
index 2453db36..7cf6462f 100644
--- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1
+++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1
@@ -35,27 +35,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Disable')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Disable')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1
index 1210e40b..5064f3c8 100644
--- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1
+++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1
@@ -34,27 +34,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Disable')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Disable')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
index bf8642b3..b5b8da90 100644
--- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
+++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
@@ -35,27 +35,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting"
- Method = 'PUT'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting"
+ Method = 'PUT'
+ }
- if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Enable')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Enable')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1
index 1c4a730b..9d19d7e5 100644
--- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1
+++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1
@@ -35,27 +35,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
- Method = 'PUT'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
+ Method = 'PUT'
+ }
- if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Enable')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Enable')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1
index df3e409f..eb5f09ed 100644
--- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1
+++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1
@@ -35,27 +35,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
- Method = 'PUT'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
+ Method = 'PUT'
+ }
- if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Enable')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Enable')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1
index 3db6282b..a9244278 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1
@@ -115,7 +115,7 @@ filter Get-GitHubRepository {
[Parameter(ParameterSetName = 'ListByOrg')]
[Parameter(ParameterSetName = 'ListByUser')]
[ValidateSet('asc', 'desc')]
- [string] $Direction,
+ [string] $Direction = 'asc',
# The number of results per page (max 100).
[Parameter(ParameterSetName = 'MyRepos')]
@@ -162,87 +162,108 @@ filter Get-GitHubRepository {
}
begin {
- $Type = $PSBoundParameters['Type']
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
if ([string]::IsNullOrEmpty($Owner)) {
$Owner = $Context.Owner
}
- Write-Debug "Owner : [$($Context.Owner)]"
+ Write-Debug "Owner: [$Owner]"
if ([string]::IsNullOrEmpty($Repo)) {
$Repo = $Context.Repo
}
- Write-Debug "Repo : [$($Context.Repo)]"
+ Write-Debug "Repo: [$Repo]"
}
process {
- $params = @{
- Context = $Context
- }
- switch ($PSCmdlet.ParameterSetName) {
- 'MyRepos_Type' {
- $params += @{
- Type = $Type
- Sort = $Sort
- Direction = $Direction
- PerPage = $PerPage
- Since = $Since
- Before = $Before
+ try {
+ $Type = $PSBoundParameters['Type']
+ Write-Debug "ParamSet: [$($PSCmdlet.ParameterSetName)]"
+ switch ($PSCmdlet.ParameterSetName) {
+ 'MyRepos_Type' {
+ $params = @{
+ Context = $Context
+ Type = $Type
+ Sort = $Sort
+ Direction = $Direction
+ PerPage = $PerPage
+ Since = $Since
+ Before = $Before
+ }
+ $params | Remove-HashtableEntry -NullOrEmptyValues
+ Write-Verbose ($params | Format-List | Out-String)
+ Get-GitHubMyRepositories @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- Get-GitHubMyRepositories @params
- }
- 'MyRepos_Aff-Vis' {
- $params += @{
- Visibility = $Visibility
- Affiliation = $Affiliation
- Sort = $Sort
- Direction = $Direction
- PerPage = $PerPage
- Since = $Since
- Before = $Before
+ 'MyRepos_Aff-Vis' {
+ $params = @{
+ Context = $Context
+ Visibility = $Visibility
+ Affiliation = $Affiliation
+ Sort = $Sort
+ Direction = $Direction
+ PerPage = $PerPage
+ Since = $Since
+ Before = $Before
+ }
+ $params | Remove-HashtableEntry -NullOrEmptyValues
+ Write-Verbose ($params | Format-List | Out-String)
+ Get-GitHubMyRepositories @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- Get-GitHubMyRepositories @params
- }
- 'ByName' {
- $params += @{
- Owner = $Owner
- Repo = $Repo
+ 'ByName' {
+ $params = @{
+ Context = $Context
+ Owner = $Owner
+ Repo = $Repo
+ }
+ $params | Remove-HashtableEntry -NullOrEmptyValues
+ Write-Verbose ($params | Format-List | Out-String)
+ Get-GitHubRepositoryByName @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- Get-GitHubRepositoryByName @params
- }
- 'ListByID' {
- $params += @{
- Since = $SinceID
+ 'ListByID' {
+ $params = @{
+ Context = $Context
+ Since = $SinceID
+ }
+ $params | Remove-HashtableEntry -NullOrEmptyValues
+ Write-Verbose ($params | Format-List | Out-String)
+ Get-GitHubRepositoryListByID @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- Get-GitHubRepositoryListByID @params
- }
- 'ListByOrg' {
- $params += @{
- Owner = $Owner
- Type = $Type
- Sort = $Sort
- Direction = $Direction
- PerPage = $PerPage
+ 'ListByOrg' {
+ $params = @{
+ Context = $Context
+ Owner = $Owner
+ Type = $Type
+ Sort = $Sort
+ Direction = $Direction
+ PerPage = $PerPage
+ }
+ $params | Remove-HashtableEntry -NullOrEmptyValues
+ Write-Verbose ($params | Format-List | Out-String)
+ Get-GitHubRepositoryListByOrg @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- Get-GitHubRepositoryListByOrg @params
- }
- 'ListByUser' {
- $params += @{
- Username = $Username
- Type = $Type
- Sort = $Sort
- Direction = $Direction
- PerPage = $PerPage
+ 'ListByUser' {
+ $params = @{
+ Context = $Context
+ Username = $Username
+ Type = $Type
+ Sort = $Sort
+ Direction = $Direction
+ PerPage = $PerPage
+ }
+ $params | Remove-HashtableEntry -NullOrEmptyValues
+ Write-Verbose ($params | Format-List | Out-String)
+ Get-GitHubRepositoryListByUser @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- Get-GitHubRepositoryListByUser @params
}
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1
index 5acc9b83..a540209f 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1
@@ -109,44 +109,53 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/activity"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ direction = $Direction
+ per_page = $PerPage
+ before = $Before
+ after = $After
+ ref = $Ref
+ actor = $Actor
+ time_period = $TimePeriod
+ activity_type = $ActivityType
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/activity"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1
index f045a2dd..32c70da1 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1
@@ -41,44 +41,46 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ ref = $Ref
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1
index add2f3ad..ce84b00c 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1
@@ -46,29 +46,47 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/contributors"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ anon = $Anon
+ per_page = $PerPage
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/contributors"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1
index 10d39aea..d2bf7914 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1
@@ -42,44 +42,47 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/forks"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ sort = $Sort
+ per_page = $PerPage
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/forks"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1
index 7acd6c3b..82a6c7fa 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1
@@ -34,25 +34,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/languages"
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/languages"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1
index f8b09697..ae1b1c0f 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1
@@ -36,25 +36,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1
index b8a08263..bf10c8c0 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1
@@ -38,30 +38,45 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = @{
- per_page = $PerPage
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/tags"
+ Method = 'GET'
+ Body = $body
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/tags"
- Method = 'GET'
- Body = $body
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1
index 0f8a9083..4e13bcce 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1
@@ -46,30 +46,45 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $body = @{
- per_page = $PerPage
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/teams"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/teams"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1
index 81caa1d5..ee17bf3b 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1
@@ -34,30 +34,45 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = @{
- per_page = $PerPage
- }
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/topics"
+ Method = 'GET'
+ Body = $body
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/topics"
- Method = 'GET'
- Body = $body
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.names
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response.names
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1
index dd97b240..a5031374 100644
--- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1
@@ -52,44 +52,48 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/transfer"
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ new_owner = $NewOwner
+ new_name = $NewName
+ team_ids = $TeamIds
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/transfer"
+ Method = 'POST'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1
index 24f3f456..22321f99 100644
--- a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1
@@ -328,93 +328,103 @@ filter New-GitHubRepository {
}
begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
if ([string]::IsNullOrEmpty($Owner)) {
$Owner = $Context.Owner
}
- Write-Debug "Owner : [$($Context.Owner)]"
-
- $GitignoreTemplate = $PSBoundParameters['GitignoreTemplate']
- $LicenseTemplate = $PSBoundParameters['LicenseTemplate']
+ Write-Debug "Owner: [$Owner]"
}
process {
- if ($PSCmdlet.ParameterSetName -in 'user', 'org') {
- $params = @{
- Context = $Context
- Owner = $Owner
- Name = $Name
- Description = $Description
- Homepage = $Homepage
- Visibility = $Visibility
- HasIssues = $HasIssues
- HasProjects = $HasProjects
- HasWiki = $HasWiki
- HasDiscussions = $HasDiscussions
- HasDownloads = $HasDownloads
- IsTemplate = $IsTemplate
- TeamId = $TeamId
- AutoInit = $AutoInit
- AllowSquashMerge = $AllowSquashMerge
- AllowMergeCommit = $AllowMergeCommit
- AllowRebaseMerge = $AllowRebaseMerge
- AllowAutoMerge = $AllowAutoMerge
- DeleteBranchOnMerge = $DeleteBranchOnMerge
- SquashMergeCommitTitle = $SquashMergeCommitTitle
- SquashMergeCommitMessage = $SquashMergeCommitMessage
- MergeCommitTitle = $MergeCommitTitle
- MergeCommitMessage = $MergeCommitMessage
- GitignoreTemplate = $GitignoreTemplate
- LicenseTemplate = $LicenseTemplate
- }
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- }
-
- switch ($PSCmdlet.ParameterSetName) {
- 'user' {
- if ($PSCmdlet.ShouldProcess("repository for user [$Name]", 'Create')) {
- New-GitHubRepositoryUser @params
+ try {
+ $GitignoreTemplate = $PSBoundParameters['GitignoreTemplate']
+ $LicenseTemplate = $PSBoundParameters['LicenseTemplate']
+ if ($PSCmdlet.ParameterSetName -in 'user', 'org') {
+ $params = @{
+ Context = $Context
+ Owner = $Owner
+ Name = $Name
+ Description = $Description
+ Homepage = $Homepage
+ Visibility = $Visibility
+ HasIssues = $HasIssues
+ HasProjects = $HasProjects
+ HasWiki = $HasWiki
+ HasDiscussions = $HasDiscussions
+ HasDownloads = $HasDownloads
+ IsTemplate = $IsTemplate
+ TeamId = $TeamId
+ AutoInit = $AutoInit
+ AllowSquashMerge = $AllowSquashMerge
+ AllowMergeCommit = $AllowMergeCommit
+ AllowRebaseMerge = $AllowRebaseMerge
+ AllowAutoMerge = $AllowAutoMerge
+ DeleteBranchOnMerge = $DeleteBranchOnMerge
+ SquashMergeCommitTitle = $SquashMergeCommitTitle
+ SquashMergeCommitMessage = $SquashMergeCommitMessage
+ MergeCommitTitle = $MergeCommitTitle
+ MergeCommitMessage = $MergeCommitMessage
+ GitignoreTemplate = $GitignoreTemplate
+ LicenseTemplate = $LicenseTemplate
}
+ Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
}
- 'org' {
- if ($PSCmdlet.ShouldProcess("repository for organization [$Owner/$Name]", 'Create')) {
- New-GitHubRepositoryOrg @params
+
+ switch ($PSCmdlet.ParameterSetName) {
+ 'user' {
+ if ($PSCmdlet.ShouldProcess("repository for user [$Name]", 'Create')) {
+ New-GitHubRepositoryUser @params
+ }
}
- }
- 'template' {
- if ($PSCmdlet.ShouldProcess("repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) {
- $params = @{
- Context = $Context
- TemplateOwner = $TemplateOwner
- TemplateRepo = $TemplateRepo
- Owner = $Owner
- Name = $Name
- IncludeAllBranches = $IncludeAllBranches
- Description = $Description
- Private = $Visibility -eq 'private'
+ 'org' {
+ if ($PSCmdlet.ShouldProcess("repository for organization [$Owner/$Name]", 'Create')) {
+ New-GitHubRepositoryOrg @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- New-GitHubRepositoryFromTemplate @params
}
- }
- 'fork' {
- if ([string]::IsNullorEmpty($Name)) {
- $Name = $ForkRepo
+ 'template' {
+ if ($PSCmdlet.ShouldProcess("repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) {
+ $params = @{
+ Context = $Context
+ TemplateOwner = $TemplateOwner
+ TemplateRepo = $TemplateRepo
+ Owner = $Owner
+ Name = $Name
+ IncludeAllBranches = $IncludeAllBranches
+ Description = $Description
+ Private = $Visibility -eq 'private'
+ }
+ Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
+ New-GitHubRepositoryFromTemplate @params
+ }
}
- if ($PSCmdlet.ShouldProcess("repository [$Owner/$Name] as fork from [$ForkOwner/$ForkRepo]", 'Create')) {
- $params = @{
- Context = $Context
- Owner = $ForkOwner
- Repo = $ForkRepo
- Organization = $Owner
- Name = $Name
- DefaultBranchOnly = $DefaultBranchOnly
+ 'fork' {
+ if ([string]::IsNullorEmpty($Name)) {
+ $Name = $ForkRepo
+ }
+ if ($PSCmdlet.ShouldProcess("repository [$Owner/$Name] as fork from [$ForkOwner/$ForkRepo]", 'Create')) {
+ $params = @{
+ Context = $Context
+ Owner = $ForkOwner
+ Repo = $ForkRepo
+ Organization = $Owner
+ Name = $Name
+ DefaultBranchOnly = $DefaultBranchOnly
+ }
+ Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
+ New-GitHubRepositoryAsFork @params
}
- Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
- New-GitHubRepositoryAsFork @params
}
}
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1
index 1ebe1907..c04cf4f9 100644
--- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1
@@ -36,27 +36,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repo]", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repo]", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1
index 5142ee5a..ef4b0a14 100644
--- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1
+++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1
@@ -36,32 +36,47 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = @{
- names = $Names | ForEach-Object { $_.ToLower() }
- }
+ process {
+ try {
+ $body = @{
+ names = $Names | ForEach-Object { $_.ToLower() }
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/topics"
- Method = 'PUT'
- Body = $body
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/topics"
+ Method = 'PUT'
+ Body = $body
+ }
- if ($PSCmdlet.ShouldProcess("topics for repo [$Owner/$Repo]", 'Set')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response.names
+ if ($PSCmdlet.ShouldProcess("topics for repo [$Owner/$Repo]", 'Set')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response.names
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1
index 8775d742..e16d39a1 100644
--- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1
+++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1
@@ -69,44 +69,47 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
+ process {
+ try {
+ $body = @{
+ event_type = $EventType
+ client_payload = $ClientPayload
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/dispatches"
- Method = 'POST'
- Body = $body
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/dispatches"
+ Method = 'POST'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1
index f66d8fcf..9a2af0ec 100644
--- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1
+++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1
@@ -36,31 +36,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
- Method = 'GET'
- }
+ process {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
+ Method = 'GET'
+ }
- try {
- (Invoke-GitHubAPI @inputObject).StatusCode -eq 204
- } catch {
- if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
- return $false
- } else {
- throw $_
+ try {
+ (Invoke-GitHubAPI @inputObject).StatusCode -eq 204
+ } catch {
+ if ($_.Exception.Response.StatusCode.Value__ -eq 404) {
+ return $false
+ } else {
+ throw $_
+ }
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1
index 63e47c39..e50193f9 100644
--- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1
@@ -177,72 +177,79 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Owner : [$($Context.Owner)]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $body = @{
- name = $Name
- description = $Description
- homepage = $Homepage
- visibility = $Visibility
- private = $Visibility -eq 'private'
- default_branch = $DefaultBranch
- squash_merge_commit_title = $SquashMergeCommitTitle
- squash_merge_commit_message = $SquashMergeCommitMessage
- merge_commit_title = $MergeCommitTitle
- merge_commit_message = $MergeCommitMessage
-
- advanced_security = if ($EnableAdvancedSecurity.IsPresent) {
- @{
- status = if ($EnableAdvancedSecurity) { 'enabled' } else { 'disabled' }
- }
- } else { $null }
- secret_scanning = if ($EnableSecretScanning.IsPresent) {
- @{
- status = if ($EnableSecretScanning) { 'enabled' } else { 'disabled' }
- }
- } else { $null }
- secret_scanning_push_protection = if ($EnableSecretScanningPushProtection.IsPresent) {
- @{
- status = if ($EnableSecretScanningPushProtection) { 'enabled' } else { 'disabled' }
+ process {
+ try {
+ $body = @{
+ name = $Name
+ description = $Description
+ homepage = $Homepage
+ visibility = $Visibility
+ private = $Visibility -eq 'private'
+ default_branch = $DefaultBranch
+ squash_merge_commit_title = $SquashMergeCommitTitle
+ squash_merge_commit_message = $SquashMergeCommitMessage
+ merge_commit_title = $MergeCommitTitle
+ merge_commit_message = $MergeCommitMessage
+ advanced_security = $EnableAdvancedSecurity ? @{
+ status = $EnableAdvancedSecurity ? 'enabled' : 'disabled'
+ } : $null
+ secret_scanning = $EnableSecretScanning ? @{
+ status = $EnableSecretScanning ? 'enabled' : 'disabled'
+ } : $null
+ secret_scanning_push_protection = $EnableSecretScanningPushProtection ? @{
+ status = $EnableSecretScanningPushProtection ? 'enabled' : 'disabled'
+ } : $null
+ has_issues = $HasIssues ? $HasIssues : $null
+ has_projects = $HasProjects ? $HasProjects : $null
+ has_wiki = $HasWiki ? $HasWiki : $null
+ is_template = $IsTemplate ? $IsTemplate : $null
+ allow_squash_merge = $AllowSquashMerge ? $AllowSquashMerge : $null
+ allow_merge_commit = $AllowMergeCommit ? $AllowMergeCommit : $null
+ allow_rebase_merge = $AllowRebaseMerge ? $AllowRebaseMerge : $null
+ allow_auto_merge = $AllowAutoMerge ? $AllowAutoMerge : $null
+ allow_update_branch = $AllowUpdateMerge ? $AllowUpdateMerge : $null
+ delete_branch_on_merge = $DeleteBranchOnMerge ? $DeleteBranchOnMerge : $null
+ archived = $Archived ? $Archived : $null
+ allow_forking = $AllowForking ? $AllowForking : $null
+ web_commit_signoff_required = $WebCommitSignoffRequired ? $WebCommitSignoffRequired : $null
}
- } else { $null }
- has_issues = if ($HasIssues.IsPresent) { $HasIssues } else { $null }
- has_projects = if ($HasProjects.IsPresent) { $HasProjects } else { $null }
- has_wiki = if ($HasWiki.IsPresent) { $HasWiki } else { $null }
- is_template = if ($IsTemplate.IsPresent) { $IsTemplate } else { $null }
- allow_squash_merge = if ($AllowSquashMerge.IsPresent) { $AllowSquashMerge } else { $null }
- allow_merge_commit = if ($AllowMergeCommit.IsPresent) { $AllowMergeCommit } else { $null }
- allow_rebase_merge = if ($AllowRebaseMerge.IsPresent) { $AllowRebaseMerge } else { $null }
- allow_auto_merge = if ($AllowAutoMerge.IsPresent) { $AllowAutoMerge } else { $null }
- allow_update_branch = if ($AllowUpdateMerge.IsPresent) { $AllowUpdateMerge } else { $null }
- delete_branch_on_merge = if ($DeleteBranchOnMerge.IsPresent) { $DeleteBranchOnMerge } else { $null }
- archived = if ($Archived.IsPresent) { $Archived } else { $null }
- allow_forking = if ($AllowForking.IsPresent) { $AllowForking } else { $null }
- web_commit_signoff_required = if ($WebCommitSignoffRequired.IsPresent) { $WebCommitSignoffRequired } else { $null }
- }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
- Remove-HashtableEntry -Hashtable $body -NullOrEmptyValues
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo"
+ Method = 'PATCH'
+ Body = $body
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo"
- Method = 'PATCH'
- Body = $body
+ if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repo]", 'Update')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repo]", 'Update')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1
index 6222f9ae..5964f324 100644
--- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1
+++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1
@@ -82,40 +82,55 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
-
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- $params = @{
- Context = $Context
- Owner = $Owner
- Repo = $Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- switch ($PSCmdlet.ParameterSetName) {
- 'Default' {
- $params += @{
- Ref = $Ref
- TimePeriod = $TimePeriod
- ActorName = $ActorName
- RuleSuiteResult = $RuleSuiteResult
- PerPage = $PerPage
+ process {
+ try {
+ $params = @{
+ Context = $Context
+ Owner = $Owner
+ Repo = $Repo
}
- Get-GitHubRepositoryRuleSuiteList @params
- }
- 'ById' {
- $params += @{
- RuleSuiteId = $RuleSuiteId
+
+ switch ($PSCmdlet.ParameterSetName) {
+ 'Default' {
+ $params += @{
+ Ref = $Ref
+ TimePeriod = $TimePeriod
+ ActorName = $ActorName
+ RuleSuiteResult = $RuleSuiteResult
+ PerPage = $PerPage
+ }
+ Get-GitHubRepositoryRuleSuiteList @params
+ }
+ 'ById' {
+ $params += @{
+ RuleSuiteId = $RuleSuiteId
+ }
+ Get-GitHubRepositoryRuleSuiteById @params
+ }
}
- Get-GitHubRepositoryRuleSuiteById @params
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1
index b1a64cca..548c94ef 100644
--- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1
+++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1
@@ -38,25 +38,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId"
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1
index 70f28673..29c6cf3a 100644
--- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1
+++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1
@@ -69,44 +69,50 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
}
+ Write-Debug "Repo: [$Repo]"
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ ref = $Ref
+ time_period = $TimePeriod
+ actor_name = $ActorName
+ rule_suite_result = $RuleSuiteResult
+ per_page = $PerPage
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1
index 839820d5..29c5ef88 100644
--- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1
+++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1
@@ -35,25 +35,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/tags/protection"
- Method = 'GET'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/tags/protection"
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1
index 4428b7ee..ab3a1fce 100644
--- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1
+++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1
@@ -37,32 +37,47 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $body = @{
- pattern = $Pattern
- }
+ process {
+ try {
+ $body = @{
+ pattern = $Pattern
+ }
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/tags/protection"
- Method = 'POST'
- Body = $body
- }
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/tags/protection"
+ Method = 'POST'
+ Body = $body
+ }
- if ($PSCmdlet.ShouldProcess("tag protection state on pattern [$Pattern] for repository [$Owner/$Repo]", 'Create')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("tag protection state on pattern [$Pattern] for repository [$Owner/$Repo]", 'Create')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1
index db1e9a30..94bb00ec 100644
--- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1
+++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1
@@ -38,27 +38,42 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId"
- Method = 'DELETE'
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId"
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repo]", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repo]", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1 b/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1
index 76f7b1cd..0afc4e02 100644
--- a/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1
+++ b/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1
@@ -49,23 +49,38 @@
[string] $Stamp = 'public'
)
- $baseURL = $script:StatusBaseURL[$Stamp]
-
- if ($Active) {
- $APIURI = "$baseURL/api/v2/scheduled-maintenances/active.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response.scheduled_maintenances
- return
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
}
- if ($Upcoming) {
- $APIURI = "$baseURL/api/v2/scheduled-maintenances/upcoming.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response.scheduled_maintenances
- return
+ process {
+ try {
+ $baseURL = $script:StatusBaseURL[$Stamp]
+
+ if ($Active) {
+ $APIURI = "$baseURL/api/v2/scheduled-maintenances/active.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response.scheduled_maintenances
+ return
+ }
+
+ if ($Upcoming) {
+ $APIURI = "$baseURL/api/v2/scheduled-maintenances/upcoming.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response.scheduled_maintenances
+ return
+ }
+
+ $APIURI = "$baseURL/api/v2/scheduled-maintenances.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response.scheduled_maintenances
+ } catch {
+ throw $_
+ }
}
- $APIURI = "$baseURL/api/v2/scheduled-maintenances.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response.scheduled_maintenances
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Status/Get-GitHubStatus.ps1 b/src/functions/public/Status/Get-GitHubStatus.ps1
index 0100d0dc..f8ccb465 100644
--- a/src/functions/public/Status/Get-GitHubStatus.ps1
+++ b/src/functions/public/Status/Get-GitHubStatus.ps1
@@ -38,17 +38,31 @@
[ValidateSet('public', 'eu')]
[string] $Stamp = 'public'
)
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ $baseURL = $script:StatusBaseURL[$Stamp]
- $baseURL = $script:StatusBaseURL[$Stamp]
+ if ($Summary) {
+ $APIURI = "$baseURL/api/v2/summary.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response
+ return
+ }
- if ($Summary) {
- $APIURI = "$baseURL/api/v2/summary.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response
- return
+ $APIURI = "$baseURL/api/v2/status.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response.status
+ } catch {
+ throw $_
+ }
}
- $APIURI = "$baseURL/api/v2/status.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response.status
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Status/Get-GitHubStatusComponent.ps1 b/src/functions/public/Status/Get-GitHubStatusComponent.ps1
index 157efd02..a8a69974 100644
--- a/src/functions/public/Status/Get-GitHubStatusComponent.ps1
+++ b/src/functions/public/Status/Get-GitHubStatusComponent.ps1
@@ -25,9 +25,24 @@
[string] $Stamp = 'public'
)
- $baseURL = $script:StatusBaseURL[$Stamp]
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
- $APIURI = "$baseURL/api/v2/components.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response.components
+ process {
+ try {
+ $baseURL = $script:StatusBaseURL[$Stamp]
+
+ $APIURI = "$baseURL/api/v2/components.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response.components
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Status/Get-GitHubStatusIncident.ps1 b/src/functions/public/Status/Get-GitHubStatusIncident.ps1
index c8842822..8710340b 100644
--- a/src/functions/public/Status/Get-GitHubStatusIncident.ps1
+++ b/src/functions/public/Status/Get-GitHubStatusIncident.ps1
@@ -38,16 +38,31 @@
[string] $Stamp = 'public'
)
- $baseURL = $script:StatusBaseURL[$Stamp]
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ }
+
+ process {
+ try {
+ $baseURL = $script:StatusBaseURL[$Stamp]
- if ($Unresolved) {
- $APIURI = "$baseURL/api/v2/incidents/unresolved.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response.incidents
- return
+ if ($Unresolved) {
+ $APIURI = "$baseURL/api/v2/incidents/unresolved.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response.incidents
+ return
+ }
+
+ $APIURI = "$baseURL/api/v2/incidents.json"
+ $response = Invoke-RestMethod -Uri $APIURI -Method Get
+ $response.incidents
+ } catch {
+ throw $_
+ }
}
- $APIURI = "$baseURL/api/v2/incidents.json"
- $response = Invoke-RestMethod -Uri $APIURI -Method Get
- $response.incidents
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/public/Teams/Get-GitHubRepoTeam.ps1
index d2fc4fb9..2db1a32c 100644
--- a/src/functions/public/Teams/Get-GitHubRepoTeam.ps1
+++ b/src/functions/public/Teams/Get-GitHubRepoTeam.ps1
@@ -17,25 +17,40 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner: [$Owner]"
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo: [$Repo]"
}
- Write-Debug "Repo : [$($Context.Repo)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/repos/$Owner/$Repo/teams"
- Method = 'Get'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/repos/$Owner/$Repo/teams"
+ Method = 'Get'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Teams/Get-GitHubTeamByName.ps1 b/src/functions/public/Teams/Get-GitHubTeamByName.ps1
index 1d235406..9c023176 100644
--- a/src/functions/public/Teams/Get-GitHubTeamByName.ps1
+++ b/src/functions/public/Teams/Get-GitHubTeamByName.ps1
@@ -32,20 +32,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/teams/$Name"
- Method = 'Get'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/teams/$Name"
+ Method = 'Get'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1
index f2f4d491..fb8cf4ec 100644
--- a/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1
+++ b/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1
@@ -26,20 +26,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/teams"
- Method = 'Get'
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/teams"
+ Method = 'Get'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1
index f91c0778..858de9a7 100644
--- a/src/functions/public/Teams/New-GitHubTeam.ps1
+++ b/src/functions/public/Teams/New-GitHubTeam.ps1
@@ -85,35 +85,50 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
- }
- Write-Debug "Organization : [$($Context.Owner)]"
-
- $body = @{
- name = $Name
- description = $Description
- maintainers = $Maintainers
- repo_names = $RepoNames
- privacy = $Privacy
- notification_setting = $NotificationSetting
- permission = $Permission
- parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- $body | Remove-HashtableEntry -NullOrEmptyValues
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/teams"
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ name = $Name
+ description = $Description
+ maintainers = $Maintainers
+ repo_names = $RepoNames
+ privacy = $Privacy
+ notification_setting = $NotificationSetting
+ permission = $Permission
+ parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/teams"
+ Method = 'POST'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("'$Name' in '$Organization'", 'Create team')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("'$Name' in '$Organization'", 'Create team')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1
index 81a5cc49..ac836f9b 100644
--- a/src/functions/public/Teams/Remove-GitHubTeam.ps1
+++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1
@@ -32,22 +32,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- $inputObject = @{
- Context = $Context
- Method = 'Delete'
- APIEndpoint = "/orgs/$Organization/teams/$Name"
- }
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ Method = 'Delete'
+ APIEndpoint = "/orgs/$Organization/teams/$Name"
+ }
- if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Delete')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Delete')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1
index ba3a02ae..c87d1e8f 100644
--- a/src/functions/public/Teams/Update-GitHubTeam.ps1
+++ b/src/functions/public/Teams/Update-GitHubTeam.ps1
@@ -79,33 +79,48 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
- }
- Write-Debug "Organization : [$($Context.Owner)]"
-
- $body = @{
- name = $NewName
- description = $Description
- privacy = $Privacy
- notification_setting = $NotificationSetting
- permission = $Permission
- parent_team_id = $ParentTeamID
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- $body | Remove-HashtableEntry -NullOrEmptyValues
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$Organization/teams/$Name"
- Method = 'Patch'
- Body = $body
+ process {
+ try {
+ $body = @{
+ name = $NewName
+ description = $Description
+ privacy = $Privacy
+ notification_setting = $NotificationSetting
+ permission = $Permission
+ parent_team_id = $ParentTeamID
+ }
+ $body | Remove-HashtableEntry -NullOrEmptyValues
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$Organization/teams/$Name"
+ Method = 'Patch'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Update')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Update')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1
index 890f97f3..8a5eb845 100644
--- a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1
+++ b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1
@@ -24,21 +24,22 @@
[Block a user from an organization](https://docs.github.com/rest/orgs/blocking#block-a-user-from-an-organization)
#>
[OutputType([bool])]
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')]
param(
# The handle for the GitHub user account.
[Parameter(
- Mandatory,
- ValueFromPipeline,
- ValueFromPipelineByPropertyName
+ Mandatory
)]
[Alias('login')]
[string] $Username,
# The organization name. The name is not case sensitive.
[Parameter(
- ValueFromPipeline,
- ValueFromPipelineByPropertyName
+ Mandatory,
+ ParameterSetName = 'Organization'
+ )]
+ [Parameter(
+ ParameterSetName = '__AllParameterSets'
)]
[Alias('org')]
[Alias('owner')]
@@ -50,16 +51,29 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ process {
+ try {
+ switch ($PSCmdlet.ParameterSetName) {
+ 'Organization' {
+ Block-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context
+ }
+ '__AllParameterSets' {
+ Block-GitHubUserByUser -Username $Username -Context $Context
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- Write-Debug "Organization : [$($Context.Owner)]"
- if ($Organization) {
- Block-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context
- } else {
- Block-GitHubUserByUser -Username $Username -Context $Context
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1
index d9bb7698..b375ab44 100644
--- a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1
+++ b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1
@@ -44,17 +44,31 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- if ($Organization) {
- Get-GitHubBlockedUserByOrganization -Organization $Organization -PerPage $PerPage -Context $Context
- } else {
- Get-GitHubBlockedUserByUser -PerPage $PerPage -Context $Context
+ process {
+ try {
+ if ($Organization) {
+ Get-GitHubBlockedUserByOrganization -Organization $Organization -PerPage $PerPage -Context $Context
+ } else {
+ Get-GitHubBlockedUserByUser -PerPage $PerPage -Context $Context
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1
index 466f2d02..cf829991 100644
--- a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1
+++ b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1
@@ -56,16 +56,31 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- if ($Organization) {
- Test-GitHubBlockedUserByOrganization -Organization $Organization -Username $Username -PerPage $PerPage -Context $Context
- } else {
- Test-GitHubBlockedUserByUser -Username $Username -PerPage $PerPage -Context $Context
+ process {
+ try {
+ if ($Organization) {
+ Test-GitHubBlockedUserByOrganization -Organization $Organization -Username $Username -PerPage $PerPage -Context $Context
+ } else {
+ Test-GitHubBlockedUserByUser -Username $Username -PerPage $PerPage -Context $Context
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1
index b25ffa90..38b54124 100644
--- a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1
+++ b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1
@@ -49,16 +49,31 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
- if ([string]::IsNullOrEmpty($Owner)) {
- $Organization = $Context.Owner
+ if ([string]::IsNullOrEmpty($Organization)) {
+ $Organization = $Context.Owner
+ }
+ Write-Debug "Organization: [$Organization]"
}
- Write-Debug "Organization : [$($Context.Owner)]"
- if ($Organization) {
- Unblock-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context
- } else {
- Unblock-GitHubUserByUser -Username $Username -Context $Context
+ process {
+ try {
+ if ($Organization) {
+ Unblock-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context
+ } else {
+ Unblock-GitHubUserByUser -Username $Username -Context $Context
+ }
+ } catch {
+ throw $_
+ }
+ }
+
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1
index 6391b20a..04609a71 100644
--- a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1
+++ b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1
@@ -35,21 +35,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- emails = $Emails
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/emails'
- Method = 'POST'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ emails = $Emails
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/emails'
+ Method = 'POST'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1
index 4d80654e..fa10cebc 100644
--- a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1
+++ b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1
@@ -41,11 +41,26 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
+
+ process {
+ try {
+ if ($Public) {
+ Get-GitHubUserPublicEmail -PerPage $PerPage -Context $Context
+ } else {
+ Get-GitHubUserAllEmail -PerPage $PerPage -Context $Context
+ }
+ } catch {
+ throw $_
+ }
+ }
- if ($Public) {
- Get-GitHubUserPublicEmail -PerPage $PerPage -Context $Context
- } else {
- Get-GitHubUserAllEmail -PerPage $PerPage -Context $Context
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1
index 2f9f2a2f..c0884175 100644
--- a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1
+++ b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1
@@ -33,23 +33,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- emails = $Emails
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/emails'
- Method = 'DELETE'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ emails = $Emails
+ }
- if ($PSCmdlet.ShouldProcess("Email addresses [$($Emails -join ', ')]", 'Delete')) {
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/emails'
+ Method = 'DELETE'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("Email addresses [$($Emails -join ', ')]", 'Delete')) {
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1 b/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1
index 9c807806..24a61cc4 100644
--- a/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1
+++ b/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1
@@ -39,23 +39,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- visibility = $Visibility
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/email/visibility'
- Method = 'PATCH'
- Body = $body
- }
+ process {
+ try {
+ $body = @{
+ visibility = $Visibility
+ }
- if ($PSCmdlet.ShouldProcess("Email visibility [$Visibility]", 'Set')) {
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/email/visibility'
+ Method = 'PATCH'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess("Email visibility [$Visibility]", 'Set')) {
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1
index dc92f030..af172ed2 100644
--- a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1
@@ -35,16 +35,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/following/$Username"
- Method = 'PUT'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/following/$Username"
+ Method = 'PUT'
+ }
+
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1
index fd880a30..eb2be94b 100644
--- a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1
+++ b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1
@@ -42,11 +42,26 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
+
+ process {
+ try {
+ if ($Username) {
+ Get-GitHubUserFollowersOfUser -Username $Username -PerPage $PerPage -Context $Context
+ } else {
+ Get-GitHubUserMyFollowers -PerPage $PerPage -Context $Context
+ }
+ } catch {
+ throw $_
+ }
+ }
- if ($Username) {
- Get-GitHubUserFollowersOfUser -Username $Username -PerPage $PerPage -Context $Context
- } else {
- Get-GitHubUserMyFollowers -PerPage $PerPage -Context $Context
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1
index 9a60fc64..ba26966f 100644
--- a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1
@@ -43,11 +43,26 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
+
+ process {
+ try {
+ if ($Username) {
+ Get-GitHubUserFollowingUser -Username $Username -PerPage $PerPage -Context $Context
+ } else {
+ Get-GitHubUserFollowingMe -PerPage $PerPage -Context $Context
+ }
+ } catch {
+ throw $_
+ }
+ }
- if ($Username) {
- Get-GitHubUserFollowingUser -Username $Username -PerPage $PerPage -Context $Context
- } else {
- Get-GitHubUserFollowingMe -PerPage $PerPage -Context $Context
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1
index 45197b69..da2bd615 100644
--- a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1
@@ -32,17 +32,32 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/following/$Username"
- Method = 'DELETE'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- if ($PSCmdlet.ShouldProcess("User [$Username]", 'Unfollow')) {
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/following/$Username"
+ Method = 'DELETE'
+ }
+
+ if ($PSCmdlet.ShouldProcess("User [$Username]", 'Unfollow')) {
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1
index 0bc1ff3d..062ada39 100644
--- a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1
@@ -49,11 +49,26 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
+
+ process {
+ try {
+ if ($Username) {
+ Test-GitHubUserFollowedByUser -Username $Username -Follows $Follows -Context $Context
+ } else {
+ Test-GitHubUserFollowedByMe -Username $Follows -Context $Context
+ }
+ } catch {
+ throw $_
+ }
+ }
- if ($Username) {
- Test-GitHubUserFollowedByUser -Username $Username -Follows $Follows -Context $Context
- } else {
- Test-GitHubUserFollowedByMe -Username $Follows -Context $Context
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1
index 9789b5ed..a24cb9b5 100644
--- a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1
+++ b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1
@@ -48,21 +48,36 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- name = $Name
- armored_public_key = $ArmoredPublicKey
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/gpg_keys'
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ name = $Name
+ armored_public_key = $ArmoredPublicKey
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/gpg_keys'
+ Method = 'POST'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1
index 039e82d3..415e7714 100644
--- a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1
+++ b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1
@@ -55,15 +55,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
- if ($Username) {
- Get-GitHubUserGpgKeyForUser -Username $Username -PerPage $PerPage -Context $Context
- } else {
- if ($ID) {
- Get-GitHubUserMyGpgKeyById -ID $ID -Context $Context
- } else {
- Get-GitHubUserMyGpgKey -PerPage $PerPage -Context $Context
+ process {
+ try {
+ if ($Username) {
+ Get-GitHubUserGpgKeyForUser -Username $Username -PerPage $PerPage -Context $Context
+ } else {
+ if ($ID) {
+ Get-GitHubUserMyGpgKeyById -ID $ID -Context $Context
+ } else {
+ Get-GitHubUserMyGpgKey -PerPage $PerPage -Context $Context
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1
index 6f70e07b..1f6e7d51 100644
--- a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1
+++ b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1
@@ -33,17 +33,32 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/gpg_keys/$ID"
- Method = 'DELETE'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) {
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/gpg_keys/$ID"
+ Method = 'DELETE'
+ }
+
+ if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) {
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Get-GitHubUser.ps1 b/src/functions/public/Users/Get-GitHubUser.ps1
index 94115fcd..e72406f4 100644
--- a/src/functions/public/Users/Get-GitHubUser.ps1
+++ b/src/functions/public/Users/Get-GitHubUser.ps1
@@ -64,23 +64,38 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
- switch ($PSCmdlet.ParameterSetName) {
- '__DefaultSet' {
- $user = Get-GitHubMyUser -Context $Context
- $social_accounts = Get-GitHubMyUserSocials -Context $Context
- $user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force
- $user
- }
- 'NamedUser' {
- $user = Get-GitHubUserByName -Username $Username -Context $Context
- $social_accounts = Get-GitHubUserSocialsByName -Username $Username -Context $Context
- $user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force
- $user
- }
- 'AllUsers' {
- Get-GitHubAllUsers -Since $Since -PerPage $PerPage -Context $Context
+ process {
+ try {
+ switch ($PSCmdlet.ParameterSetName) {
+ '__DefaultSet' {
+ $user = Get-GitHubMyUser -Context $Context
+ $social_accounts = Get-GitHubMyUserSocials -Context $Context
+ $user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force
+ $user
+ }
+ 'NamedUser' {
+ $user = Get-GitHubUserByName -Username $Username -Context $Context
+ $social_accounts = Get-GitHubUserSocialsByName -Username $Username -Context $Context
+ $user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force
+ $user
+ }
+ 'AllUsers' {
+ Get-GitHubAllUsers -Since $Since -PerPage $PerPage -Context $Context
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Get-GitHubUserCard.ps1 b/src/functions/public/Users/Get-GitHubUserCard.ps1
index 74ac00a1..79ae51fb 100644
--- a/src/functions/public/Users/Get-GitHubUserCard.ps1
+++ b/src/functions/public/Users/Get-GitHubUserCard.ps1
@@ -45,21 +45,36 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- subject_type = $SubjectType
- subject_id = $SubjectID
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/users/$Username/hovercard"
- Method = 'GET'
- Body = $body
+ process {
+ try {
+ $body = @{
+ subject_type = $SubjectType
+ subject_id = $SubjectID
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/users/$Username/hovercard"
+ Method = 'GET'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1
index ca015268..dcd9b37f 100644
--- a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1
+++ b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1
@@ -42,21 +42,36 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- title = $Title
- key = $Key
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/keys'
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ title = $Title
+ key = $Key
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/keys'
+ Method = 'POST'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1
index 5605ec71..04dd5f42 100644
--- a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1
+++ b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1
@@ -58,15 +58,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
- if ($Username) {
- Get-GitHubUserKeyForUser -Username $Username -PerPage $PerPage -Context $Context
- } else {
- if ($ID) {
- Get-GitHubUserMyKeyById -ID $ID -Context $Context
- } else {
- Get-GitHubUserMyKey -PerPage $PerPage -Context $Context
+ process {
+ try {
+ if ($Username) {
+ Get-GitHubUserKeyForUser -Username $Username -PerPage $PerPage -Context $Context
+ } else {
+ if ($ID) {
+ Get-GitHubUserMyKeyById -ID $ID -Context $Context
+ } else {
+ Get-GitHubUserMyKey -PerPage $PerPage -Context $Context
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1
index b69a2888..6870fcfe 100644
--- a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1
+++ b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1
@@ -34,17 +34,32 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/keys/$ID"
- Method = 'DELETE'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- if ($PSCmdlet.ShouldProcess("Key with ID [$ID]", 'Delete')) {
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/keys/$ID"
+ Method = 'DELETE'
+ }
+
+ if ($PSCmdlet.ShouldProcess("Key with ID [$ID]", 'Delete')) {
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1
index 82f2350b..13815ab3 100644
--- a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1
+++ b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1
@@ -44,21 +44,36 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- title = $Title
- key = $Key
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/ssh_signing_keys'
- Method = 'POST'
- Body = $body
+ process {
+ try {
+ $body = @{
+ title = $Title
+ key = $Key
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/ssh_signing_keys'
+ Method = 'POST'
+ Body = $body
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1
index 9a72c78c..cc1fd255 100644
--- a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1
+++ b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1
@@ -58,15 +58,30 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
+ }
- if ($Username) {
- Get-GitHubUserSigningKeyForUser -Username $Username -PerPage $PerPage -Context $Context
- } else {
- if ($ID) {
- Get-GitHubUserMySigningKeyById -ID $ID -Context $Context
- } else {
- Get-GitHubUserMySigningKey -PerPage $PerPage -Context $Context
+ process {
+ try {
+ if ($Username) {
+ Get-GitHubUserSigningKeyForUser -Username $Username -PerPage $PerPage -Context $Context
+ } else {
+ if ($ID) {
+ Get-GitHubUserMySigningKeyById -ID $ID -Context $Context
+ } else {
+ Get-GitHubUserMySigningKey -PerPage $PerPage -Context $Context
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1
index 113cedaf..af4aab7b 100644
--- a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1
+++ b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1
@@ -35,17 +35,32 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/user/ssh_signing_keys/$ID"
- Method = 'DELETE'
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) {
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ process {
+ try {
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/user/ssh_signing_keys/$ID"
+ Method = 'DELETE'
+ }
+
+ if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) {
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Set-GitHubUser.ps1 b/src/functions/public/Users/Set-GitHubUser.ps1
index f89e3ecd..b7c23432 100644
--- a/src/functions/public/Users/Set-GitHubUser.ps1
+++ b/src/functions/public/Users/Set-GitHubUser.ps1
@@ -68,29 +68,44 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- name = $Name
- email = $Email
- blog = $Blog
- twitter_username = $TwitterUsername
- company = $Company
- location = $Location
- hireable = $Hireable
- bio = $Bio
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user'
- Method = 'PATCH'
- Body = $body
+ process {
+ try {
+ $body = @{
+ name = $Name
+ email = $Email
+ blog = $Blog
+ twitter_username = $TwitterUsername
+ company = $Company
+ location = $Location
+ hireable = $Hireable
+ bio = $Bio
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user'
+ Method = 'PATCH'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess('authenticated user', 'Set')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
+ }
}
- if ($PSCmdlet.ShouldProcess('authenticated user', 'Set')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
+ end {
+ Write-Debug "[$stackPath] - End"
}
}
diff --git a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1
index 48ac0606..ebafaa78 100644
--- a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1
+++ b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1
@@ -30,21 +30,35 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- account_urls = $AccountUrls
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/social_accounts'
- Body = $body
- Method = 'POST'
- }
+ process {
+ try {
+ $body = @{
+ account_urls = $AccountUrls
+ }
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/social_accounts'
+ Body = $body
+ Method = 'POST'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ } catch {
+ throw $_
+ }
}
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1
index ac548a43..48bea649 100644
--- a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1
+++ b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1
@@ -31,22 +31,37 @@
[object] $Context = (Get-GitHubContext)
)
- $Context = Resolve-GitHubContext -Context $Context
-
- $body = @{
- account_urls = $AccountUrls
+ begin {
+ $stackPath = Get-PSCallStackPath
+ Write-Debug "[$stackPath] - Start"
+ $Context = Resolve-GitHubContext -Context $Context
+ Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
- $inputObject = @{
- Context = $Context
- APIEndpoint = '/user/social_accounts'
- Body = $body
- Method = 'DELETE'
- }
+ process {
+ try {
+ $body = @{
+ account_urls = $AccountUrls
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/user/social_accounts'
+ Body = $body
+ Method = 'DELETE'
+ }
- if ($PSCmdlet.ShouldProcess("Social accounts [$($AccountUrls -join ', ')]", 'Delete')) {
- $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
+ if ($PSCmdlet.ShouldProcess("Social accounts [$($AccountUrls -join ', ')]", 'Delete')) {
+ $null = Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ throw $_
}
}
+
+ end {
+ Write-Debug "[$stackPath] - End"
+ }
}
diff --git a/tools/utilities/GitHubAPI.ps1 b/tools/utilities/GitHubAPI.ps1
index e7a06f98..956966d5 100644
--- a/tools/utilities/GitHubAPI.ps1
+++ b/tools/utilities/GitHubAPI.ps1
@@ -21,8 +21,8 @@ $response = Invoke-RestMethod -Uri $APIDocURI -Method Get
# @{n = 'PUT'; e = { (($_.value.psobject.Properties.Name) -contains 'PUT') } }, `
# @{n = 'PATCH'; e = { (($_.value.psobject.Properties.Name) -contains 'PATCH') } } | Format-Table
-$path = '/apps/{app_slug}'
-$method = 'get'
+$path = '/markdown/raw'
+$method = 'post'
$response.paths.$path.$method
$response.paths.$path.$method.tags | clip # -> Namespace/foldername
$response.paths.$path.$method.operationId | clip # -> FunctionName
@@ -41,57 +41,9 @@ $response.paths.$path.$method.responses.'200'.content.'application/json'.schema
$response.paths.$path.$method.responses.'200'.content.'application/json'.schema.items # -> OutputType
$response.components.schemas.'issue-comment' | ConvertTo-Json
+$response.components.responses # HTTP status descriptions
-function New-Function {
- [CmdletBinding(SupportsShouldProcess)]
- param(
- [Parameter(Mandatory)]
- [string] $Path,
-
- [Parameter(Mandatory)]
- [string] $Method
- )
-
- $APIDocURI = 'https://raw.githubusercontent.com/github/rest-api-description/main'
- $Bundled = '/descriptions/api.github.com/api.github.com.json'
- # $Dereferenced = 'descriptions/api.github.com/dereferenced/api.github.com.deref.json'
- $APIDocURI = $APIDocURI + $Bundled
- $response = Invoke-RestMethod -Uri $APIDocURI -Method Get
-
- $response.paths.$Path.$Method
-
- $FunctionName = "$Method-GitHub" + (($response.paths.$path.$method.operationId) -Replace '/', '-')
-
- $folderName = $response.paths.$path.$method.'x-github'.category
- $subFolderName = $response.paths.$path.$method.'x-github'.subcategory
-
- $template = @"
- function $FunctionName {
- <#
- .SYNOPSIS
- $($response.paths.$path.$method.summary)
-
- .DESCRIPTION
- $($response.paths.$path.$method.description)
-
- .EXAMPLE
- An example
-
- .NOTES
- [$($response.paths.$path.$method.summary)]($($response.paths.$path.$method.externalDocs.url))
- #>
- [OutputType([pscustomobject])]
- [CmdletBinding()]
- param(
- # The context to run the command in.
- [Parameter()]
- [string] `$Context = (Get-GitHubConfig -Name 'DefaultContext')
- )
- }
-"@
- if ($PSCmdlet.ShouldProcess('Function', 'Create')) {
- New-Item -Path "src/functions/$folderName/$subFolderName" -Name "$FunctionName.ps1" -ItemType File -Value $template
- }
-
-}
+$path = '/repos/{owner}/{repo}/actions/runs'
+$method = 'get'
+$response.components.schemas.'issue-comment'
diff --git a/tools/utilities/New-Function.ps1 b/tools/utilities/New-Function.ps1
index 062e987e..e7a79fde 100644
--- a/tools/utilities/New-Function.ps1
+++ b/tools/utilities/New-Function.ps1
@@ -1,85 +1,72 @@
-function New-Function {
+
+function New-Function {
<#
- .SYNOPSIS
- Short description
+ .SYNOPSIS
+ Short description
- .DESCRIPTION
- Long description
+ .DESCRIPTION
+ Long description
- .EXAMPLE
- An example
+ .PARAMETER Path
+ Parameter description
- .NOTES
- General notes
+ .PARAMETER Method
+ Parameter description
+
+ .EXAMPLE
+ An example
+
+ .NOTES
+ General notes
#>
[CmdletBinding(SupportsShouldProcess)]
param(
- # The name of the organization.
- [Parameter()]
- [string]$Owner,
-
- # The name of the organization.
- [Parameter()]
- [string]$Repo,
+ [Parameter(Mandatory)]
+ [string] $Path,
- # The context to run the command in. Used to get the details for the API call.
- # Can be either a string or a GitHubContext object.
- [Parameter()]
- [object] $Context = (Get-GitHubContext)
+ [Parameter(Mandatory)]
+ [string] $Method
)
- begin {
- $commandName = $MyInvocation.MyCommand.Name
- Write-Debug "[$commandName] - Start"
+ $APIDocURI = 'https://raw.githubusercontent.com/github/rest-api-description/main'
+ $Bundled = '/descriptions/api.github.com/api.github.com.json'
+ # $Dereferenced = 'descriptions/api.github.com/dereferenced/api.github.com.deref.json'
+ $APIDocURI = $APIDocURI + $Bundled
+ $response = Invoke-RestMethod -Uri $APIDocURI -Method Get
- $Context = Resolve-GitHubContext -Context $Context
+ $response.paths.$Path.$Method
- if ([string]::IsNullOrEmpty($Enterprise)) {
- $Enterprise = $Context.Enterprise
- }
- Write-Debug "Enterprise : [$($Context.Enterprise)]"
+ $FunctionName = "$Method-GitHub" + (($response.paths.$path.$method.operationId) -Replace '/', '-')
- if ([string]::IsNullOrEmpty($Owner)) {
- $Owner = $Context.Owner
- }
- Write-Debug "Owner : [$($Context.Owner)]"
+ $folderName = $response.paths.$path.$method.'x-github'.category
+ $subFolderName = $response.paths.$path.$method.'x-github'.subcategory
- if ([string]::IsNullOrEmpty($Repo)) {
- $Repo = $Context.Repo
- }
- Write-Debug "Repo : [$($Context.Repo)]"
- }
+ $template = @"
+ function $FunctionName {
+ <#
+ .SYNOPSIS
+ $($response.paths.$path.$method.summary)
- process {
- try {
- $body = @{
- per_page = $PerPage
- }
+ .DESCRIPTION
+ $($response.paths.$path.$method.description)
- $inputObject = @{
- Context = $Context
- APIEndpoint = "/orgs/$OrganizationName/blocks"
- Method = 'GET'
- Body = $body
- }
+ .EXAMPLE
+ An example
- if ($PSCmdlet.ShouldProcess('Target', 'Operation')) {
- Invoke-GitHubAPI @inputObject | ForEach-Object {
- Write-Output $_.Response
- }
- }
- } catch {
- Write-Debug "Error: $_"
- } finally {
- Write-Debug 'Finally'
- }
+ .NOTES
+ [$($response.paths.$path.$method.summary)]($($response.paths.$path.$method.externalDocs.url))
+ #>
+ [OutputType([pscustomobject])]
+ [CmdletBinding()]
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] `$Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
}
-
- end {
- Write-Debug "[$commandName] - End"
+"@
+ if ($PSCmdlet.ShouldProcess('Function', 'Create')) {
+ New-Item -Path "src/functions/$folderName/$subFolderName" -Name "$FunctionName.ps1" -ItemType File -Value $template
}
- clean {
- Write-Debug 'Clean'
- }
}
diff --git a/tools/utilities/New-FunctionTemplate.ps1 b/tools/utilities/New-FunctionTemplate.ps1
new file mode 100644
index 00000000..4d025022
--- /dev/null
+++ b/tools/utilities/New-FunctionTemplate.ps1
@@ -0,0 +1,85 @@
+function New-FunctionTemplate {
+ <#
+ .SYNOPSIS
+ Short description
+
+ .DESCRIPTION
+ Long description
+
+ .EXAMPLE
+ An example
+
+ .NOTES
+ General notes
+ #>
+ [CmdletBinding(SupportsShouldProcess)]
+ param(
+ # The name of the organization.
+ [Parameter()]
+ [string]$Owner,
+
+ # The name of the organization.
+ [Parameter()]
+ [string]$Repo,
+
+ # The context to run the command in. Used to get the details for the API call.
+ # Can be either a string or a GitHubContext object.
+ [Parameter()]
+ [object] $Context = (Get-GitHubContext)
+ )
+
+ begin {
+ $commandName = $MyInvocation.MyCommand.Name
+ Write-Debug "[$commandName] - Start"
+
+ $Context = Resolve-GitHubContext -Context $Context
+
+ if ([string]::IsNullOrEmpty($Enterprise)) {
+ $Enterprise = $Context.Enterprise
+ }
+ Write-Debug "Enterprise : [$($Context.Enterprise)]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $Context.Owner
+ }
+ Write-Debug "Owner : [$($Context.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $Context.Repo
+ }
+ Write-Debug "Repo : [$($Context.Repo)]"
+ }
+
+ process {
+ try {
+ $body = @{
+ per_page = $PerPage
+ }
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = "/orgs/$OrganizationName/blocks"
+ Method = 'GET'
+ Body = $body
+ }
+
+ if ($PSCmdlet.ShouldProcess('Target', 'Operation')) {
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+ }
+ } catch {
+ Write-Debug "Error: $_"
+ } finally {
+ Write-Debug 'Finally'
+ }
+ }
+
+ end {
+ Write-Debug "[$commandName] - End"
+ }
+
+ clean {
+ Write-Debug 'Clean'
+ }
+}