From 19d5801a4267d06af9ea8865f2d4571e83d3cf89 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 23 Jan 2025 16:15:24 +0100 Subject: [PATCH 01/71] Fix App installations --- src/functions/public/Actions/{ => Data}/Get-GitHubEventData.ps1 | 0 src/functions/public/Actions/{ => Data}/Get-GitHubRunnerData.ps1 | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/functions/public/Actions/{ => Data}/Get-GitHubEventData.ps1 (100%) rename src/functions/public/Actions/{ => Data}/Get-GitHubRunnerData.ps1 (100%) diff --git a/src/functions/public/Actions/Get-GitHubEventData.ps1 b/src/functions/public/Actions/Data/Get-GitHubEventData.ps1 similarity index 100% rename from src/functions/public/Actions/Get-GitHubEventData.ps1 rename to src/functions/public/Actions/Data/Get-GitHubEventData.ps1 diff --git a/src/functions/public/Actions/Get-GitHubRunnerData.ps1 b/src/functions/public/Actions/Data/Get-GitHubRunnerData.ps1 similarity index 100% rename from src/functions/public/Actions/Get-GitHubRunnerData.ps1 rename to src/functions/public/Actions/Data/Get-GitHubRunnerData.ps1 From cda6444a4654daca0bc2d0a27f37fbe4aa13163d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 23 Jan 2025 22:23:28 +0100 Subject: [PATCH 02/71] Move GitHubAppJWT to GitHub Apps --- .../public/Apps/{ => GitHub Apps}/Get-GitHubAppJSONWebToken.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/functions/public/Apps/{ => GitHub Apps}/Get-GitHubAppJSONWebToken.ps1 (100%) diff --git a/src/functions/public/Apps/Get-GitHubAppJSONWebToken.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 similarity index 100% rename from src/functions/public/Apps/Get-GitHubAppJSONWebToken.ps1 rename to src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 From b02e0bbbe4ea5231407671bb4ae2a9ab152b615a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 24 Jan 2025 15:00:17 +0100 Subject: [PATCH 03/71] Move GitHub App installation and uninstallation functions to private directory; enforce mandatory parameters --- .github/workflows/Process-PSModule.yml | 2 + ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 14 +-- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 12 +-- .../Apps/GitHub Apps/Install-GitHubApp.ps1 | 94 +++++++++++++++++++ .../Apps/GitHub Apps/Uninstall-GitHubApp.ps1 | 84 +++++++++++++++++ .../Get-GitHubEnterpriseOrganization.ps1 | 2 +- 6 files changed, 188 insertions(+), 20 deletions(-) rename src/functions/{public/Enterprise => private/Apps/GitHub Apps}/Install-GitHubAppOnEnterpriseOrganization.ps1 (85%) rename src/functions/{public/Enterprise => private/Apps/GitHub Apps}/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 (82%) create mode 100644 src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 create mode 100644 src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 5252ed337..bc8b830f0 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -36,3 +36,5 @@ jobs: TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} + with: + SkipTests: All diff --git a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 similarity index 85% rename from src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 rename to src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 index 2f72c5f66..662729535 100644 --- a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -14,7 +14,7 @@ [CmdletBinding()] param( # The enterprise slug or ID. - [Parameter()] + [Parameter(Mandatory)] [string] $Enterprise, # The organization name. The name is not case sensitive. @@ -28,9 +28,9 @@ # The repository selection for the GitHub App. Can be one of: # - all - all repositories that the authenticated GitHub App installation can access. # - selected - select specific repositories. - [Parameter()] + [Parameter(Mandatory)] [ValidateSet('all', 'selected')] - [string] $RepositorySelection = 'all', + [string] $RepositorySelection, # The names of the repositories to which the installation will be granted access. [Parameter()] @@ -39,18 +39,12 @@ # 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) + [object] $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($Enterprise)) { - $Enterprise = $Context.Enterprise - } - Write-Debug "Enterprise: [$Enterprise]" } process { diff --git a/src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 similarity index 82% rename from src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 rename to src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index 92596632c..058eeaa0a 100644 --- a/src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -16,7 +16,7 @@ [CmdletBinding()] param( # The enterprise slug or ID. - [Parameter()] + [Parameter(Mandatory)] [string] $Enterprise, # The organization name. The name is not case sensitive. @@ -25,24 +25,18 @@ # The client ID of the GitHub App to install. [Parameter(Mandatory)] - [Alias('installation_id')] + [Alias('installation_id', 'id')] [string] $InstallationID, # 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) + [object] $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($Enterprise)) { - $Enterprise = $Context.Enterprise - } - Write-Debug "Enterprise: [$Enterprise]" } process { diff --git a/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 b/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 new file mode 100644 index 000000000..0ff6d2e41 --- /dev/null +++ b/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 @@ -0,0 +1,94 @@ +function Install-GitHubApp { + <# + .SYNOPSIS + Install an app + + .DESCRIPTION + Installs the provided GitHub App on the specified target. + + .EXAMPLE + Install-GitHubApp -Enterprise 'msx' -Organization 'org' -ClientID '123456' -RepositorySelection 'selected' -Repositories 'repo1', 'repo2' + + Install the GitHub App with + - the client ID '123456' + - the repository selection 'selected' + - the repositories 'repo1' and 'repo2' + on the organization 'org' in the enterprise 'msx'. + + .EXAMPLE + Install-GitHubApp -Enterprise 'msx' -Organization 'org' -ClientID '123456' -RepositorySelection 'all' + + Install the GitHub App with + - the client ID '123456' + - the repository selection 'all' + on the organization 'org' in the enterprise 'msx'. + #> + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ParameterSetName = 'EnterpriseOrganization', + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ParameterSetName = 'EnterpriseOrganization', + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # The client ID of the GitHub App to install. + [Parameter(Mandatory)] + [string] $ClientID, + + # 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 + } + + process { + if ([string]::IsNullOrEmpty($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise: [$Enterprise]" + if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization + } + Write-Debug "Organization: [$Organization]" + try { + switch ($PSCmdlet.ParameterSetName) { + 'EnterpriseOrganization' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + ClientID = $ClientID + RepositorySelection = $RepositorySelection + Repositories = $Repositories + Context = $Context + } + Install-GitHubAppOnEnterpriseOrganization @params + } + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} + +#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 b/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 new file mode 100644 index 000000000..d14eb0fbb --- /dev/null +++ b/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 @@ -0,0 +1,84 @@ +function Uninstall-GitHubApp { + <# + .SYNOPSIS + Uninstall a GitHub App. + + .DESCRIPTION + Uninstalls the provided GitHub App on the specified target. + + .EXAMPLE + Uninstall-GitHubApp -Enterprise 'msx' -Organization 'org' -InstallationID '123456' + + Uninstall the GitHub App with the installation ID '123456' from the organization 'org' in the enterprise 'msx'. + #> + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ParameterSetName = 'EnterpriseOrganization', + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ParameterSetName = 'EnterpriseOrganization', + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # The client ID of the GitHub App to install. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('installation_id', 'id')] + [string] $InstallationID, + + # 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 + } + + process { + if ([string]::IsNullOrEmpty($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise: [$Enterprise]" + if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization + } + Write-Debug "Organization: [$Organization]" + try { + switch ($PSCmdlet.ParameterSetName) { + 'EnterpriseOrganization' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + InstallationID = $InstallationID + Context = $Context + } + Uninstall-GitHubAppOnEnterpriseOrganization @params + } + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} + +#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 index 98ff3efee..67f25496c 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 @@ -11,7 +11,7 @@ #> [CmdletBinding()] param( - [Parameter()] + [Parameter(Mandatory)] [string] $Enterprise, # The context to run the command in. Used to get the details for the API call. From 9764809604fc60e1dcaaefcd8063cd0fc971296c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 24 Jan 2025 16:04:22 +0100 Subject: [PATCH 04/71] Add repository selection parameters to Install-GitHubApp function --- .../public/Apps/GitHub Apps/Install-GitHubApp.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 b/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 index 0ff6d2e41..93f5e5f53 100644 --- a/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 @@ -45,6 +45,17 @@ [Parameter(Mandatory)] [string] $ClientID, + # The repository selection for the GitHub App. Can be one of: + # - all - all repositories that the authenticated GitHub App installation can access. + # - selected - select specific repositories. + [Parameter()] + [ValidateSet('all', 'selected')] + [string] $RepositorySelection = 'selected', + + # The names of the repositories to which the installation will be granted access. + [Parameter()] + [string[]] $Repositories = @(), + # 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()] From 6d4b2958faa8f95f39a29f46e2ae4dd25111b308 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 26 Jan 2025 21:22:57 +0100 Subject: [PATCH 05/71] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Update=20context?= =?UTF-8?q?=20parameters=20for=20GitHub=20installation=20types=20and=20adj?= =?UTF-8?q?ust=20parameter=20requirement=20for=20Get-GitHubEnterpriseOrgan?= =?UTF-8?q?ization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Auth/Connect-GitHubApp.ps1 | 11 +++++++---- .../Enterprise/Get-GitHubEnterpriseOrganization.ps1 | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 2b15b2dab..69ded8da1 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -126,15 +126,18 @@ TokenExpirationDate = [datetime]$token.ExpiresAt } - $contextParams['InstallationName'] = switch ($installation.target_type) { + switch ($installation.target_type) { 'User' { - [string]$installation.account.login + $contextParams['InstallationName'] = [string]$installation.account.login + $contextParams['Organization'] = [string]$installation.account.login } 'Organization' { - [string]$installation.account.login + $contextParams['InstallationName'] = [string]$installation.account.login + $contextParams['Organization'] = [string]$installation.account.login } 'Enterprise' { - [string]$installation.account.slug + $contextParams['InstallationName'] = [string]$installation.account.slug + $contextParams['Enterprise'] = [string]$installation.account.slug } } Write-Verbose 'Logging in using a managed installation access token...' diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 index 67f25496c..98ff3efee 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 @@ -11,7 +11,7 @@ #> [CmdletBinding()] param( - [Parameter(Mandatory)] + [Parameter()] [string] $Enterprise, # The context to run the command in. Used to get the details for the API call. From cfb64810ee655d49fa40caaa8913170163bcecea Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 26 Jan 2025 21:40:29 +0100 Subject: [PATCH 06/71] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Remove=20default?= =?UTF-8?q?=20context=20assignment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 | 3 +-- .../private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 | 3 +-- src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 | 3 +-- .../private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 | 3 +-- .../private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 | 3 +-- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 | 3 +-- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 | 3 +-- src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 | 2 +- .../Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 | 3 +-- .../private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 3 +-- src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 | 3 +-- src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 | 3 +-- src/functions/private/License/Get-GitHubLicenseByName.ps1 | 3 +-- src/functions/private/License/Get-GitHubLicenseList.ps1 | 3 +-- src/functions/private/License/Get-GitHubRepositoryLicense.ps1 | 3 +-- .../Organization/Blocking/Block-GitHubUserByOrganization.ps1 | 3 +-- .../Blocking/Get-GitHubBlockedUserByOrganization.ps1 | 3 +-- .../Blocking/Test-GitHubBlockedUserByOrganization.ps1 | 3 +-- .../Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 | 3 +-- .../private/Organization/Get-GitHubAllOrganization.ps1 | 3 +-- .../private/Organization/Get-GitHubMyOrganization.ps1 | 3 +-- .../private/Organization/Get-GitHubOrganizationByName.ps1 | 3 +-- .../private/Organization/Get-GitHubUserOrganization.ps1 | 3 +-- .../private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 | 3 +-- .../Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 | 3 +-- .../private/Releases/Releases/Get-GitHubReleaseAll.ps1 | 3 +-- .../private/Releases/Releases/Get-GitHubReleaseByID.ps1 | 3 +-- .../private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 | 3 +-- .../private/Releases/Releases/Get-GitHubReleaseLatest.ps1 | 3 +-- .../Autolinks/Get-GitHubRepositoryAutolinkById.ps1 | 3 +-- .../Autolinks/Get-GitHubRepositoryAutolinkList.ps1 | 3 +-- .../private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 | 3 +-- .../Repositories/Repositories/Get-GitHubMyRepositories.ps1 | 3 +-- .../Repositories/Repositories/Get-GitHubRepositoryByName.ps1 | 3 +-- .../Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 | 3 +-- .../Repositories/Get-GitHubRepositoryListByOrg.ps1 | 3 +-- .../Repositories/Get-GitHubRepositoryListByUser.ps1 | 3 +-- .../Repositories/New-GitHubRepositoryFromTemplate.ps1 | 3 +-- .../Repositories/Repositories/New-GitHubRepositoryOrg.ps1 | 3 +-- .../Repositories/Repositories/New-GitHubRepositoryUser.ps1 | 3 +-- src/functions/private/Teams/Get-GitHubRESTTeam.ps1 | 3 +-- src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 | 3 +-- src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 | 3 +-- src/functions/private/Teams/Get-GitHubRepoTeam.ps1 | 3 +-- src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 | 3 +-- src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 | 3 +-- .../private/Users/Blocking/Block-GitHubUserByUser.ps1 | 3 +-- .../private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 | 3 +-- .../private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 | 3 +-- .../private/Users/Blocking/Unblock-GitHubUserByUser.ps1 | 3 +-- src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 | 3 +-- .../private/Users/Emails/Get-GitHubUserPublicEmail.ps1 | 3 +-- .../private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 | 3 +-- .../private/Users/Followers/Get-GitHubUserFollowingMe.ps1 | 3 +-- .../private/Users/Followers/Get-GitHubUserFollowingUser.ps1 | 3 +-- .../private/Users/Followers/Get-GitHubUserMyFollowers.ps1 | 3 +-- .../private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 | 3 +-- .../private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 | 3 +-- .../private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 | 3 +-- .../private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 | 3 +-- .../private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 | 3 +-- src/functions/private/Users/Get-GitHubAllUser.ps1 | 3 +-- src/functions/private/Users/Get-GitHubMyUser.ps1 | 3 +-- src/functions/private/Users/Get-GitHubUserByName.ps1 | 3 +-- src/functions/private/Users/Get-GitHubUserCard.ps1 | 3 +-- src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 | 3 +-- src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 | 3 +-- src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 | 3 +-- .../Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 | 3 +-- .../Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 | 3 +-- .../Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 | 3 +-- .../private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 | 3 +-- .../Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 | 3 +-- 73 files changed, 73 insertions(+), 145 deletions(-) diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 index 9032bef8a..98a0fe01e 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 @@ -84,13 +84,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 index e07a5fbca..b76e45b85 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 @@ -91,13 +91,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 index df1b98df9..22ef0dec1 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 @@ -27,13 +27,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index c32b49a48..2cee9fc3f 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -26,13 +26,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType App } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index 6b6e77462..e2d17a555 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -29,13 +29,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType APP } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 1be9aff19..4c643bae4 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -28,13 +28,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType APP } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 index 9bb7ce43c..d39ab1c5a 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 @@ -26,13 +26,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType APP } diff --git a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 index dffd3960e..68b5659bd 100644 --- a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 @@ -26,7 +26,7 @@ # The context to resolve into an object. Used to get the details for the API call. # Can be either a string or a GitHubContext object. [Parameter(ValueFromPipeline)] - [object] $Context = (Get-GitHubContext) + [object] $Context ) begin { diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 index a4e6f3059..1d0774e8c 100644 --- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 @@ -17,13 +17,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context } process { diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index ccf985237..d78cfea46 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -28,7 +28,7 @@ # 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), + [object] $Context, # Return the new access token. [Parameter()] @@ -38,7 +38,6 @@ begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType UAT } diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 index e3c0fbc1d..3d168a329 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 @@ -24,13 +24,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index 7d1c70942..257bd7514 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -22,13 +22,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index a058020c9..4dc6b32f6 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -27,13 +27,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index 718f95b42..d741aaced 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -23,13 +23,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index e3c066468..387cc991c 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -36,13 +36,12 @@ # 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) + [object] $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)) { diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 109173ff5..88045169f 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -41,13 +41,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index d99be05ef..b76586c66 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -32,13 +32,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index 928be8432..337697fdf 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -40,13 +40,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index 978360299..712528a72 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -41,13 +41,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index d8a1102d8..3c42c016d 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -34,13 +34,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index b561dcb69..0640e4f70 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -33,13 +33,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index bceada5aa..07f0fc6c6 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -39,13 +39,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index e66124df4..0d56c7735 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -35,13 +35,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index c40692353..94826c337 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -36,13 +36,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 8e9fcc7f7..751207633 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -41,13 +41,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index c35157bb8..b747c3577 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -35,13 +35,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 5f60d311a..05fe2ac60 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -34,13 +34,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index 156454bc5..6f658e55c 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -33,13 +33,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index 8c0325899..537eb0833 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -30,13 +30,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index 3a93ca727..7c1c0149a 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -37,13 +37,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index d42736410..1f9bf863b 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -31,13 +31,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index 0a1e85d88..6137b628a 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -65,13 +65,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index acdfb5eb4..6cbf70952 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -110,13 +110,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index ff9b5f24f..ade44e09f 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -33,13 +33,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index f3cd52686..27d3e1942 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -30,13 +30,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index 2e24b3ac8..3f06ead09 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -59,13 +59,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index 70d5133e8..0eb7e421f 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -61,13 +61,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index f9bfe16b7..e6ea2ff61 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -75,13 +75,12 @@ # 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) + [object] $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 diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 1eddfd0ba..0ff2e5dd2 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -184,7 +184,7 @@ filter New-GitHubRepositoryOrg { # 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) + [object] $Context ) dynamicparam { @@ -214,7 +214,6 @@ 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'] diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index 3405128a5..b953b4059 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -178,7 +178,7 @@ filter New-GitHubRepositoryUser { # 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) + [object] $Context ) dynamicparam { @@ -208,7 +208,6 @@ 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'] diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index ed1859723..f78369c67 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -42,13 +42,12 @@ # 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) + [object] $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($Organization)) { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index a7fc5d519..1291cf2b8 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -26,13 +26,12 @@ # 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) + [object] $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($Organization)) { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index 4575a53b2..fdbeb69f3 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -23,13 +23,12 @@ # 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) + [object] $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($Organization)) { diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index 2db1a32c4..7c4e327aa 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -14,13 +14,12 @@ # 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) + [object] $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)) { diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 index b8675c403..f545c93e0 100644 --- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 @@ -27,13 +27,12 @@ # 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) + [object] $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($Organization)) { diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 index 24f28cb3a..407308d43 100644 --- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 @@ -24,13 +24,12 @@ # 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) + [object] $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($Organization)) { diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index 4f5846da0..9d76b002d 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -30,13 +30,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index 768614871..603a4374b 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -25,13 +25,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index ebd64b1f0..1f2f547ef 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -37,13 +37,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index ef2916a5d..fa9810262 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -30,13 +30,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index 9929a4dcd..c6a236301 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -27,13 +27,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index d810b0612..8fe9f8791 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -29,13 +29,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index 5651515da..a12689b74 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -35,13 +35,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index 7de86587c..9f6ea98d8 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -26,13 +26,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index 90f9ded87..22a002103 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -35,13 +35,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index 1d9af6015..0cdcded2a 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -27,13 +27,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index 483e7d52e..c9c0c26f2 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -29,13 +29,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index e816d0184..42ef3a84b 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -35,13 +35,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 index 2d21817b9..61dc38abe 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 @@ -33,13 +33,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 index dfdc6d031..93655405f 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 @@ -28,13 +28,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 index 01ffbe5cf..a878d3461 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 @@ -30,13 +30,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 1a6d095e3..1a456bfe6 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -33,13 +33,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1 index b58ad6ed7..4e9bc820f 100644 --- a/src/functions/private/Users/Get-GitHubMyUser.ps1 +++ b/src/functions/private/Users/Get-GitHubMyUser.ps1 @@ -23,13 +23,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1 index be4c82bd1..182689dde 100644 --- a/src/functions/private/Users/Get-GitHubUserByName.ps1 +++ b/src/functions/private/Users/Get-GitHubUserByName.ps1 @@ -41,13 +41,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 index f42114014..2fbeea5ad 100644 --- a/src/functions/private/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/private/Users/Get-GitHubUserCard.ps1 @@ -42,13 +42,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 index ce4ebdccb..0663da987 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 @@ -33,13 +33,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 index 2ebe8ac8a..c1e2ba98d 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 @@ -28,13 +28,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 index 32642acc3..5044d6a28 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 @@ -30,13 +30,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } 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 30706acda..243aff987 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 @@ -28,13 +28,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } 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 d4db058f9..5354871b0 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 @@ -31,13 +31,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } 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 fccf461e5..b9229c5ec 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 @@ -33,13 +33,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 index f9ff21027..3e5095cda 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 @@ -26,13 +26,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 index 4cff51bdf..caf55da7c 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 @@ -29,13 +29,12 @@ # 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) + [object] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } From c4a1f2304de05381257c80e640c4c8f669e1953e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 26 Jan 2025 21:41:00 +0100 Subject: [PATCH 07/71] tests --- .github/workflows/Process-PSModule.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index bc8b830f0..c0f82c2f3 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -36,5 +36,5 @@ jobs: TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} - with: - SkipTests: All + # with: + # SkipTests: All From 6329abfb596765ea9390dc300c60e42db4bf479d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 27 Jan 2025 08:35:15 +0100 Subject: [PATCH 08/71] Revert Organization to Owner --- src/functions/public/Auth/Connect-GitHubApp.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 69ded8da1..96f0d73d0 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -129,11 +129,11 @@ switch ($installation.target_type) { 'User' { $contextParams['InstallationName'] = [string]$installation.account.login - $contextParams['Organization'] = [string]$installation.account.login + $contextParams['Owner'] = [string]$installation.account.login } 'Organization' { $contextParams['InstallationName'] = [string]$installation.account.login - $contextParams['Organization'] = [string]$installation.account.login + $contextParams['Owner'] = [string]$installation.account.login } 'Enterprise' { $contextParams['InstallationName'] = [string]$installation.account.slug From aacdbe3a4d49d929440f59706f5375287adc4b45 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 27 Jan 2025 12:39:51 +0100 Subject: [PATCH 09/71] Remove dynamicparam that requires context --- .../public/Gitignore/Get-GitHubGitignore.ps1 | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 index 7fca1570e..7746c1116 100644 --- a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 +++ b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } - -filter Get-GitHubGitignore { +filter Get-GitHubGitignore { <# .SYNOPSIS Get a gitignore template or list of all gitignore templates names @@ -25,28 +23,18 @@ filter Get-GitHubGitignore { #> [CmdletBinding(DefaultParameterSetName = 'List')] param( + [Parameter( + Mandatory, + ParameterSetName = 'Name' + )] + [string] $Name, + # 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) ) - dynamicparam { - $DynamicParamDictionary = New-DynamicParamDictionary - - $dynParam = @{ - Name = 'Name' - ParameterSetName = 'Name' - Type = [string] - Mandatory = $true - ValidateSet = Get-GitHubGitignoreList - DynamicParamDictionary = $DynamicParamDictionary - } - New-DynamicParam @dynParam - - return $DynamicParamDictionary - } - begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" @@ -78,3 +66,11 @@ filter Get-GitHubGitignore { Write-Debug "[$stackPath] - End" } } + +Register-ArgumentCompleter -CommandName Get-GitHubGitignore -ParameterName Name -ScriptBlock { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) + $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter + Get-GitHubGitignoreList -Context $fakeBoundParameter.Context | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { + [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + } +} From 42c4e6a9c57110f87f8fbb46a63be93bbe7604f0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 27 Jan 2025 20:44:58 +0100 Subject: [PATCH 10/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Rename=20Ins?= =?UTF-8?q?tallationID=20parameter=20to=20ID=20and=20update=20related=20AP?= =?UTF-8?q?I=20endpoints;=20remove=20Get-GitHubEnterpriseInstallableOrgani?= =?UTF-8?q?zation=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 6 +- ...-GitHubAppInstallationRepositoryAccess.ps1 | 101 +++++++++++++++ .../Get-GitHubAppAccessibleRepository.ps1 | 94 ++++++++++++++ .../Get-GitHubAppInstallableOrganization.ps1} | 14 ++- ...-GitHubAppInstallationRepositoryAccess.ps1 | 103 ++++++++++++++++ .../New-GitHubAppInstallationAccessToken.ps1 | 6 +- ...-GitHubAppInstallationRepositoryAccess.ps1 | 101 +++++++++++++++ .../Apps/GitHub Apps/Uninstall-GitHubApp.ps1 | 12 +- ...-GitHubAppInstallationRepositoryAccess.ps1 | 116 ++++++++++++++++++ 9 files changed, 539 insertions(+), 14 deletions(-) create mode 100644 src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 create mode 100644 src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 rename src/functions/public/{Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 => Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1} (82%) create mode 100644 src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 create mode 100644 src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 create mode 100644 src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 diff --git a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index 058eeaa0a..5cab9ae1d 100644 --- a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -25,8 +25,8 @@ # The client ID of the GitHub App to install. [Parameter(Mandatory)] - [Alias('installation_id', 'id')] - [string] $InstallationID, + [Alias('installation_id', 'InstallationID')] + [string] $ID, # 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. @@ -43,7 +43,7 @@ try { $inputObject = @{ Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$InstallationID}" + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID}" Method = 'Delete' } diff --git a/src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 new file mode 100644 index 000000000..499989e9a --- /dev/null +++ b/src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 @@ -0,0 +1,101 @@ +function Add-GitHubAppInstallationRepositoryAccess { + <# + .SYNOPSIS + Grant repository access to an organization installation. + + .DESCRIPTION + Grant repository access to an organization installation. + + .EXAMPLE + $params = @{ + Enterprise = 'msx' + Organization = 'PSModule' + InstallationID = 12345678 + Repositories = 'repo1', 'repo2' + } + Add-GitHubAppInstallationRepositoryAccess @params + + Grant access to the repositories 'repo1' and 'repo2' for the installation + with the ID '12345678' on the organization 'PSModule' in the enterprise 'msx'. + #> + [CmdletBinding(SupportsShouldProcess)] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # The unique identifier of the installation. + # Example: '12345678' + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('installation_id', 'InstallationID')] + [int] $ID, + + # The names of the repositories to which the installation will be granted access. + [Parameter()] + [string[]] $Repositories = @(), + + # 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($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise : [$($Context.Enterprise)]" + + if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization + } + Write-Debug "Organization : [$($Context.Organization)]" + } + + process { + try { + $body = @{ + repositories = $Repositories + } + + $inputObject = @{ + Context = $Context + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/add" + Method = 'PATCH' + Body = $body + } + + if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } + } catch { + Write-Debug "Error: $_" + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} + +#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 new file mode 100644 index 000000000..16ae21187 --- /dev/null +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 @@ -0,0 +1,94 @@ +function Get-GitHubAppAccessibleRepository { + <# + .SYNOPSIS + Get repositories belonging to an enterprise owned organization that can be made accessible to a GitHub App + + .DESCRIPTION + List the repositories belonging to an enterprise owned organization that can be made accessible to a GitHub App installed on that + organization. + + The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/enterprise_organization_installations (read) + permission. + + .EXAMPLE + $params = @{ + Enterprise = 'msx' + Organization = 'PSModule' + } + Get-GitHubAppAccessibleRepository @params + + Get the repositories that can be made accessible to a GitHub App installed on the organization 'PSModule' in the enterprise 'msx'. + #> + [CmdletBinding(SupportsShouldProcess)] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # 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($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise : [$($Context.Enterprise)]" + + if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization + } + Write-Debug "Organization : [$($Context.Organization)]" + } + + process { + try { + $body = @{ + pre_page = $PerPage + } + + $inputObject = @{ + Context = $Context + APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" + Method = 'PATCH' + Body = $body + } + + if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } + } catch { + Write-Debug "Error: $_" + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} + +#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 similarity index 82% rename from src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 rename to src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 index 3ec304425..fd1578f43 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubEnterpriseInstallableOrganization { +function Get-GitHubAppInstallableOrganization { <# .SYNOPSIS Get enterprise-owned organizations that can have GitHub Apps installed @@ -10,7 +10,7 @@ (read) permission. .EXAMPLE - Get-GitHubEnterpriseInstallableOrganization -Enterprise 'msx' + Get-GitHubAppInstallableOrganization -Enterprise 'msx' #> [CmdletBinding()] param( @@ -18,6 +18,11 @@ [Parameter()] [string] $Enterprise, + # 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()] @@ -37,10 +42,15 @@ process { try { + $body = @{ + pre_page = $PerPage + } + $inputObject = @{ Context = $Context APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations" Method = 'GET' + Body = $body } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 new file mode 100644 index 000000000..991618e20 --- /dev/null +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 @@ -0,0 +1,103 @@ +function Get-GitHubAppInstallationRepositoryAccess { + <# + .SYNOPSIS + Get the repositories accessible to a given GitHub App installation. + + .DESCRIPTION + Lists the repositories accessible to a given GitHub App installation on an enterprise-owned organization. + + The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/organization_installations (read) permission. + + .EXAMPLE + $params = @{ + Enterprise = 'msx' + Organization = 'PSModule' + InstallationID = 12345678 + } + Get-GitHubAppInstallationRepositoryAccess @params + + Get the repositories accessible to the GitHub App installation + with the ID '12345678' on the organization 'PSModule' in the enterprise 'msx'. + #> + [CmdletBinding(SupportsShouldProcess)] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # The unique identifier of the installation. + # Example: '12345678' + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('installation_id', 'InstallationID')] + [int] $ID, + + # 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($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise : [$($Context.Enterprise)]" + + if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization + } + Write-Debug "Organization : [$($Context.Organization)]" + } + + process { + try { + $body = @{ + pre_page = $PerPage + } + + $inputObject = @{ + Context = $Context + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" + Method = 'PATCH' + Body = $body + } + + if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } + } catch { + Write-Debug "Error: $_" + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} + +#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 index 2b9cf17c6..7948d52ee 100644 --- a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 +++ b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 @@ -56,8 +56,8 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('ID')] - [int] $InstallationID, + [Alias('installation_id','InstallationID')] + [int] $ID, # 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. @@ -76,7 +76,7 @@ try { $inputObject = @{ Context = $Context - APIEndpoint = "/app/installations/$InstallationID/access_tokens" + APIEndpoint = "/app/installations/$ID/access_tokens" Method = 'Post' } diff --git a/src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 new file mode 100644 index 000000000..eb5eaea0c --- /dev/null +++ b/src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 @@ -0,0 +1,101 @@ +function Remove-GitHubAppInstallationRepositoryAccess { + <# + .SYNOPSIS + Remove repository access to an organization installation. + + .DESCRIPTION + Remove repository access to an organization installation. + + .EXAMPLE + $params = @{ + Enterprise = 'msx' + Organization = 'PSModule' + InstallationID = 12345678 + Repositories = 'repo1', 'repo2' + } + Remove-GitHubAppInstallationRepositoryAccess @params + + Remove access to the repositories 'repo1' and 'repo2' for the installation + with the ID '12345678' on the organization 'PSModule' in the enterprise 'msx'. + #> + [CmdletBinding(SupportsShouldProcess)] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # The unique identifier of the installation. + # Example: '12345678' + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('installation_id', 'InstallationID')] + [int] $ID, + + # The names of the repositories to which the installation will be granted access. + [Parameter()] + [string[]] $Repositories = @(), + + # 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($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise : [$($Context.Enterprise)]" + + if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization + } + Write-Debug "Organization : [$($Context.Organization)]" + } + + process { + try { + $body = @{ + repositories = $Repositories + } + + $inputObject = @{ + Context = $Context + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/remove" + Method = 'PATCH' + Body = $body + } + + if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } + } catch { + Write-Debug "Error: $_" + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} + +#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 b/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 index d14eb0fbb..fd487b598 100644 --- a/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 @@ -34,8 +34,8 @@ Mandatory, ValueFromPipelineByPropertyName )] - [Alias('installation_id', 'id')] - [string] $InstallationID, + [Alias('installation_id', 'InstallationID')] + [string] $ID, # 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. @@ -63,10 +63,10 @@ switch ($PSCmdlet.ParameterSetName) { 'EnterpriseOrganization' { $params = @{ - Enterprise = $Enterprise - Organization = $Organization - InstallationID = $InstallationID - Context = $Context + Enterprise = $Enterprise + Organization = $Organization + ID = $ID + Context = $Context } Uninstall-GitHubAppOnEnterpriseOrganization @params } diff --git a/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 new file mode 100644 index 000000000..e1ab1fa11 --- /dev/null +++ b/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 @@ -0,0 +1,116 @@ +function Update-GitHubAppInstallationRepositoryAccess { + <# + .SYNOPSIS + Update the installation repository access between all repositories and selected repositories. + + .DESCRIPTION + Update repository access for a GitHub App installation between all repositories and selected repositories. + + .EXAMPLE + Update-GitHubAppInstallationRepositoryAccess -Enterprise 'msx' -Organization 'PSModule' -InstallationID 12345678 -RepositorySelection 'all' + + Update the repository access for the GitHub App installation with the ID '12345678' + to all repositories on the organization 'PSModule' in the enterprise 'msx'. + + .EXAMPLE + $params = @{ + Enterprise = 'msx' + Organization = 'PSModule' + InstallationID = 12345678 + RepositorySelection = 'selected' + Repositories = 'repo1', 'repo2' + } + Update-GitHubAppInstallationRepositoryAccess @params + + Update the repository access for the GitHub App installation with the ID '12345678' + to the repositories 'repo1' and 'repo2' on the organization 'PSModule' in the enterprise 'msx'. + #> + [CmdletBinding(SupportsShouldProcess)] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # The unique identifier of the installation. + # Example: '12345678' + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('installation_id', 'InstallationID')] + [int] $ID, + + # The repository selection for the GitHub App. Can be one of: + # - all - all repositories that the authenticated GitHub App installation can access. + # - selected - select specific repositories. + [Parameter(Mandatory)] + [ValidateSet('all', 'selected')] + [string] $RepositorySelection, + + # The names of the repositories to which the installation will be granted access. + [Parameter()] + [string[]] $Repositories = @(), + + # 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($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise : [$($Context.Enterprise)]" + + if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization + } + Write-Debug "Organization : [$($Context.Organization)]" + } + + process { + try { + $body = @{ + repository_selection = $RepositorySelection + repositories = $Repositories + } + + $inputObject = @{ + Context = $Context + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" + Method = 'PATCH' + Body = $body + } + + if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } + } catch { + Write-Debug "Error: $_" + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} + +#SkipTest:FunctionTest:Will add a test for this function in a future PR From 60e4cb98a239693fac22aba1fed6708f777385d5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 27 Jan 2025 20:48:34 +0100 Subject: [PATCH 11/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Update=20ali?= =?UTF-8?q?as=20for=20InstallationID=20parameter=20to=20improve=20consiste?= =?UTF-8?q?ncy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 index 7948d52ee..f7e545a93 100644 --- a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 +++ b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 @@ -56,7 +56,7 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('installation_id','InstallationID')] + [Alias('installation_id', 'InstallationID')] [int] $ID, # The context to run the command in. Used to get the details for the API call. From 0df943a0aa33ad3f91c015d4c6dc6a99a8dfb4af Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 28 Jan 2025 00:24:43 +0100 Subject: [PATCH 12/71] Gather all GitHubAppInstallation functiuns under Get-GitHubAppInstallation (context aware) --- ...tHubAppInstallationForAuthenticatedApp.ps1 | 53 ++++++++++++ ...bEnterpriseOrganizationAppInstallation.ps1 | 77 ++++++++++++++++++ .../Get-GitHubOrganizationAppInstallation.ps1 | 13 +-- .../GitHub Apps/Get-GitHubAppInstallation.ps1 | 80 +++++++++++++------ tests/GitHub.Tests.ps1 | 8 +- 5 files changed, 193 insertions(+), 38 deletions(-) create mode 100644 src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 create mode 100644 src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 rename src/functions/{public/Organization => private/Apps/GitHub Apps}/Get-GitHubOrganizationAppInstallation.ps1 (84%) diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 new file mode 100644 index 000000000..1b050149b --- /dev/null +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -0,0 +1,53 @@ +function Get-GitHubAppInstallationForAuthenticatedApp { + <# + .SYNOPSIS + List installations for the authenticated app. + + .DESCRIPTION + The permissions the installation has are included under the `permissions` key. + + You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) + to access this endpoint. + + .EXAMPLE + Get-GitHubAppInstallationForAuthenticatedApp + + List installations for the authenticated app. + + .NOTES + [List installations for the authenticated app](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app) + #> + [CmdletBinding()] + param( + # 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 + ) + + begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" + Assert-GitHubContext -Context $Context -AuthType APP + } + + process { + try { + $inputObject = @{ + Context = $Context + APIEndpoint = '/app/installations' + Method = 'GET' + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 new file mode 100644 index 000000000..60f88d438 --- /dev/null +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -0,0 +1,77 @@ +function Get-GitHubEnterpriseOrganizationAppInstallation { + <# + .SYNOPSIS + List GitHub Apps installed on an enterprise-owned organization + + .DESCRIPTION + Lists the GitHub App installations associated with the given enterprise-owned organization. + + The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/organization_installations (read) permission. + + .EXAMPLE + Get-GitHubEnterpriseOrganizationAppInstallation -ENterprise 'msx' -Organization 'github' + + Gets all GitHub Apps in the organization `github` in the enterprise `msx`. + + .NOTES + [List GitHub Apps installed on an enterprise-owned organization]() + #> + [OutputType([pscustomobject])] + [CmdletBinding()] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Organization, + + # 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 + ) + + begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" + Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + } + + process { + try { + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Context = $Context + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" + Method = 'GET' + Body = $body + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.installations + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} diff --git a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 similarity index 84% rename from src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 rename to src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index a7a0f8b35..5c240c152 100644 --- a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubOrganizationAppInstallation { +function Get-GitHubOrganizationAppInstallation { <# .SYNOPSIS List app installations for an organization @@ -24,9 +24,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] - [Alias('login')] [string] $Organization, # The number of results per page (max 100). @@ -37,19 +34,13 @@ # 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) + [object] $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]" } process { diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 index d65c0e5f1..e493a4f37 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 @@ -1,24 +1,46 @@ -filter Get-GitHubAppInstallation { +function Get-GitHubAppInstallation { <# .SYNOPSIS - List installations for the authenticated app + List installations for the authenticated app, on organization or enterprise organization. .DESCRIPTION - The permissions the installation has are included under the `permissions` key. - - You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) - to access this endpoint. + Lists the installations for the authenticated app. + If the app is installed on an enterprise, the installations for the enterprise are returned. + If the app is installed on an organization, the installations for the organization are returned. + #> + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + param( + # The enterprise slug or ID. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName, + ParameterSetName = 'Enterprise' + )] + [string] $Enterprise, - .EXAMPLE - Get-GitHubAppInstallation + # The organization name. The name is not case sensitive. + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName, + ParameterSetName = 'Enterprise' + )] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName, + ParameterSetName = 'Organization' + )] + [string] $Organization, - List installations for the authenticated app. + # The number of results per page (max 100). + [Parameter( + ParameterSetName = 'Enterprise' + )] + [Parameter( + ParameterSetName = 'Organization' + )] + [ValidateRange(0, 100)] + [int] $PerPage, - .NOTES - [List installations for the authenticated app](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app) - #> - [CmdletBinding()] - param( # 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()] @@ -29,19 +51,31 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context - Assert-GitHubContext -Context $Context -AuthType APP } process { try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/installations' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + switch ($PSCmdlet.ParameterSetName) { + 'Enterprise' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + PerPage = $PerPage + Context = $Context + } + Get-GitHubEnterpriseOrganizationAppInstallation @params + } + 'Organization' { + $params = @{ + Organization = $Organization + PerPage = $PerPage + Context = $Context + } + Get-GitHubOrganizationAppInstallation @params + } + '__AllParameterSets' { + Get-GitHubAppInstallationForAuthenticatedApp -Context $Context + } } } catch { throw $_ diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index d657262cd..164c0198b 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -1030,8 +1030,8 @@ Describe 'As a GitHub App - Enterprise (APP_ENT)' { It 'Get-GitHubOrganization - Gets a specific organization (APP_ENT)' { { Get-GitHubOrganization -Organization 'psmodule-test-org3' } | Should -Not -Throw } - It 'Get-GitHubOrganizationAppInstallation - Gets the GitHub App installations on the organization (APP_ENT)' { - $installations = Get-GitHubOrganizationAppInstallation -Organization 'psmodule-test-org3' + It 'Get-GitHubAppInstallation - Gets the GitHub App installations on the organization (APP_ENT)' { + $installations = Get-GitHubAppInstallation -Organization 'psmodule-test-org3' Write-Verbose ($installations | Format-Table | Out-String) -Verbose $installations | Should -Not -BeNullOrEmpty } @@ -1150,8 +1150,8 @@ Describe 'As a GitHub App - Organization (APP_ORG)' { It 'Get-GitHubOrganization - Gets a specific organization (APP_ORG)' { { Get-GitHubOrganization -Organization 'psmodule-test-org' } | Should -Not -Throw } - It 'Get-GitHubOrganizationAppInstallation - Gets the GitHub App installations on the organization (APP_ORG)' { - $installations = Get-GitHubOrganizationAppInstallation -Organization 'psmodule-test-org' + It 'Get-GitHubAppInstallation - Gets the GitHub App installations on the organization (APP_ORG)' { + $installations = Get-GitHubAppInstallation -Organization 'psmodule-test-org' Write-Verbose ($installations | Format-Table | Out-String) -Verbose $installations | Should -Not -BeNullOrEmpty } From c28d6d9c8172f85097056114fea61be60d4d6a8b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 28 Jan 2025 11:46:04 +0100 Subject: [PATCH 13/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Update=20out?= =?UTF-8?q?put=20to=20return=20full=20API=20response=20instead=20of=20just?= =?UTF-8?q?=20installations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubEnterpriseOrganizationAppInstallation.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index 60f88d438..2d42fdf03 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -64,7 +64,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.installations + Write-Output $_.Response } } catch { throw $_ From bd345862963b3544f55a54a3eb07c55fef789f05 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 11:08:03 +0100 Subject: [PATCH 14/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Clean=20up?= =?UTF-8?q?=20parameter=20definitions=20and=20streamline=20API=20request?= =?UTF-8?q?=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Process-PSModule.yml | 4 ++-- .../Update-GitHubAppInstallationRepositoryAccess.ps1 | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index c0f82c2f3..bc8b830f0 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -36,5 +36,5 @@ jobs: TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} - # with: - # SkipTests: All + with: + SkipTests: All diff --git a/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 index e1ab1fa11..8aaf15497 100644 --- a/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 @@ -28,17 +28,11 @@ [CmdletBinding(SupportsShouldProcess)] param( # The enterprise slug or ID. - [Parameter( - Mandatory, - ValueFromPipelineByPropertyName - )] + [Parameter(ValueFromPipelineByPropertyName)] [string] $Enterprise, # The organization name. The name is not case sensitive. - [Parameter( - Mandatory, - ValueFromPipelineByPropertyName - )] + [Parameter(ValueFromPipelineByPropertyName)] [string] $Organization, # The unique identifier of the installation. @@ -90,6 +84,7 @@ repository_selection = $RepositorySelection repositories = $Repositories } + $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ Context = $Context From 3e906aac542c4e697945f285ba9901eaa17d1c35 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 11:57:17 +0100 Subject: [PATCH 15/71] Fix PerPage param --- src/functions/public/API/Invoke-GitHubAPI.ps1 | 8 ++++---- .../GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 | 2 +- .../GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 | 2 +- .../Get-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index 9f3ac0f34..9e9aed377 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -95,7 +95,7 @@ process { $Token = $Context.Token - Write-Debug "Token : [$Token]" + Write-Debug "Token : [$Token]" if ([string]::IsNullOrEmpty($HttpVersion)) { $HttpVersion = $Context.HttpVersion @@ -105,17 +105,17 @@ if ([string]::IsNullOrEmpty($ApiBaseUri)) { $ApiBaseUri = $Context.ApiBaseUri } - Write-Debug "ApiBaseUri: [$ApiBaseUri]" + Write-Debug "ApiBaseUri: [$ApiBaseUri]" if ([string]::IsNullOrEmpty($ApiVersion)) { $ApiVersion = $Context.ApiVersion } - Write-Debug "ApiVersion: [$ApiVersion]" + Write-Debug "ApiVersion: [$ApiVersion]" if ([string]::IsNullOrEmpty($TokenType)) { $TokenType = $Context.TokenType } - Write-Debug "TokenType : [$TokenType]" + Write-Debug "TokenType : [$TokenType]" switch ($TokenType) { 'ghu' { diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 index 16ae21187..4a8f3a5f3 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 @@ -66,7 +66,7 @@ process { try { $body = @{ - pre_page = $PerPage + per_page = $PerPage } $inputObject = @{ diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 index fd1578f43..69d1d6e32 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 @@ -43,7 +43,7 @@ process { try { $body = @{ - pre_page = $PerPage + per_page = $PerPage } $inputObject = @{ diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 index 991618e20..cf683ba0a 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 @@ -75,7 +75,7 @@ process { try { $body = @{ - pre_page = $PerPage + per_page = $PerPage } $inputObject = @{ From 106ac22f5a5bfe89c942836551db86c50050105d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 12:00:19 +0100 Subject: [PATCH 16/71] Fix get --- .../Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 index 4a8f3a5f3..01e4bb70b 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 @@ -72,7 +72,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" - Method = 'PATCH' + Method = 'GET' Body = $body } From 73cc337759ddce99a9e1fda0148bac1afcb12aee Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 14:00:05 +0100 Subject: [PATCH 17/71] Fix command for GetRepoAccess --- .../GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 index cf683ba0a..52f12fded 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 @@ -81,7 +81,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" - Method = 'PATCH' + Method = 'GET' Body = $body } From 581ec05bf59f86a542a33b0129a32c144d2d6159 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 16:57:08 +0100 Subject: [PATCH 18/71] Playing around with parallelism -> sequentialism :) --- .../public/Auth/Connect-GitHubApp.ps1 | 77 +++++++++---------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 96f0d73d0..836e2e1c1 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -41,25 +41,19 @@ [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The user account to connect to. - [Parameter( - Mandatory, - ParameterSetName = 'User' - )] - [string] $User, + [Parameter()] + [SupportsWildcards()] + [string[]] $User = '*', # The organization to connect to. - [Parameter( - Mandatory, - ParameterSetName = 'Organization' - )] - [string] $Organization, + [Parameter()] + [SupportsWildcards()] + [string[]] $Organization = '*', # The enterprise to connect to. - [Parameter( - Mandatory, - ParameterSetName = 'Enterprise' - )] - [string] $Enterprise, + [Parameter()] + [SupportsWildcards()] + [string[]] $Enterprise = '*', # Passes the context object to the pipeline. [Parameter()] @@ -86,38 +80,40 @@ $Context | Assert-GitHubContext -AuthType 'App' $installations = Get-GitHubAppInstallation -Context $Context + $selectedInstallations = @() Write-Verbose "Found [$($installations.Count)] installations." - switch ($PSCmdlet.ParameterSetName) { - 'User' { - Write-Verbose "Filtering installations for user [$User]." - $installations = $installations | Where-Object { $_.target_type -eq 'User' -and $_.account.login -in $User } - } - 'Organization' { - Write-Verbose "Filtering installations for organization [$Organization]." - $installations = $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -in $Organization } - } - 'Enterprise' { - Write-Verbose "Filtering installations for enterprise [$Enterprise]." - $installations = $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -in $Enterprise } - } + $User | ForEach-Object { + $userItem = $_ + Write-Verbose "Adding installation based on user [$userItem]." + $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'User' -and $_.account.login -like $userItem } + } + $Organization | ForEach-Object { + $organizationItem = $_ + Write-Verbose "Filtering installations for organization [$organizationItem]." + $installations = $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -in $organizationItem } + } + $Enterprise | ForEach-Object { + $enterpriseItem = $_ + Write-Verbose "Filtering installations for enterprise [$enterpriseItem]." + $installations = $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -in $enterpriseItem } } Write-Verbose "Found [$($installations.Count)] installations for the target." - $installations | ForEach-Object { + $installations | ForEach-Object -ThrottleLimit ([Environment]::ProcessorCount * 2) -Parallel { $installation = $_ Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" - $token = New-GitHubAppInstallationAccessToken -Context $Context -InstallationID $installation.id + $token = New-GitHubAppInstallationAccessToken -Context $using:Context -InstallationID $installation.id $contextParams = @{ AuthType = [string]'IAT' TokenType = [string]'ghs' - DisplayName = [string]$Context.DisplayName - ApiBaseUri = [string]$Context.ApiBaseUri - ApiVersion = [string]$Context.ApiVersion - HostName = [string]$Context.HostName - HttpVersion = [string]$Context.HttpVersion - PerPage = [int]$Context.PerPage - ClientID = [string]$Context.ClientID + DisplayName = [string]$using:Context.DisplayName + ApiBaseUri = [string]$using:Context.ApiBaseUri + ApiVersion = [string]$using:Context.ApiVersion + HostName = [string]$using:Context.HostName + HttpVersion = [string]$using:Context.HttpVersion + PerPage = [int]$using:Context.PerPage + ClientID = [string]$using:Context.ClientID InstallationID = [string]$installation.id Permissions = [pscustomobject]$installation.permissions Events = [string[]]$installation.events @@ -140,9 +136,9 @@ $contextParams['Enterprise'] = [string]$installation.account.slug } } - Write-Verbose 'Logging in using a managed installation access token...' - Write-Verbose ($contextParams | Format-Table | Out-String) - $contextObj = [InstallationGitHubContext]::new((Set-GitHubContext -Context $contextParams.Clone() -PassThru -Default:$Default)) + $contextParams + } | ForEach-Object { + $contextObj = [InstallationGitHubContext]::new((Set-GitHubContext -Context $_ -PassThru -Default:$Default)) Write-Verbose ($contextObj | Format-List | Out-String) if (-not $Silent) { $name = $contextObj.name @@ -153,7 +149,6 @@ Write-Debug "Passing context [$contextObj] to the pipeline." Write-Output $contextObj } - $contextParams.Clear() } } catch { Write-Error $_ From fdef7c5973fd868d84b2e7623c72c5b2d3c2c10a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 16:58:08 +0100 Subject: [PATCH 19/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Improve=20in?= =?UTF-8?q?stallation=20filtering=20and=20update=20verbose=20logging=20in?= =?UTF-8?q?=20Connect-GitHubApp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Auth/Connect-GitHubApp.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 836e2e1c1..4c6bf85a0 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -90,16 +90,16 @@ $Organization | ForEach-Object { $organizationItem = $_ Write-Verbose "Filtering installations for organization [$organizationItem]." - $installations = $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -in $organizationItem } + $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -in $organizationItem } } $Enterprise | ForEach-Object { $enterpriseItem = $_ Write-Verbose "Filtering installations for enterprise [$enterpriseItem]." - $installations = $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -in $enterpriseItem } + $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -in $enterpriseItem } } - Write-Verbose "Found [$($installations.Count)] installations for the target." - $installations | ForEach-Object -ThrottleLimit ([Environment]::ProcessorCount * 2) -Parallel { + Write-Verbose "Found [$($selectedInstallations.Count)] installations for the target." + $selectedInstallations | ForEach-Object -ThrottleLimit ([Environment]::ProcessorCount * 2) -Parallel { $installation = $_ Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" $token = New-GitHubAppInstallationAccessToken -Context $using:Context -InstallationID $installation.id From 2bd74b08f87a388c93fbffb8610bbc7822cc51ff Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 17:32:13 +0100 Subject: [PATCH 20/71] Fix parallelism --- src/functions/public/Auth/Connect-GitHubApp.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 4c6bf85a0..0e93ee9dd 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -90,16 +90,16 @@ $Organization | ForEach-Object { $organizationItem = $_ Write-Verbose "Filtering installations for organization [$organizationItem]." - $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -in $organizationItem } + $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -like $organizationItem } } $Enterprise | ForEach-Object { $enterpriseItem = $_ Write-Verbose "Filtering installations for enterprise [$enterpriseItem]." - $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -in $enterpriseItem } + $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem } } Write-Verbose "Found [$($selectedInstallations.Count)] installations for the target." - $selectedInstallations | ForEach-Object -ThrottleLimit ([Environment]::ProcessorCount * 2) -Parallel { + $contextParamObjects = $selectedInstallations | ForEach-Object -ThrottleLimit ([Environment]::ProcessorCount * 2) -Parallel { $installation = $_ Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" $token = New-GitHubAppInstallationAccessToken -Context $using:Context -InstallationID $installation.id @@ -137,7 +137,9 @@ } } $contextParams - } | ForEach-Object { + } + + $contextParamObjects | ForEach-Object { $contextObj = [InstallationGitHubContext]::new((Set-GitHubContext -Context $_ -PassThru -Default:$Default)) Write-Verbose ($contextObj | Format-List | Out-String) if (-not $Silent) { From b7a0a5932ff203b3653cbff998e6b431f1368234 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 19:10:10 +0100 Subject: [PATCH 21/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Enhance=20pa?= =?UTF-8?q?rameter=20handling=20and=20improve=20installation=20filtering?= =?UTF-8?q?=20in=20Connect-GitHubApp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/Auth/Connect-GitHubApp.ps1 | 83 +++++++++++-------- 1 file changed, 48 insertions(+), 35 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 0e93ee9dd..39012f801 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -41,19 +41,19 @@ [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The user account to connect to. - [Parameter()] + [Parameter(ParameterSetName = 'Filtered')] [SupportsWildcards()] - [string[]] $User = '*', + [string[]] $User, # The organization to connect to. - [Parameter()] + [Parameter(ParameterSetName = 'Filtered')] [SupportsWildcards()] - [string[]] $Organization = '*', + [string[]] $Organization, # The enterprise to connect to. - [Parameter()] + [Parameter(ParameterSetName = 'Filtered')] [SupportsWildcards()] - [string[]] $Enterprise = '*', + [string[]] $Enterprise, # Passes the context object to the pipeline. [Parameter()] @@ -82,38 +82,52 @@ $installations = Get-GitHubAppInstallation -Context $Context $selectedInstallations = @() Write-Verbose "Found [$($installations.Count)] installations." - $User | ForEach-Object { - $userItem = $_ - Write-Verbose "Adding installation based on user [$userItem]." - $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'User' -and $_.account.login -like $userItem } - } - $Organization | ForEach-Object { - $organizationItem = $_ - Write-Verbose "Filtering installations for organization [$organizationItem]." - $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -like $organizationItem } - } - $Enterprise | ForEach-Object { - $enterpriseItem = $_ - Write-Verbose "Filtering installations for enterprise [$enterpriseItem]." - $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem } + switch ($PSCmdlet.ParameterSetName) { + 'Filtered' { + $User | ForEach-Object { + $userItem = $_ + Write-Verbose "Adding installation based on user [$userItem]." + $selectedInstallations += $installations | Where-Object { + $_.target_type -eq 'User' -and $_.account.login -like $userItem + } + } + $Organization | ForEach-Object { + $organizationItem = $_ + Write-Verbose "Filtering installations for organization [$organizationItem]." + $selectedInstallations += $installations | Where-Object { + $_.target_type -eq 'Organization' -and $_.account.login -like $organizationItem + } + } + $Enterprise | ForEach-Object { + $enterpriseItem = $_ + Write-Verbose "Filtering installations for enterprise [$enterpriseItem]." + $selectedInstallations += $installations | Where-Object { + $_.target_type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem + } + } + } + default { + Write-Verbose 'No target specified. Connecting to all installations.' + $selectedInstallations = $installations + } } - Write-Verbose "Found [$($selectedInstallations.Count)] installations for the target." - $contextParamObjects = $selectedInstallations | ForEach-Object -ThrottleLimit ([Environment]::ProcessorCount * 2) -Parallel { + Write-Verbose "Found [$($installations.Count)] installations for the target." + $installations | ForEach-Object { $installation = $_ Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" - $token = New-GitHubAppInstallationAccessToken -Context $using:Context -InstallationID $installation.id + $token = New-GitHubAppInstallationAccessToken -Context $Context -InstallationID $installation.id $contextParams = @{ AuthType = [string]'IAT' TokenType = [string]'ghs' - DisplayName = [string]$using:Context.DisplayName - ApiBaseUri = [string]$using:Context.ApiBaseUri - ApiVersion = [string]$using:Context.ApiVersion - HostName = [string]$using:Context.HostName - HttpVersion = [string]$using:Context.HttpVersion - PerPage = [int]$using:Context.PerPage - ClientID = [string]$using:Context.ClientID + DisplayName = [string]$Context.DisplayName + ApiBaseUri = [string]$Context.ApiBaseUri + ApiVersion = [string]$Context.ApiVersion + HostName = [string]$Context.HostName + HttpVersion = [string]$Context.HttpVersion + PerPage = [int]$Context.PerPage + ClientID = [string]$Context.ClientID InstallationID = [string]$installation.id Permissions = [pscustomobject]$installation.permissions Events = [string[]]$installation.events @@ -136,11 +150,9 @@ $contextParams['Enterprise'] = [string]$installation.account.slug } } - $contextParams - } - - $contextParamObjects | ForEach-Object { - $contextObj = [InstallationGitHubContext]::new((Set-GitHubContext -Context $_ -PassThru -Default:$Default)) + Write-Verbose 'Logging in using a managed installation access token...' + Write-Verbose ($contextParams | Format-Table | Out-String) + $contextObj = [InstallationGitHubContext]::new((Set-GitHubContext -Context $contextParams.Clone() -PassThru -Default:$Default)) Write-Verbose ($contextObj | Format-List | Out-String) if (-not $Silent) { $name = $contextObj.name @@ -151,6 +163,7 @@ Write-Debug "Passing context [$contextObj] to the pipeline." Write-Output $contextObj } + $contextParams.Clear() } } catch { Write-Error $_ From eabbbbcd1b04d348920b82ce21fdb37c0ffd60be Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 19:44:25 +0100 Subject: [PATCH 22/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Update=20ver?= =?UTF-8?q?bose=20logging=20for=20user,=20organization,=20and=20enterprise?= =?UTF-8?q?=20filters=20in=20Connect-GitHubApp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Auth/Connect-GitHubApp.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 39012f801..cc3c94444 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -86,21 +86,21 @@ 'Filtered' { $User | ForEach-Object { $userItem = $_ - Write-Verbose "Adding installation based on user [$userItem]." + Write-Verbose "User filter: [$userItem]." $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'User' -and $_.account.login -like $userItem } } $Organization | ForEach-Object { $organizationItem = $_ - Write-Verbose "Filtering installations for organization [$organizationItem]." + Write-Verbose "Organization filter: [$organizationItem]." $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Organization' -and $_.account.login -like $organizationItem } } $Enterprise | ForEach-Object { $enterpriseItem = $_ - Write-Verbose "Filtering installations for enterprise [$enterpriseItem]." + Write-Verbose "Enterprise filter: [$enterpriseItem]." $selectedInstallations += $installations | Where-Object { $_.target_type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem } @@ -112,8 +112,8 @@ } } - Write-Verbose "Found [$($installations.Count)] installations for the target." - $installations | ForEach-Object { + Write-Verbose "Found [$($selectedInstallations.Count)] installations for the target." + $selectedInstallations | ForEach-Object { $installation = $_ Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" $token = New-GitHubAppInstallationAccessToken -Context $Context -InstallationID $installation.id From e78df97b67f0ef3c9628a26426e3456b7e789891 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 29 Jan 2025 22:40:26 +0100 Subject: [PATCH 23/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Add=20Silent?= =?UTF-8?q?=20parameter=20to=20suppress=20output=20in=20Connect-GitHubApp?= =?UTF-8?q?=20and=20Disconnect-GitHubAccount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Auth/Connect-GitHubApp.ps1 | 7 +++++++ src/functions/public/Auth/Disconnect-GitHubAccount.ps1 | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index cc3c94444..0596085f1 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -59,6 +59,13 @@ [Parameter()] [switch] $PassThru, + # Suppresses the output of the function. + [Parameter()] + [Alias('Quiet')] + [Alias('q')] + [Alias('s')] + [switch] $Silent, + # Set as the default context. [Parameter()] [switch] $Default, diff --git a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 index f66ff5372..d1c60a388 100644 --- a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 @@ -33,7 +33,7 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] [CmdletBinding()] param( - # Silently disconnects from GitHub. + # Suppresses the output of the function. [Parameter()] [Alias('Quiet')] [Alias('q')] From 7585b3c90f8791cf0ca0f491d8d5af8af70c5073 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Feb 2025 02:24:54 +0100 Subject: [PATCH 24/71] =?UTF-8?q?=F0=9F=AA=B2=20[Refactor]:=20Update=20mod?= =?UTF-8?q?ule=20requirements=20in=20various=20scripts=20for=20consistency?= =?UTF-8?q?=20and=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/Apps/AppManagement.ps1 | 4 +++- examples/Apps/EnterpriseApps.ps1 | 4 +++- examples/Connecting.ps1 | 5 ++++- examples/Teams/Get-AllTeams.ps1 | 1 - scripts/Update-CoverageReport.ps1 | 2 +- src/classes/public/Context/GitHubContext.ps1 | 2 +- .../private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 4 +++- src/functions/private/Config/Initialize-GitHubConfig.ps1 | 4 +++- .../Organization/Blocking/Block-GitHubUserByOrganization.ps1 | 1 - .../Blocking/Test-GitHubBlockedUserByOrganization.ps1 | 1 - src/functions/private/Teams/Get-GitHubRESTTeam.ps1 | 2 +- src/functions/private/Users/Get-GitHubAllUser.ps1 | 1 + src/functions/public/Actions/Data/Get-GitHubEventData.ps1 | 1 - src/functions/public/Actions/Data/Get-GitHubRunnerData.ps1 | 1 - src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 | 1 - .../public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 | 2 +- .../Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 | 1 - src/functions/public/Commands/Set-GitHubLogGroup.ps1 | 1 - src/functions/public/Config/Get-GitHubConfig.ps1 | 4 +--- src/functions/public/License/Get-GitHubLicense.ps1 | 4 +--- tests/GitHub.Tests.ps1 | 5 ++++- tools/utilities/GitHubAPI.ps1 | 3 +-- tools/utilities/Local-Testing.ps1 | 4 +++- tools/utilities/New-Function.ps1 | 3 +-- tools/utilities/StopWorkflowsCustom.ps1 | 2 -- 25 files changed, 32 insertions(+), 31 deletions(-) diff --git a/examples/Apps/AppManagement.ps1 b/examples/Apps/AppManagement.ps1 index de8a5c69e..1166429a2 100644 --- a/examples/Apps/AppManagement.ps1 +++ b/examples/Apps/AppManagement.ps1 @@ -1,4 +1,6 @@ -# Install an app on the entire enterprise +#Requires -Modules @{ ModuleName = 'GitHub'; RequiredVersion = '0.13.2' } + +# Install an app on the entire enterprise $appIDs = @( 'Iv1.f26b61bc99e69405' ) diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 index c41e8b007..3e56150a3 100644 --- a/examples/Apps/EnterpriseApps.ps1 +++ b/examples/Apps/EnterpriseApps.ps1 @@ -1,4 +1,6 @@ -$appIDs = @( +#Requires -Modules @{ ModuleName = 'GitHub'; RequiredVersion = '0.13.2' } + +$appIDs = @( 'qweqweqwe', 'qweqweqweqwe' ) diff --git a/examples/Connecting.ps1 b/examples/Connecting.ps1 index b687a282b..87b0c600c 100644 --- a/examples/Connecting.ps1 +++ b/examples/Connecting.ps1 @@ -1,4 +1,7 @@ -### +#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } +#Requires -Modules @{ ModuleName = 'Microsoft.PowerShell.SecretManagement'; RequiredVersion = '1.1.2' } + +### ### CONNECTING ### diff --git a/examples/Teams/Get-AllTeams.ps1 b/examples/Teams/Get-AllTeams.ps1 index 5f282702b..e69de29bb 100644 --- a/examples/Teams/Get-AllTeams.ps1 +++ b/examples/Teams/Get-AllTeams.ps1 @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/scripts/Update-CoverageReport.ps1 b/scripts/Update-CoverageReport.ps1 index ab0fd749d..c809cf743 100644 --- a/scripts/Update-CoverageReport.ps1 +++ b/scripts/Update-CoverageReport.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules MarkdownPS +#Requires -Modules @{ ModuleName = 'MarkdownPS'; RequiredVersion = '1.10' } [CmdletBinding()] param() diff --git a/src/classes/public/Context/GitHubContext.ps1 b/src/classes/public/Context/GitHubContext.ps1 index 232c2d21a..8d54ac1b9 100644 --- a/src/classes/public/Context/GitHubContext.ps1 +++ b/src/classes/public/Context/GitHubContext.ps1 @@ -1,4 +1,4 @@ -class GitHubContext { +class GitHubContext { # The context ID. [string] $ID diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index d78cfea46..03e377b3b 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -1,4 +1,6 @@ -function Update-GitHubUserAccessToken { +#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } + +function Update-GitHubUserAccessToken { <# .SYNOPSIS Updates the GitHub access token. diff --git a/src/functions/private/Config/Initialize-GitHubConfig.ps1 b/src/functions/private/Config/Initialize-GitHubConfig.ps1 index 5e51c0636..fce061650 100644 --- a/src/functions/private/Config/Initialize-GitHubConfig.ps1 +++ b/src/functions/private/Config/Initialize-GitHubConfig.ps1 @@ -1,4 +1,6 @@ -function Initialize-GitHubConfig { +#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } + +function Initialize-GitHubConfig { <# .SYNOPSIS Initialize the GitHub module configuration. diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 88045169f..52d47ce19 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -75,4 +75,3 @@ 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 337697fdf..cde0a4aa3 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -71,4 +71,3 @@ Write-Debug "[$stackPath] - End" } } - diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index f78369c67..63bb92ab6 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -64,7 +64,7 @@ } switch ($PSCmdlet.ParameterSetName) { 'GetByName' { - Get-GitHubTeamByName @params -Name $Name + Get-GitHubRESTTeamByName @params -Name $Name } '__AllParameterSets' { Get-GitHubTeamListByOrg @params diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 1a456bfe6..5da582bfc 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -18,6 +18,7 @@ .NOTES https://docs.github.com/rest/users/users#list-users #> + [Alias('Get-GitHubAllUsers')] [OutputType([pscustomobject])] [CmdletBinding()] param( diff --git a/src/functions/public/Actions/Data/Get-GitHubEventData.ps1 b/src/functions/public/Actions/Data/Get-GitHubEventData.ps1 index 3bce149bd..d057b864b 100644 --- a/src/functions/public/Actions/Data/Get-GitHubEventData.ps1 +++ b/src/functions/public/Actions/Data/Get-GitHubEventData.ps1 @@ -26,4 +26,3 @@ Write-Debug "[$stackPath] - End" } } - diff --git a/src/functions/public/Actions/Data/Get-GitHubRunnerData.ps1 b/src/functions/public/Actions/Data/Get-GitHubRunnerData.ps1 index af6cfbf9d..5a61023b5 100644 --- a/src/functions/public/Actions/Data/Get-GitHubRunnerData.ps1 +++ b/src/functions/public/Actions/Data/Get-GitHubRunnerData.ps1 @@ -26,4 +26,3 @@ Write-Debug "[$stackPath] - End" } } - diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 index f77eb9b12..0e91cdf47 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 @@ -74,4 +74,3 @@ Write-Debug "[$stackPath] - End" } } - diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 index 60aa43ebe..b9057fee1 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 +++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubAppJSONWebToken { +function Get-GitHubAppJSONWebToken { <# .SYNOPSIS Generates a JSON Web Token (JWT) for a GitHub App. diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 index 94c3b3f16..36a02d756 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 @@ -53,4 +53,3 @@ Write-Debug "[$stackPath] - End" } } - diff --git a/src/functions/public/Commands/Set-GitHubLogGroup.ps1 b/src/functions/public/Commands/Set-GitHubLogGroup.ps1 index 5ac4e0845..7a08b63a9 100644 --- a/src/functions/public/Commands/Set-GitHubLogGroup.ps1 +++ b/src/functions/public/Commands/Set-GitHubLogGroup.ps1 @@ -51,5 +51,4 @@ throw $_ } Write-Host '::endgroup::' - } diff --git a/src/functions/public/Config/Get-GitHubConfig.ps1 b/src/functions/public/Config/Get-GitHubConfig.ps1 index 545c3aa94..42633f786 100644 --- a/src/functions/public/Config/Get-GitHubConfig.ps1 +++ b/src/functions/public/Config/Get-GitHubConfig.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } - -function Get-GitHubConfig { +function Get-GitHubConfig { <# .SYNOPSIS Get a GitHub module configuration. diff --git a/src/functions/public/License/Get-GitHubLicense.ps1 b/src/functions/public/License/Get-GitHubLicense.ps1 index 7f5953a61..8ec620b6a 100644 --- a/src/functions/public/License/Get-GitHubLicense.ps1 +++ b/src/functions/public/License/Get-GitHubLicense.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } - -filter Get-GitHubLicense { +filter Get-GitHubLicense { <# .SYNOPSIS Get a license template, list of all popular license templates or a license for a repository diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 164c0198b..5ece25162 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -1,4 +1,7 @@ -[Diagnostics.CodeAnalysis.SuppressMessageAttribute( +#Requires -Modules @{ ModuleName = 'Microsoft.PowerShell.SecretManagement'; RequiredVersion = '1.1.2' } +#Requires -Modules @{ ModuleName = 'Pester'; RequiredVersion = '5.7.1' } + +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Pester grouping syntax: known issue.' )] diff --git a/tools/utilities/GitHubAPI.ps1 b/tools/utilities/GitHubAPI.ps1 index bff1706b6..820c3ce40 100644 --- a/tools/utilities/GitHubAPI.ps1 +++ b/tools/utilities/GitHubAPI.ps1 @@ -1,4 +1,4 @@ -# https://github.com/github/rest-api-description +# https://github.com/github/rest-api-description $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' @@ -94,4 +94,3 @@ $schema.title $schema.properties.action.enum $schema.required - diff --git a/tools/utilities/Local-Testing.ps1 b/tools/utilities/Local-Testing.ps1 index d5eab535e..fbdbf708a 100644 --- a/tools/utilities/Local-Testing.ps1 +++ b/tools/utilities/Local-Testing.ps1 @@ -1,4 +1,6 @@ -##### +#Requires -Modules @{ ModuleName = 'Microsoft.PowerShell.SecretManagement'; RequiredVersion = '1.1.2' } + +##### Get-Module -Name GitHub -ListAvailable Get-Module -Name GitHub* -ListAvailable | Remove-Module -Force Get-Module -Name GitHub* -ListAvailable | Uninstall-Module -Force -AllVersions diff --git a/tools/utilities/New-Function.ps1 b/tools/utilities/New-Function.ps1 index e7a79fde3..8c1955e05 100644 --- a/tools/utilities/New-Function.ps1 +++ b/tools/utilities/New-Function.ps1 @@ -1,5 +1,4 @@ - -function New-Function { +function New-Function { <# .SYNOPSIS Short description diff --git a/tools/utilities/StopWorkflowsCustom.ps1 b/tools/utilities/StopWorkflowsCustom.ps1 index ea7c787e3..599655573 100644 --- a/tools/utilities/StopWorkflowsCustom.ps1 +++ b/tools/utilities/StopWorkflowsCustom.ps1 @@ -30,8 +30,6 @@ Get-GitHubWorkflow | Disable-GitHubWorkflow # Cancel all started workflows Get-GitHubWorkflowRun | Where-Object status -NE completed | Stop-GitHubWorkflowRun -Get-GitHubRepoTeams - (Get-GitHubWorkflow).count From 3342b10e62aa5a8c6bcfaf744c28ddd12e82faf4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 21:33:34 +0100 Subject: [PATCH 25/71] =?UTF-8?q?=F0=9F=93=9D=20[Documentation]:=20Add=20g?= =?UTF-8?q?uidelines=20for=20function=20and=20parameter=20naming=20convent?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/Guidelines.md | 103 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 tools/Guidelines.md diff --git a/tools/Guidelines.md b/tools/Guidelines.md new file mode 100644 index 000000000..9ed1ad2bc --- /dev/null +++ b/tools/Guidelines.md @@ -0,0 +1,103 @@ +# Guidelines + +Writing down guidelines so that it can be the basis for pester tests. + +## Functions + +- Group functions by the object type they are working with in a folder based on the name of the object, NOT based on the API. + +### Name + +- Verb-GitHubNoun - based on what object type they are working with. Let parameters dictate the scope of the function. + +#### Name - Public functions + +#### Name - Private functions + +- No aliases + +### Documentation + +#### SYNOPSIS + +#### DESCRIPTION + +#### EXAMPLES + +- PSModule framework removes the default fencing. So, we need to add the fencing back in the examples where we see fit. + +#### PARAMETERS + +- Parameter docs do not go in the comment block. They are in the `param` block above each parameter. + Principle: Keep documentation close to the code it documents. + +#### NOTES + +- Have a link to the documentation with the display name of the official documentation. This is so that when user search on the online +function documentation they can search based on the official documentation. + +#### LINK + +- First link is to the function documentation that is generated for the PowerShell module. +- Other links can be to the official documentation. + +### Parameters + +- Parameters use the PascalCase version of the parameter name in the official documentation. + +#### Parameters - public functions + +- `Context` parameter supports `string` and `GitHubContext`. -> This is why we have `Resolve-GitHubContext` in the public functions. +- Evaluation of default values for other scoping parameters happen in `process` block. +- `Owner` always have `User` and `Organization` as aliases +- `Repository` is always spelled out. +- `ID` when needed, should be the short form, but have the long form as an alias supporting both lower_snake_case and PascalCase. + +#### Parameters - private functions + +- No aliases +- `Context` parameter is `GitHubContext`. Calling function should have resolved the context to a `GitHubContext` object already. + +### Content + +- Use begin, process, end and optionally clean blocks. +- begin block is for parameter validation and setup. +- process block is for the main logic. This should also have a foreach loop for pipelining. +- All context defaults must be evaluated in the process block. +- One API call = one function +- API parameters are always splatted + - The name of the splat is `$inputObject` + - The order of the splat is: + - `Method` + - `APIEndpoint` + - `Body` + - `Context` +- API Body is always a hashtable + +- If function calls `Invoke-GitHubAPI`, `Invoke-RestMethod` or `Invoke-WebRequest` that requires a `Context` parameter: + - Function must also have `Assert-GitHubContext` in begin block. + - Add a comment below `Assert-GitHubContext` stating the permissions needed for the API call. + +### Content - Public + +- If Public function + - Resolve-GitHubContext + + +### Content - Private + +- Pipelining is not supported + +#### Parameters + + + + + + + +## Classes + +- One class pr type of resource +- Properties are PascalCased (as expected by PowerShell users) + From 8276211857721b354657b13bfcfc568ed1d0e623 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 21:34:30 +0100 Subject: [PATCH 26/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20parame?= =?UTF-8?q?ter=20name=20from=20`TokenType`=20to=20`AuthType`=20in=20`Asser?= =?UTF-8?q?t-GitHubContext`=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../private/Auth/Context/Assert-GitHubContext.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 index d54844545..977b77c50 100644 --- a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 @@ -8,7 +8,7 @@ If the context does not meet the requirements, an error is thrown. .EXAMPLE - Assert-GitHubContext -Context 'github.com/Octocat' -TokenType 'App' + Assert-GitHubContext -Context 'github.com/Octocat' -AuthType 'App' #> [OutputType([void])] [CmdletBinding()] @@ -18,11 +18,15 @@ Mandatory, ValueFromPipeline )] - [object] $Context, + [GitHubContext] $Context, # The required authtypes for the command. [Parameter(Mandatory)] [string[]] $AuthType + + # # The required permission for the command. + # [Parameter()] + # [string] $Permission ) begin { @@ -36,6 +40,9 @@ if ($Context.AuthType -notin $AuthType) { throw "The context '$($Context.Name)' does not match the required AuthTypes [$AuthType] for [$command]." } + # if ($Context.AuthType -in 'IAT' -and $Context.Permission -notin $Permission) { + # throw "The context '$($Context.Name)' does not match the required Permission [$Permission] for [$command]." + # } } end { From 85ab67ea09330e0c889e288295c0918468a43a1e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 21:38:49 +0100 Subject: [PATCH 27/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Rename=20act?= =?UTF-8?q?ion=20scripts=20and=20update=20parameter=20names=20for=20consis?= =?UTF-8?q?tency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubWorkflowRun.ps1 | 77 +++++++++---------- .../Remove-GitHubWorkflowRun.ps1 | 47 +++++------ .../Restart-GitHubWorkflowRun.ps1} | 16 +++- .../Stop-GitHubWorkflowRun.ps1 | 31 ++++---- .../{ => Workflow}/Disable-GitHubWorkflow.ps1 | 41 +++++----- .../{ => Workflow}/Enable-GitHubWorkflow.ps1 | 43 +++++------ .../{ => Workflow}/Get-GitHubWorkflow.ps1 | 51 ++++++------ .../Get-GitHubWorkflowUsage.ps1 | 46 +++++------ .../{ => Workflow}/Start-GitHubWorkflow.ps1 | 55 ++++++------- 9 files changed, 190 insertions(+), 217 deletions(-) rename src/functions/public/Actions/{ => Workflow Run}/Get-GitHubWorkflowRun.ps1 (79%) rename src/functions/public/Actions/{ => Workflow Run}/Remove-GitHubWorkflowRun.ps1 (67%) rename src/functions/public/Actions/{Start-GitHubWorkflowReRun.ps1 => Workflow Run/Restart-GitHubWorkflowRun.ps1} (87%) rename src/functions/public/Actions/{ => Workflow Run}/Stop-GitHubWorkflowRun.ps1 (76%) rename src/functions/public/Actions/{ => Workflow}/Disable-GitHubWorkflow.ps1 (65%) rename src/functions/public/Actions/{ => Workflow}/Enable-GitHubWorkflow.ps1 (59%) rename src/functions/public/Actions/{ => Workflow}/Get-GitHubWorkflow.ps1 (66%) rename src/functions/public/Actions/{ => Workflow}/Get-GitHubWorkflowUsage.ps1 (58%) rename src/functions/public/Actions/{ => Workflow}/Start-GitHubWorkflow.ps1 (68%) diff --git a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 similarity index 79% rename from src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 rename to src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 index 9635676f7..61dfe752f 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 @@ -36,18 +36,26 @@ [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 = '__AllParameterSets')] + [CmdletBinding()] [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)] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository. The name is not case sensitive. - [Parameter(Mandatory)] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The ID of the workflow. You can also pass the workflow filename as a string. [Parameter( @@ -119,50 +127,37 @@ 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 { - $params = @{ - Owner = $Owner - Repo = $Repo - Actor = $Actor - Branch = $Branch - Event = $Event - Status = $Status - Created = $Created - ExcludePullRequests = $ExcludePullRequests - CheckSuiteID = $CheckSuiteID - HeadSHA = $HeadSHA - PerPage = $PerPage - } + $params = @{ + Owner = $Owner + Repo = $Repo + Actor = $Actor + Branch = $Branch + Event = $Event + Status = $Status + Created = $Created + ExcludePullRequests = $ExcludePullRequests + CheckSuiteID = $CheckSuiteID + HeadSHA = $HeadSHA + PerPage = $PerPage + } - switch ($PSCmdlet.ParameterSetName) { - 'ByID' { - $params['ID'] = $ID - Get-GitHubWorkflowRunByWorkflow @params - } + switch ($PSCmdlet.ParameterSetName) { + 'ByID' { + $params['ID'] = $ID + Get-GitHubWorkflowRunByWorkflow @params + } - 'ByName' { - $params['ID'] = (Get-GitHubWorkflow -Owner $Owner -Repo $Repo -Name $Name).id - Get-GitHubWorkflowRunByWorkflow @params - } + 'ByName' { + $params['ID'] = (Get-GitHubWorkflow -Owner $Owner -Repo $Repository -Name $Name).id + Get-GitHubWorkflowRunByWorkflow @params + } - '__AllParameterSets' { - Get-GitHubWorkflowRunByRepo @params - } + default { + Get-GitHubWorkflowRunByRepo @params } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 similarity index 67% rename from src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 rename to src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 index 6aaf7c2b4..809f34c9d 100644 --- a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 @@ -19,20 +19,28 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The unique identifier of the workflow run. [Parameter( Mandatory, ValueFromPipelineByPropertyName )] - [Alias('ID', 'run_id')] - [string] $RunID, + [Alias('run_id', 'RunID')] + [string] $ID, # 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. @@ -45,32 +53,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "repos/$Owner/$Repo/actions/runs/$RunID" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'DELETE' + APIEndpoint = "repos/$Owner/$Repository/actions/runs/$ID" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("workflow run with ID [$RunID] in [$Owner/$Repo]", 'Delete')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Delete workflow run')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 similarity index 87% rename from src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 rename to src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 index da3647fdb..b1603a091 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 @@ -1,4 +1,4 @@ -filter Start-GitHubWorkflowReRun { +filter Restart-GitHubWorkflowRun { <# .SYNOPSIS Re-run a workflow @@ -15,12 +15,20 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The unique identifier of the workflow run. [Alias('workflow_id')] diff --git a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 similarity index 76% rename from src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 rename to src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 index cb924bdb5..f0f3283f4 100644 --- a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 @@ -17,13 +17,21 @@ [CmdletBinding(SupportsShouldProcess)] [alias('Cancel-GitHubWorkflowRun')] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, - [Alias('workflow_id')] + [Alias('workflow_id', 'WorkflowID')] [Parameter( Mandatory, ValueFromPipelineByPropertyName @@ -41,26 +49,17 @@ 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 { $inputObject = @{ - Context = $Context Method = 'POST' - APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/cancel" + APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/cancel" + Context = $Context } - if ($PSCmdlet.ShouldProcess("workflow run with ID [$ID] in [$Owner/$Repo]", 'Cancel/Stop')) { + if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Cancel/Stop workflow run')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 similarity index 65% rename from src/functions/public/Actions/Disable-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 index 45e40bf45..0b5070875 100644 --- a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 @@ -3,15 +3,23 @@ .NOTES [Disable a workflow](https://docs.github.com/en/rest/actions/workflows#disable-a-workflow) #> - [CmdletBinding()] + [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The ID of the workflow. You can also pass the workflow filename as a string. [Parameter( @@ -31,28 +39,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/disable" - Method = 'PUT' - } + $inputObject = @{ + Method = 'PUT' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/disable" + Context = $Context + } - $null = Invoke-GitHubAPI @inputObject - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Disable workflow')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 similarity index 59% rename from src/functions/public/Actions/Enable-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 index 4170d0f2b..26fe8df5d 100644 --- a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 @@ -3,13 +3,21 @@ .NOTES [Enable a workflow](https://docs.github.com/en/rest/actions/workflows#enable-a-workflow) #> - [CmdletBinding()] + [CmdletBinding(SupportsShouldProcess)] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, [Parameter( Mandatory, @@ -28,28 +36,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/enable" - Method = 'PUT' - } - - $null = Invoke-GitHubAPI @inputObject - } catch { - throw $_ + $inputObject = @{ + Method = 'PUT' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/enable" + Context = $Context + } + + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Enable workflow')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 similarity index 66% rename from src/functions/public/Actions/Get-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 index 49f98113a..b925cf5b6 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 @@ -21,13 +21,21 @@ .NOTES [List repository workflows](https://docs.github.com/rest/actions/workflows?apiVersion=2022-11-28#list-repository-workflows) #> - [CmdletBinding(DefaultParameterSetName = 'ByName')] + [CmdletBinding()] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -45,35 +53,22 @@ 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.workflows - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 similarity index 58% rename from src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 rename to src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 index 22179722e..9fdcf09aa 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 @@ -12,15 +12,21 @@ .NOTES [Get workflow usage](https://docs.github.com/en/rest/actions/workflows#get-workflow-usage) #> - [CmdletBinding( - DefaultParameterSetName = 'ByName' - )] + [CmdletBinding()] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, [Parameter( Mandatory, @@ -39,31 +45,17 @@ 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 { - - $inputObject = @{ - Context = $Context - Method = 'GET' - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/timing" - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/timing" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.billable - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 similarity index 68% rename from src/functions/public/Actions/Start-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 index 5d1bd4020..5493adca6 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 @@ -20,15 +20,23 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The ID of the workflow. - [Alias('workflow_id')] + [Alias('workflow_id', 'WorkflowID')] [Parameter( Mandatory, ValueFromPipelineByPropertyName @@ -57,38 +65,25 @@ 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 = @{ - 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/$Repository/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("$Owner/$Repo/$ID", 'Start workflow')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } From 06e5877f2725b6a766962a7b0385f67f4d64ecd4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 21:44:31 +0100 Subject: [PATCH 28/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Rename=20Git?= =?UTF-8?q?Hub=20Apps=20scripts=20and=20update=20parameter=20names=20for?= =?UTF-8?q?=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubApp.ps1 | 18 ++------- .../Get-GitHubAppInstallableOrganization.ps1 | 38 ++++++++----------- .../Get-GitHubAppJSONWebToken.ps1 | 0 .../Install-GitHubApp.ps1 | 37 +++++++----------- .../Uninstall-GitHubApp.ps1 | 31 +++++---------- tools/Guidelines.md | 2 + 6 files changed, 44 insertions(+), 82 deletions(-) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Get-GitHubApp.ps1 (79%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Get-GitHubAppInstallableOrganization.ps1 (58%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Get-GitHubAppJSONWebToken.ps1 (100%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Install-GitHubApp.ps1 (69%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Uninstall-GitHubApp.ps1 (64%) diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 similarity index 79% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 rename to src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 index 0e91cdf47..16a1d51c4 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 @@ -21,7 +21,7 @@ [Get the authenticated app | GitHub Docs](https://docs.github.com/rest/apps/apps#get-the-authenticated-app) #> [OutputType([pscustomobject])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The AppSlug is just the URL-friendly name of a GitHub App. # You can find this on the settings page for your GitHub App (e.g., ). @@ -30,8 +30,8 @@ Mandatory, ParameterSetName = 'BySlug' )] - [Alias('Name')] - [string] $AppSlug, + [Alias('AppSlug')] + [string] $Name, # 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. @@ -43,23 +43,13 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context - - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - 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 + Get-GitHubAppByName -AppSlug $Name -Context $Context } default { Get-GitHubAuthenticatedApp -Context $Context diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 similarity index 58% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 rename to src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 index 69d1d6e32..a8a9b4f28 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 @@ -6,8 +6,9 @@ .DESCRIPTION List of organizations owned by the enterprise on which the authenticated GitHub App installation may install other GitHub Apps. - The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/enterprise_organization_installations - (read) permission. + .NOTES + Permissions required: + - enterprise_organization_installations: read .EXAMPLE Get-GitHubAppInstallableOrganization -Enterprise 'msx' @@ -33,31 +34,24 @@ $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]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + # enterprise_organization_installations=read } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubAppJSONWebToken.ps1 similarity index 100% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 rename to src/functions/public/Apps/GitHub App/Get-GitHubAppJSONWebToken.ps1 diff --git a/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 similarity index 69% rename from src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 rename to src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 index 93f5e5f53..6ff054ae7 100644 --- a/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 @@ -23,7 +23,7 @@ - the repository selection 'all' on the organization 'org' in the enterprise 'msx'. #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -66,34 +66,23 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context - Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installations=write } process { - if ([string]::IsNullOrEmpty($Enterprise)) { - $Enterprise = $Context.Enterprise - } - Write-Debug "Enterprise: [$Enterprise]" - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization: [$Organization]" - try { - switch ($PSCmdlet.ParameterSetName) { - 'EnterpriseOrganization' { - $params = @{ - Enterprise = $Enterprise - Organization = $Organization - ClientID = $ClientID - RepositorySelection = $RepositorySelection - Repositories = $Repositories - Context = $Context - } - Install-GitHubAppOnEnterpriseOrganization @params + switch ($PSCmdlet.ParameterSetName) { + 'EnterpriseOrganization' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + ClientID = $ClientID + RepositorySelection = $RepositorySelection + Repositories = $Repositories + Context = $Context } + Install-GitHubAppOnEnterpriseOrganization @params } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 similarity index 64% rename from src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 rename to src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 index fd487b598..48bc964f1 100644 --- a/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 @@ -11,7 +11,7 @@ Uninstall the GitHub App with the installation ID '123456' from the organization 'org' in the enterprise 'msx'. #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -47,32 +47,19 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context - Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } process { - if ([string]::IsNullOrEmpty($Enterprise)) { - $Enterprise = $Context.Enterprise - } - Write-Debug "Enterprise: [$Enterprise]" - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization: [$Organization]" - try { - switch ($PSCmdlet.ParameterSetName) { - 'EnterpriseOrganization' { - $params = @{ - Enterprise = $Enterprise - Organization = $Organization - ID = $ID - Context = $Context - } - Uninstall-GitHubAppOnEnterpriseOrganization @params + switch ($PSCmdlet.ParameterSetName) { + 'EnterpriseOrganization' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + ID = $ID + Context = $Context } + Uninstall-GitHubAppOnEnterpriseOrganization @params } - } catch { - throw $_ } } diff --git a/tools/Guidelines.md b/tools/Guidelines.md index 9ed1ad2bc..9b37c43e5 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -83,6 +83,8 @@ function documentation they can search based on the official documentation. - If Public function - Resolve-GitHubContext +- To select underlying private functions use parameter sets, in a swticth statement. + - Use the `default` block to cover the default parameter set `__AllParameterSets`. ### Content - Private From 711ee578e4c45df40555aab68c930391be074831 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:40:18 +0100 Subject: [PATCH 29/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Simplify=20A?= =?UTF-8?q?PI=20call=20structures=20and=20improve=20parameter=20handling?= =?UTF-8?q?=20in=20GitHub=20App=20webhook=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-GitHubAppInstallationRepositoryAccess.ps1 | 42 +++++--------- .../Get-GitHubAppAccessibleRepository.ps1 | 41 +++++--------- .../Get-GitHubAppInstallation.ps1 | 42 +++++++------- ...-GitHubAppInstallationRepositoryAccess.ps1 | 44 +++++---------- ...-GitHubAppInstallationRepositoryAccess.ps1 | 42 +++++--------- ...-GitHubAppInstallationRepositoryAccess.ps1 | 55 ++++++++----------- .../New-GitHubAppInstallationAccessToken.ps1 | 30 ++++------ .../Get-GitHubAppWebhookConfiguration.ps1 | 20 +++---- .../Webhooks/Get-GitHubAppWebhookDelivery.ps1 | 27 ++++----- .../Invoke-GitHubAppWebhookReDelivery.ps1 | 22 +++----- .../Update-GitHubAppWebhookConfiguration.ps1 | 37 ++++++------- 11 files changed, 156 insertions(+), 246 deletions(-) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Add-GitHubAppInstallationRepositoryAccess.ps1 (67%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Get-GitHubAppAccessibleRepository.ps1 (65%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Get-GitHubAppInstallation.ps1 (65%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Get-GitHubAppInstallationRepositoryAccess.ps1 (67%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Remove-GitHubAppInstallationRepositoryAccess.ps1 (67%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Update-GitHubAppInstallationRepositoryAccess.ps1 (68%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/New-GitHubAppInstallationAccessToken.ps1 (85%) diff --git a/src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 similarity index 67% rename from src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 index 499989e9a..c15db0c18 100644 --- a/src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 @@ -57,39 +57,27 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=write + #enterprise_organization_installations=write } process { - try { - $body = @{ - repositories = $Repositories - } + $body = @{ + repositories = $Repositories + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/add" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'PATCH' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/add" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Enterprise/$Organization", 'Add repo access to installation')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - Write-Debug "Error: $_" } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 similarity index 65% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 rename to src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 index 01e4bb70b..3f5d442ac 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 @@ -50,39 +50,24 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + # Enterprise organization installations (read) } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - Write-Debug "Error: $_" + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 similarity index 65% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 rename to src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 index e493a4f37..2d0a881fd 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 @@ -8,7 +8,7 @@ If the app is installed on an enterprise, the installations for the enterprise are returned. If the app is installed on an organization, the installations for the organization are returned. #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -54,31 +54,27 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'Enterprise' { - $params = @{ - Enterprise = $Enterprise - Organization = $Organization - PerPage = $PerPage - Context = $Context - } - Get-GitHubEnterpriseOrganizationAppInstallation @params + switch ($PSCmdlet.ParameterSetName) { + 'Enterprise' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + PerPage = $PerPage + Context = $Context } - 'Organization' { - $params = @{ - Organization = $Organization - PerPage = $PerPage - Context = $Context - } - Get-GitHubOrganizationAppInstallation @params - } - '__AllParameterSets' { - Get-GitHubAppInstallationForAuthenticatedApp -Context $Context + Get-GitHubEnterpriseOrganizationAppInstallation @params + } + 'Organization' { + $params = @{ + Organization = $Organization + PerPage = $PerPage + Context = $Context } + Get-GitHubOrganizationAppInstallation @params + } + default { + Get-GitHubAppInstallationForAuthenticatedApp -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 similarity index 67% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 index 52f12fded..ffdb353de 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 @@ -19,7 +19,7 @@ Get the repositories accessible to the GitHub App installation with the ID '12345678' on the organization 'PSModule' in the enterprise 'msx'. #> - [CmdletBinding(SupportsShouldProcess)] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -59,39 +59,25 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=read + #enterprise_organization_installations=read } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - Write-Debug "Error: $_" + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 similarity index 67% rename from src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 index eb5eaea0c..e6934724c 100644 --- a/src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 @@ -57,39 +57,27 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=write + #enterprise_organization_installations=write } process { - try { - $body = @{ - repositories = $Repositories - } + $body = @{ + repositories = $Repositories + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/remove" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'PATCH' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/remove" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Enterprise/$Organization - $Repositories", 'Remove repository access')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - Write-Debug "Error: $_" } } diff --git a/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 similarity index 68% rename from src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 index 8aaf15497..309a890b1 100644 --- a/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 @@ -28,11 +28,16 @@ [CmdletBinding(SupportsShouldProcess)] param( # The enterprise slug or ID. - [Parameter(ValueFromPipelineByPropertyName)] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] [string] $Enterprise, # The organization name. The name is not case sensitive. - [Parameter(ValueFromPipelineByPropertyName)] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName)] [string] $Organization, # The unique identifier of the installation. @@ -65,41 +70,29 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=write + #enterprise_organization_installations=write } process { - try { - $body = @{ - repository_selection = $RepositorySelection - repositories = $Repositories - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + repository_selection = $RepositorySelection + repositories = $Repositories + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'PATCH' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Enterprise/$Organization", 'Update repository access')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - Write-Debug "Error: $_" } } diff --git a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 similarity index 85% rename from src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 rename to src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 index f7e545a93..4ceac55bc 100644 --- a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 +++ b/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 @@ -73,31 +73,23 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/app/installations/$ID/access_tokens" - Method = 'Post' - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/app/installations/$ID/access_tokens" + Context = $Context + } - 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 - } + 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 36a02d756..9b4441214 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 @@ -34,18 +34,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/hook/config' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'GET' + APIEndpoint = '/app/hook/config' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 index 0208f92c3..3d9cdfe39 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 @@ -31,7 +31,7 @@ Mandatory, ParameterSetName = 'ByID' )] - [Alias('DeliveryID', 'delivery_id')] + [Alias('delivery_id', 'DeliveryID')] [string] $ID, # Only the ones to redeliver. @@ -64,23 +64,16 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'ByID' { - Write-Debug "ByID: [$ID]" - Get-GitHubAppWebhookDeliveryByID -ID $ID -Context $Context - } - 'Redelivery' { - Write-Debug "Redelivery: [$NeedingRedelivery]" - Get-GitHubAppWebhookDeliveryToRedeliver -Context $Context -PerPage $PerPage -TimeSpan $TimeSpan - } - 'ByList' { - Write-Debug 'ByList' - Get-GitHubAppWebhookDeliveryByList -Context $Context -PerPage $PerPage - } + switch ($PSCmdlet.ParameterSetName) { + 'ByID' { + Get-GitHubAppWebhookDeliveryByID -ID $ID -Context $Context + } + 'Redelivery' { + Get-GitHubAppWebhookDeliveryToRedeliver -Context $Context -PerPage $PerPage -TimeSpan $TimeSpan + } + default { + Get-GitHubAppWebhookDeliveryByList -Context $Context -PerPage $PerPage } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 index 7808e2af3..f902c6e07 100644 --- a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 @@ -27,7 +27,7 @@ param( # The ID of the delivery. [Parameter(Mandatory)] - [Alias('DeliveryID', 'delivery_id')] + [Alias('delivery_id', 'DeliveryID')] [string] $ID, # The context to run the command in. Used to get the details for the API call. @@ -44,20 +44,16 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/app/hook/deliveries/$ID/attempts" - Method = 'post' - } + $inputObject = @{ + Method = 'Post' + Context = $Context + APIEndpoint = "/app/hook/deliveries/$ID/attempts" + } - if ($PSCmdlet.ShouldProcess('webhook delivery', 'Redeliver')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("[$ID]", 'Redeliver event')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 index 734027fd6..931bc777f 100644 --- a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 @@ -37,6 +37,7 @@ # Determines whether the SSL certificate of the host for URL will be verified when delivering payloads. # We strongly recommend not setting this as you are subject to man-in-the-middle and other attacks. + [Parameter()] [switch] $InsecureSSL, # The context to run the command in. Used to get the details for the API call. @@ -53,29 +54,25 @@ } process { - try { - $body = @{ - url = $URL - content_type = $ContentType - secret = $Secret - insecure_ssl = $PSBoundParameters.ContainsKey($InsecureSSL) ? ($InsecureSSL ? 1 : 0) : $null - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + url = $URL + content_type = $ContentType + secret = $Secret + insecure_ssl = $PSBoundParameters.ContainsKey($InsecureSSL) ? ($InsecureSSL ? 1 : 0) : $null + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/hook/config' - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'PATCH' + APIEndpoint = '/app/hook/config' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('webhook configuration', 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess('webhook configuration', 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } From ce3273fcac2692fa287b28fba12a98e0249c16fe Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:40:52 +0100 Subject: [PATCH 30/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20par?= =?UTF-8?q?ameter=20type=20for=20`$Context`=20to=20`GitHubContext`=20and?= =?UTF-8?q?=20streamline=20API=20call=20structures=20in=20workflow=20funct?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Actions/Get-GitHubWorkflowRunByRepo.ps1 | 55 ++++++-------- .../Get-GitHubWorkflowRunByWorkflow.ps1 | 55 ++++++-------- .../Actions/Import-GitHubEventData.ps1 | 74 +++++++++---------- .../Actions/Import-GitHubRunnerData.ps1 | 26 +++---- 4 files changed, 88 insertions(+), 122 deletions(-) diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 index 98a0fe01e..762ab6814 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 @@ -84,50 +84,37 @@ # 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 + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + } + + process { + $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 } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/repos/$Owner/$Repo/actions/runs" + Body = $body + Context = $Context } - 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 $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.workflow_runs } } diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 index b76e45b85..4d3572c2c 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 @@ -91,50 +91,37 @@ # 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 + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + } + + process { + $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 } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/runs" + Body = $body + Context = $Context } - 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 $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.workflow_runs } } diff --git a/src/functions/private/Actions/Import-GitHubEventData.ps1 b/src/functions/private/Actions/Import-GitHubEventData.ps1 index def1ed332..fa5cf33de 100644 --- a/src/functions/private/Actions/Import-GitHubEventData.ps1 +++ b/src/functions/private/Actions/Import-GitHubEventData.ps1 @@ -25,50 +25,46 @@ function Import-GitHubEventData { } process { - try { - $gitHubEventJson = Get-Content -Path $env:GITHUB_EVENT_PATH - $gitHubEvent = $gitHubEventJson | ConvertFrom-Json + $gitHubEventJson = Get-Content -Path $env:GITHUB_EVENT_PATH + $gitHubEvent = $gitHubEventJson | ConvertFrom-Json - $eventAction = $gitHubEvent.action - $eventSender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url - $eventEnterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url - $eventOrganization = $gitHubEvent.organization | Select-Object -Property login, id, node_id - $eventOwner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url - $eventRepository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch + $eventAction = $gitHubEvent.action + $eventSender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url + $eventEnterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url + $eventOrganization = $gitHubEvent.organization | Select-Object -Property login, id, node_id + $eventOwner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url + $eventRepository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch - $gitHubEvent = $gitHubEvent | Select-Object -ExcludeProperty action, sender, enterprise, organization, repository + $gitHubEvent = $gitHubEvent | Select-Object -ExcludeProperty action, sender, enterprise, organization, repository - $hashtable = @{} - $gitHubEvent.PSObject.Properties | ForEach-Object { - $name = $_.Name - $name = $name | ConvertTo-CasingStyle -To PascalCase - $hashtable[$name] = $_.Value - } - $gitHubEvent = [pscustomobject]$hashtable + $hashtable = @{} + $gitHubEvent.PSObject.Properties | ForEach-Object { + $name = $_.Name + $name = $name | ConvertTo-CasingStyle -To PascalCase + $hashtable[$name] = $_.Value + } + $gitHubEvent = [pscustomobject]$hashtable - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Type -Value $env:GITHUB_EVENT_NAME -Force - if ($eventAction) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Action -Value $eventAction -Force - } - if ($eventSender) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Sender -Value $eventSender -Force - } - if ($eventEnterprise) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Enterprise -Value $eventEnterprise -Force - } - if ($eventOrganization) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Organization -Value $eventOrganization -Force - } - if ($eventOwner) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Owner -Value $eventOwner -Force - } - if ($eventRepository) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Repository -Value $eventRepository -Force - } - $script:GitHub.Event = $gitHubEvent - } catch { - throw $_ + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Type -Value $env:GITHUB_EVENT_NAME -Force + if ($eventAction) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Action -Value $eventAction -Force + } + if ($eventSender) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Sender -Value $eventSender -Force + } + if ($eventEnterprise) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Enterprise -Value $eventEnterprise -Force + } + if ($eventOrganization) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Organization -Value $eventOrganization -Force + } + if ($eventOwner) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Owner -Value $eventOwner -Force + } + if ($eventRepository) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Repository -Value $eventRepository -Force } + $script:GitHub.Event = $gitHubEvent } end { diff --git a/src/functions/private/Actions/Import-GitHubRunnerData.ps1 b/src/functions/private/Actions/Import-GitHubRunnerData.ps1 index 82dbd59e0..3a8ae9542 100644 --- a/src/functions/private/Actions/Import-GitHubRunnerData.ps1 +++ b/src/functions/private/Actions/Import-GitHubRunnerData.ps1 @@ -23,21 +23,17 @@ } process { - try { - $script:GitHub.Runner = [pscustomobject]@{ - Name = $env:RUNNER_NAME - OS = $env:RUNNER_OS - Arch = $env:RUNNER_ARCH - Environment = $env:RUNNER_ENVIRONMENT - Temp = $env:RUNNER_TEMP - Perflog = $env:RUNNER_PERFLOG - ToolCache = $env:RUNNER_TOOL_CACHE - TrackingID = $env:RUNNER_TRACKING_ID - Workspace = $env:RUNNER_WORKSPACE - Processors = [System.Environment]::ProcessorCount - } - } catch { - throw $_ + $script:GitHub.Runner = [pscustomobject]@{ + Name = $env:RUNNER_NAME + OS = $env:RUNNER_OS + Arch = $env:RUNNER_ARCH + Environment = $env:RUNNER_ENVIRONMENT + Temp = $env:RUNNER_TEMP + Perflog = $env:RUNNER_PERFLOG + ToolCache = $env:RUNNER_TOOL_CACHE + TrackingID = $env:RUNNER_TRACKING_ID + Workspace = $env:RUNNER_WORKSPACE + Processors = [System.Environment]::ProcessorCount } } From 8d15f5e18eea532bec75f7ebe81fe7b5d55b8d8e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:45:05 +0100 Subject: [PATCH 31/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20par?= =?UTF-8?q?ameter=20type=20for=20`$Context`=20to=20`GitHubContext`=20in=20?= =?UTF-8?q?multiple=20GitHub=20App=20functions=20for=20consistency=20and?= =?UTF-8?q?=20improved=20type=20safety?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/GitHub Apps/Get-GitHubAppByName.ps1 | 22 +++---- ...tHubAppInstallationForAuthenticatedApp.ps1 | 22 +++---- .../Get-GitHubAuthenticatedApp.ps1 | 24 +++---- ...bEnterpriseOrganizationAppInstallation.ps1 | 31 ++++----- .../Get-GitHubOrganizationAppInstallation.ps1 | 28 ++++---- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 36 +++++----- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 25 ++++--- .../Get-GitHubAppWebhookDeliveryByID.ps1 | 58 ++++++++-------- .../Get-GitHubAppWebhookDeliveryByList.ps1 | 66 +++++++++---------- ...et-GitHubAppWebhookDeliveryToRedeliver.ps1 | 50 +++++++------- 10 files changed, 162 insertions(+), 200 deletions(-) diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 index 22ef0dec1..3d399dd68 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 @@ -27,7 +27,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -37,18 +37,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/apps/$AppSlug" - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/apps/$AppSlug" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 1b050149b..6b38af87c 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -22,7 +22,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -32,18 +32,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/installations' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'GET' + APIEndpoint = '/app/installations' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index 2cee9fc3f..c836e6e93 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -26,7 +26,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -36,20 +36,14 @@ } process { - try { - $Context = Resolve-GitHubContext -Context $Context - - $inputObject = @{ - Context = $Context - APIEndpoint = '/app' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'GET' + APIEndpoint = '/app' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index 2d42fdf03..758b27b7f 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -41,33 +41,30 @@ # 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 + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" - Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + # Enterprise_organization_installations=read } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index 5c240c152..a5bb29dd3 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -34,7 +34,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -44,23 +44,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/installations" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/orgs/$Organization/installations" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.installations - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.installations } } diff --git a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 index 662729535..f93b5aa3f 100644 --- a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -39,35 +39,33 @@ # 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 + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + # enterprise_organization_installations=write } process { - try { - $body = @{ - client_id = $ClientID - repository_selection = $RepositorySelection - repositories = $Repositories - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + client_id = $ClientID + repository_selection = $RepositorySelection + repositories = $Repositories + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index 5cab9ae1d..91112c705 100644 --- a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -25,33 +25,30 @@ # The client ID of the GitHub App to install. [Parameter(Mandatory)] - [Alias('installation_id', 'InstallationID')] [string] $ID, # 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 + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installations=write } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID}" - Method = 'Delete' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index e2d17a555..719dda1db 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -23,13 +23,13 @@ param( # The ID of the delivery. [Parameter(Mandatory)] - [Alias('DeliveryID', 'delivery_id')] + [Alias('delivery_id', 'DeliveryID')] [string] $ID, # 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 + [GitHubContext] $Context ) begin { @@ -39,36 +39,32 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/app/hook/deliveries/$ID" - Method = 'GET' - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/app/hook/deliveries/$ID" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - [GitHubWebhook]( - @{ - ID = $_.id - GUID = $_.guid - DeliveredAt = $_.delivered_at - Redelivery = $_.redelivery - Duration = $_.duration - Status = $_.status - StatusCode = $_.status_code - Event = $_.event - Action = $_.action - InstallationID = $_.installation.id - RepositoryID = $_.repository.id - ThrottledAt = $_.throttled_at - URL = $_.url - Request = $_.request - Response = $_.response - } - ) - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + [GitHubWebhook]( + @{ + ID = $_.id + GUID = $_.guid + DeliveredAt = $_.delivered_at + Redelivery = $_.redelivery + Duration = $_.duration + Status = $_.status + StatusCode = $_.status_code + Event = $_.event + Action = $_.action + InstallationID = $_.installation.id + RepositoryID = $_.repository.id + ThrottledAt = $_.throttled_at + URL = $_.url + Request = $_.request + Response = $_.response + } + ) } } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 4c643bae4..74ec44cc9 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -28,7 +28,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -38,43 +38,39 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/hook/deliveries' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = '/app/hook/deliveries' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - $_.Response | ForEach-Object { - [GitHubWebhook]( - @{ - ID = $_.id - GUID = $_.guid - DeliveredAt = $_.delivered_at - Redelivery = $_.redelivery - Duration = $_.duration - Status = $_.status - StatusCode = $_.status_code - Event = $_.event - Action = $_.action - InstallationID = $_.installation.id - RepositoryID = $_.repository.id - ThrottledAt = $_.throttled_at - URL = $_.url - Request = $_.request - Response = $_.response - } - ) - } + Invoke-GitHubAPI @inputObject | ForEach-Object { + $_.Response | ForEach-Object { + [GitHubWebhook]( + @{ + ID = $_.id + GUID = $_.guid + DeliveredAt = $_.delivered_at + Redelivery = $_.redelivery + Duration = $_.duration + Status = $_.status + StatusCode = $_.status_code + Event = $_.event + Action = $_.action + InstallationID = $_.installation.id + RepositoryID = $_.repository.id + ThrottledAt = $_.throttled_at + URL = $_.url + Request = $_.request + Response = $_.response + } + ) } - } catch { - throw $_ } } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 index d39ab1c5a..e81c11160 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 @@ -26,7 +26,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -36,33 +36,29 @@ } process { - try { - $checkPoint = (Get-Date).AddHours($TimeSpan) - Get-GitHubAppWebhookDeliveryByList -Context $Context -PerPage $PerPage | Where-Object { $_.DeliveredAt -gt $checkPoint } | - Group-Object -Property GUID | Where-Object { $_.Group.Status -notcontains 'OK' } | ForEach-Object { - $refObject = $_.Group | Sort-Object -Property DeliveredAt - [GitHubWebhookRedelivery]@{ - Attempts = $_.Count - GUID = $_.Name - Status = $refObject.Status - StatusCode = $refObject.StatusCode - Event = $refObject.Event - Action = $refObject.Action - Duration = $_.Group.Duration | Measure-Object -Average | Select-Object -ExpandProperty Average - ID = $refObject.ID - DeliveredAt = $refObject.DeliveredAt - Redelivery = $refObject.Redelivery - InstallationID = $refObject.InstallationID - RepositoryID = $refObject.RepositoryID - ThrottledAt = $refObject.ThrottledAt - URL = $refObject.URL - Request = $refObject.Request - Response = $refObject.Response - } + $checkPoint = (Get-Date).AddHours($TimeSpan) + Get-GitHubAppWebhookDeliveryByList -Context $Context -PerPage $PerPage | Where-Object { $_.DeliveredAt -gt $checkPoint } | + Group-Object -Property GUID | Where-Object { $_.Group.Status -notcontains 'OK' } | ForEach-Object { + $refObject = $_.Group | Sort-Object -Property DeliveredAt + [GitHubWebhookRedelivery]@{ + Attempts = $_.Count + GUID = $_.Name + Status = $refObject.Status + StatusCode = $refObject.StatusCode + Event = $refObject.Event + Action = $refObject.Action + Duration = $_.Group.Duration | Measure-Object -Average | Select-Object -ExpandProperty Average + ID = $refObject.ID + DeliveredAt = $refObject.DeliveredAt + Redelivery = $refObject.Redelivery + InstallationID = $refObject.InstallationID + RepositoryID = $refObject.RepositoryID + ThrottledAt = $refObject.ThrottledAt + URL = $refObject.URL + Request = $refObject.Request + Response = $refObject.Response } - } catch { - throw $_ - } + } } end { From 914da114e7146e6451455d884e6593598904a920 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:46:17 +0100 Subject: [PATCH 32/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Enhance=20pa?= =?UTF-8?q?rameter=20handling=20and=20add=20TODOs=20for=20permission=20che?= =?UTF-8?q?cks=20in=20GitHub=20context=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/Context/Assert-GitHubContext.ps1 | 2 + .../Auth/Context/Resolve-GitHubContext.ps1 | 52 +++++++++---------- .../Auth/Context/Set-GitHubContext.ps1 | 2 +- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 index 977b77c50..257d7195d 100644 --- a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 @@ -24,6 +24,7 @@ [Parameter(Mandatory)] [string[]] $AuthType + # TODO: Implement permission check # # The required permission for the command. # [Parameter()] # [string] $Permission @@ -40,6 +41,7 @@ if ($Context.AuthType -notin $AuthType) { throw "The context '$($Context.Name)' does not match the required AuthTypes [$AuthType] for [$command]." } + # TODO: Implement permission check # if ($Context.AuthType -in 'IAT' -and $Context.Permission -notin $Permission) { # throw "The context '$($Context.Name)' does not match the required Permission [$Permission] for [$command]." # } diff --git a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 index 68b5659bd..60f1b3158 100644 --- a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 @@ -25,7 +25,10 @@ param( # The context to resolve into an object. Used to get the details for the API call. # Can be either a string or a GitHubContext object. - [Parameter(ValueFromPipeline)] + [Parameter( + Mandatory, + ValueFromPipeline + )] [object] $Context ) @@ -36,36 +39,33 @@ } process { - 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 ($Context -is [string]) { + $contextName = $Context + Write-Debug "Getting context: [$contextName]" + $Context = Get-GitHubContext -Context $contextName + } - # 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 $_ + if (-not $Context) { + throw "Please provide a valid context or log in using 'Connect-GitHub'." } + + # TODO: Implement App installation context resolution + # 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 } + # } + # } + # } + Write-Output $Context } end { Write-Debug "[$stackPath] - End" - Write-Output $Context } } diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index 5f3af22ad..1266214ff 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -82,7 +82,7 @@ function Set-GitHubContext { $app = Get-GitHubApp -AppSlug $contextObj['Username'] -Context $contextObj $contextObj['DisplayName'] = [string]$app.name } catch { - Write-Warning "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." + Write-Debug "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." } } if ($script:GitHub.EnvironmentType -eq 'GHA') { From 015915f21f9c1ebfbd4b11d2eac1e8c504d31447 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:46:35 +0100 Subject: [PATCH 33/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20par?= =?UTF-8?q?ameter=20type=20for=20`$Context`=20to=20`GitHubContext`=20in=20?= =?UTF-8?q?Device=20Flow=20functions=20for=20improved=20type=20safety?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 | 2 +- .../private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 index 1d0774e8c..181dce85e 100644 --- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 @@ -17,7 +17,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index cea9919e6..10eecab1e 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -30,7 +30,7 @@ function Update-GitHubUserAccessToken { # 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, + [GitHubContext] $Context, # Return the new access token. [Parameter()] From 9731ff89b6d30c26c3ec7903c67f71a4b6ad247a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:46:47 +0100 Subject: [PATCH 34/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20par?= =?UTF-8?q?ameter=20type=20for=20`$Context`=20to=20`GitHubContext`=20in=20?= =?UTF-8?q?Gitignore=20functions=20for=20improved=20type=20safety?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gitignore/Get-GitHubGitignoreByName.ps1 | 24 ++++++++----------- .../Gitignore/Get-GitHubGitignoreList.ps1 | 10 +++----- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 index 3d168a329..46c8a8bbc 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 @@ -24,7 +24,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -34,19 +34,15 @@ } process { - 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 $_ + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/gitignore/templates/$Name" + Accept = 'application/vnd.github.raw+json' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index 257bd7514..d38f44436 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -22,7 +22,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -32,19 +32,15 @@ } process { - try { $inputObject = @{ - Context = $Context - APIEndpoint = '/gitignore/templates' Method = 'GET' + APIEndpoint = '/gitignore/templates' + Context = $Context } Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } - } catch { - throw $_ - } } end { From 6371d2002be37289b864f4cb37cbcccb421b86b3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:47:21 +0100 Subject: [PATCH 35/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20par?= =?UTF-8?q?ameter=20type=20for=20`$Context`=20to=20`GitHubContext`=20in=20?= =?UTF-8?q?multiple=20user=20and=20team=20functions=20for=20improved=20typ?= =?UTF-8?q?e=20safety?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../License/Get-GitHubLicenseByName.ps1 | 24 +++++------ .../private/License/Get-GitHubLicenseList.ps1 | 22 ++++------ .../License/Get-GitHubRepositoryLicense.ps1 | 42 +++++++------------ .../Block-GitHubUserByOrganization.ps1 | 19 ++------- .../Get-GitHubBlockedUserByOrganization.ps1 | 28 ++++++------- .../Test-GitHubBlockedUserByOrganization.ps1 | 16 ++----- .../Unblock-GitHubUserByOrganization.ps1 | 15 ++----- .../Get-GitHubAllOrganization.ps1 | 2 +- .../Organization/Get-GitHubMyOrganization.ps1 | 2 +- .../Get-GitHubOrganizationByName.ps1 | 2 +- .../Get-GitHubUserOrganization.ps1 | 2 +- .../Assets/Get-GitHubReleaseAssetByID.ps1 | 2 +- .../Get-GitHubReleaseAssetByReleaseID.ps1 | 2 +- .../Releases/Get-GitHubReleaseAll.ps1 | 2 +- .../Releases/Get-GitHubReleaseByID.ps1 | 2 +- .../Releases/Get-GitHubReleaseByTagName.ps1 | 2 +- .../Releases/Get-GitHubReleaseLatest.ps1 | 2 +- .../Get-GitHubRepositoryAutolinkById.ps1 | 2 +- .../Get-GitHubRepositoryAutolinkList.ps1 | 2 +- .../Fork/New-GitHubRepositoryAsFork.ps1 | 2 +- .../Repositories/Get-GitHubMyRepositories.ps1 | 2 +- .../Get-GitHubRepositoryByName.ps1 | 2 +- .../Get-GitHubRepositoryListByID.ps1 | 2 +- .../Get-GitHubRepositoryListByOrg.ps1 | 2 +- .../Get-GitHubRepositoryListByUser.ps1 | 2 +- .../New-GitHubRepositoryFromTemplate.ps1 | 2 +- .../Repositories/New-GitHubRepositoryOrg.ps1 | 2 +- .../Repositories/New-GitHubRepositoryUser.ps1 | 2 +- .../private/Teams/Get-GitHubRESTTeam.ps1 | 2 +- .../Teams/Get-GitHubRESTTeamByName.ps1 | 2 +- .../Teams/Get-GitHubRESTTeamListByOrg.ps1 | 2 +- .../private/Teams/Get-GitHubRepoTeam.ps1 | 2 +- .../private/Teams/Get-GitHubTeamBySlug.ps1 | 2 +- .../private/Teams/Get-GitHubTeamListByOrg.ps1 | 2 +- .../Users/Blocking/Block-GitHubUserByUser.ps1 | 2 +- .../Blocking/Get-GitHubBlockedUserByUser.ps1 | 2 +- .../Blocking/Test-GitHubBlockedUserByUser.ps1 | 2 +- .../Blocking/Unblock-GitHubUserByUser.ps1 | 2 +- .../Users/Emails/Get-GitHubUserAllEmail.ps1 | 2 +- .../Emails/Get-GitHubUserPublicEmail.ps1 | 2 +- .../Get-GitHubUserFollowersOfUser.ps1 | 2 +- .../Followers/Get-GitHubUserFollowingMe.ps1 | 2 +- .../Followers/Get-GitHubUserFollowingUser.ps1 | 2 +- .../Followers/Get-GitHubUserMyFollowers.ps1 | 2 +- .../Followers/Test-GitHubUserFollowedByMe.ps1 | 2 +- .../Test-GitHubUserFollowedByUser.ps1 | 2 +- .../GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 | 2 +- .../Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 | 2 +- .../GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 | 2 +- .../private/Users/Get-GitHubAllUser.ps1 | 2 +- .../private/Users/Get-GitHubMyUser.ps1 | 2 +- .../private/Users/Get-GitHubUserByName.ps1 | 2 +- .../private/Users/Get-GitHubUserCard.ps1 | 2 +- .../Users/Keys/Get-GitHubUserKeyForUser.ps1 | 2 +- .../Users/Keys/Get-GitHubUserMyKey.ps1 | 2 +- .../Users/Keys/Get-GitHubUserMyKeyById.ps1 | 2 +- .../Get-GitHubUserMySigningKey.ps1 | 2 +- .../Get-GitHubUserMySigningKeyById.ps1 | 2 +- .../Get-GitHubUserSigningKeyForUser.ps1 | 2 +- .../Get-GitHubMyUserSocials.ps1 | 2 +- .../Get-GitHubUserSocialsByName.ps1 | 2 +- 61 files changed, 111 insertions(+), 163 deletions(-) diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index 4dc6b32f6..a591d65d9 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -27,7 +27,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -37,19 +37,15 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/licenses/$Name" - Accept = 'application/vnd.github+json' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Context = $Context + APIEndpoint = "/licenses/$Name" + Accept = 'application/vnd.github+json' + Method = 'GET' + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index d741aaced..c906f7095 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -23,7 +23,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -33,18 +33,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/licenses' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'GET' + APIEndpoint = '/licenses' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index 387cc991c..6d8661478 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -36,47 +36,33 @@ # 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 + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { $contentType = switch ($Type) { 'raw' { 'application/vnd.github.raw+json' } 'html' { 'application/vnd.github.html+json' } } - } - process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/license" - ContentType = $contentType - Method = 'GET' - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/repos/$Owner/$Repo/license" + ContentType = $contentType + Context = $Context + } - 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 $_ + 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 } } end { diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 52d47ce19..1dd526c89 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -41,7 +41,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -52,23 +52,12 @@ process { $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/blocks/$Username" Method = 'PUT' + APIEndpoint = "/orgs/$Organization/blocks/$Username" + Context = $Context } - 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 $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index b76586c66..c1e1c851e 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -32,7 +32,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -42,23 +42,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/blocks" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'GET' + APIEndpoint = "/orgs/$Organization/blocks" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index cde0a4aa3..0f6346d87 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -40,7 +40,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -51,20 +51,12 @@ process { $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/blocks/$Username" Method = 'GET' + APIEndpoint = "/orgs/$Organization/blocks/$Username" + Context = $Context } - try { - (Invoke-GitHubAPI @inputObject).StatusCode -eq 204 - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index 712528a72..cdea93dc0 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -41,7 +41,7 @@ # 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 + [GitHubContext] $Context ) begin { @@ -52,18 +52,11 @@ process { $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/blocks/$Username" Method = 'DELETE' + APIEndpoint = "/orgs/$Organization/blocks/$Username" + Context = $Context } - - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - Write-Error $_.Exception.Response - throw $_ - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index 3c42c016d..ea95b92c9 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -34,7 +34,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index 0640e4f70..09fddcce9 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -33,7 +33,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index 07f0fc6c6..dcbf69fc5 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -39,7 +39,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index 0d56c7735..670e77e00 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -35,7 +35,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index 94826c337..42eccb95f 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -36,7 +36,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 751207633..255c23abe 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -41,7 +41,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index b747c3577..b023675b0 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -35,7 +35,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 05fe2ac60..0bb6a114a 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -34,7 +34,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index 6f658e55c..1e561e2ac 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -33,7 +33,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index 537eb0833..1b24d1f3e 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -30,7 +30,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index 7c1c0149a..3f85864c6 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -37,7 +37,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index 1f9bf863b..fe19ed524 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -31,7 +31,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index 6137b628a..cf5a4b0fd 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -65,7 +65,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index 6cbf70952..e4cc00c95 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -110,7 +110,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index ade44e09f..2a9657b8b 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -33,7 +33,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index 27d3e1942..034a58342 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -30,7 +30,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index 3f06ead09..f4fac6c53 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -59,7 +59,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index 0eb7e421f..9f815299a 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -61,7 +61,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index e6ea2ff61..f84ded353 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -75,7 +75,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 0ff2e5dd2..34e59756d 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -184,7 +184,7 @@ filter New-GitHubRepositoryOrg { # 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 + [GitHubContext] $Context ) dynamicparam { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index b953b4059..ad0ef4824 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -178,7 +178,7 @@ filter New-GitHubRepositoryUser { # 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 + [GitHubContext] $Context ) dynamicparam { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index 63bb92ab6..c10a69cf4 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -42,7 +42,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index 1291cf2b8..bd745d9c3 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -26,7 +26,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index fdbeb69f3..d23199655 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -23,7 +23,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index 7c4e327aa..2f796c879 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -14,7 +14,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 index f545c93e0..5d1db06a5 100644 --- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 @@ -27,7 +27,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 index 407308d43..b0520e848 100644 --- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 @@ -24,7 +24,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index 9d76b002d..c5d4fc325 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -30,7 +30,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index 603a4374b..29613da2c 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -25,7 +25,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index 1f2f547ef..68cf48a67 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -37,7 +37,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index fa9810262..30620f21e 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -30,7 +30,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index c6a236301..a1a894ec6 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -27,7 +27,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index 8fe9f8791..179781c33 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -29,7 +29,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index a12689b74..fefd44369 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -35,7 +35,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index 9f6ea98d8..ecfc06c5b 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -26,7 +26,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index 22a002103..dc47ebbe9 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -35,7 +35,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index 0cdcded2a..e8b5584a3 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -27,7 +27,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index c9c0c26f2..a14a8c25a 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -29,7 +29,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index 42ef3a84b..76ad1f301 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -35,7 +35,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 index 61dc38abe..abae1bd2e 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 @@ -33,7 +33,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 index 93655405f..8998a41ce 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 @@ -28,7 +28,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 index a878d3461..c310385de 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 @@ -30,7 +30,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 5da582bfc..949899450 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -34,7 +34,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1 index 4e9bc820f..47c9dc433 100644 --- a/src/functions/private/Users/Get-GitHubMyUser.ps1 +++ b/src/functions/private/Users/Get-GitHubMyUser.ps1 @@ -23,7 +23,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1 index 182689dde..3a9e18ecc 100644 --- a/src/functions/private/Users/Get-GitHubUserByName.ps1 +++ b/src/functions/private/Users/Get-GitHubUserByName.ps1 @@ -41,7 +41,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 index 2fbeea5ad..dc682e659 100644 --- a/src/functions/private/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/private/Users/Get-GitHubUserCard.ps1 @@ -42,7 +42,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 index 0663da987..1afb028a0 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 @@ -33,7 +33,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 index c1e2ba98d..6b7662e8a 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 @@ -28,7 +28,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 index 5044d6a28..fdcde9e97 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 @@ -30,7 +30,7 @@ # 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 + [GitHubContext] $Context ) begin { 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 243aff987..254ca5de4 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 @@ -28,7 +28,7 @@ # 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 + [GitHubContext] $Context ) begin { 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 5354871b0..903529875 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 @@ -31,7 +31,7 @@ # 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 + [GitHubContext] $Context ) begin { 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 b9229c5ec..0e6653f9a 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 @@ -33,7 +33,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 index 3e5095cda..8d5204a1a 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 @@ -26,7 +26,7 @@ # 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 + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 index caf55da7c..ee82b7383 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 @@ -29,7 +29,7 @@ # 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 + [GitHubContext] $Context ) begin { From 4f9ce61b94a8505c016d1a5a8541e0d6ccfcc049 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 3 Feb 2025 22:50:13 +0100 Subject: [PATCH 36/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Standardize?= =?UTF-8?q?=20HTTP=20method=20casing=20and=20enforce=20mandatory=20context?= =?UTF-8?q?=20parameter=20in=20multiple=20functions=20for=20consistency=20?= =?UTF-8?q?and=20improved=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 | 4 ++-- .../private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 | 4 ++-- .../private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 | 4 ++-- .../Get-GitHubAppInstallationForAuthenticatedApp.ps1 | 4 ++-- .../private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 | 4 ++-- .../Get-GitHubEnterpriseOrganizationAppInstallation.ps1 | 4 ++-- .../GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 | 4 ++-- .../GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 | 2 +- .../Uninstall-GitHubAppOnEnterpriseOrganization.ps1 | 2 +- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 | 4 ++-- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 | 4 ++-- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 | 2 +- .../private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 | 2 +- .../private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 | 2 +- .../Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 | 2 +- .../private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 2 +- src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 | 4 ++-- src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 | 4 ++-- src/functions/private/License/Get-GitHubLicenseByName.ps1 | 4 ++-- src/functions/private/License/Get-GitHubLicenseList.ps1 | 4 ++-- src/functions/private/License/Get-GitHubRepositoryLicense.ps1 | 4 ++-- .../Organization/Blocking/Block-GitHubUserByOrganization.ps1 | 4 ++-- .../Blocking/Get-GitHubBlockedUserByOrganization.ps1 | 4 ++-- .../Blocking/Test-GitHubBlockedUserByOrganization.ps1 | 4 ++-- .../Blocking/Unblock-GitHubUserByOrganization.ps1 | 4 ++-- .../private/Organization/Get-GitHubAllOrganization.ps1 | 4 ++-- .../private/Organization/Get-GitHubMyOrganization.ps1 | 4 ++-- .../private/Organization/Get-GitHubOrganizationByName.ps1 | 4 ++-- .../private/Organization/Get-GitHubUserOrganization.ps1 | 4 ++-- .../private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 | 4 ++-- .../Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 | 4 ++-- .../private/Releases/Releases/Get-GitHubReleaseAll.ps1 | 4 ++-- .../private/Releases/Releases/Get-GitHubReleaseByID.ps1 | 4 ++-- .../private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 | 4 ++-- .../private/Releases/Releases/Get-GitHubReleaseLatest.ps1 | 4 ++-- .../Autolinks/Get-GitHubRepositoryAutolinkById.ps1 | 4 ++-- .../Autolinks/Get-GitHubRepositoryAutolinkList.ps1 | 4 ++-- .../private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 | 4 ++-- .../Repositories/Repositories/Get-GitHubMyRepositories.ps1 | 4 ++-- .../Repositories/Repositories/Get-GitHubRepositoryByName.ps1 | 4 ++-- .../Repositories/Get-GitHubRepositoryListByID.ps1 | 4 ++-- .../Repositories/Get-GitHubRepositoryListByOrg.ps1 | 4 ++-- .../Repositories/Get-GitHubRepositoryListByUser.ps1 | 4 ++-- .../Repositories/New-GitHubRepositoryFromTemplate.ps1 | 4 ++-- .../Repositories/Repositories/New-GitHubRepositoryOrg.ps1 | 4 ++-- .../Repositories/Repositories/New-GitHubRepositoryUser.ps1 | 4 ++-- src/functions/private/Teams/Get-GitHubRESTTeam.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRepoTeam.ps1 | 2 +- src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 | 2 +- src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 | 2 +- .../private/Users/Blocking/Block-GitHubUserByUser.ps1 | 4 ++-- .../private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 | 4 ++-- .../private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 | 4 ++-- .../private/Users/Blocking/Unblock-GitHubUserByUser.ps1 | 4 ++-- src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 | 4 ++-- .../private/Users/Emails/Get-GitHubUserPublicEmail.ps1 | 4 ++-- .../private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 | 4 ++-- .../private/Users/Followers/Get-GitHubUserFollowingMe.ps1 | 4 ++-- .../private/Users/Followers/Get-GitHubUserFollowingUser.ps1 | 4 ++-- .../private/Users/Followers/Get-GitHubUserMyFollowers.ps1 | 4 ++-- .../private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 | 4 ++-- .../private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 | 4 ++-- .../private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 | 4 ++-- .../private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 | 4 ++-- .../private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 | 4 ++-- src/functions/private/Users/Get-GitHubAllUser.ps1 | 4 ++-- src/functions/private/Users/Get-GitHubMyUser.ps1 | 4 ++-- src/functions/private/Users/Get-GitHubUserByName.ps1 | 4 ++-- src/functions/private/Users/Get-GitHubUserCard.ps1 | 4 ++-- src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 | 4 ++-- src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 | 4 ++-- src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 | 4 ++-- .../Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 | 4 ++-- .../Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 | 4 ++-- .../SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 | 4 ++-- .../private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 | 4 ++-- .../Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 | 4 ++-- src/functions/public/API/Invoke-GitHubAPI.ps1 | 4 ++-- .../public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 | 2 +- .../public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 | 2 +- .../public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 | 2 +- .../public/Actions/Workflow/Disable-GitHubWorkflow.ps1 | 2 +- .../public/Actions/Workflow/Enable-GitHubWorkflow.ps1 | 2 +- src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 | 2 +- .../public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 | 2 +- .../public/Actions/Workflow/Start-GitHubWorkflow.ps1 | 2 +- .../Add-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../Get-GitHubAppAccessibleRepository.ps1 | 2 +- .../Get-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../Remove-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../Update-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 | 2 +- .../Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 | 2 +- .../Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 | 2 +- src/functions/public/Branches/Get-GitHubRepoBranch.ps1 | 2 +- src/functions/public/Emojis/Get-GitHubEmoji.ps1 | 2 +- src/functions/public/Markdown/Get-GitHubMarkdown.ps1 | 2 +- src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 | 2 +- src/functions/public/Meta/Get-GitHubApiVersion.ps1 | 2 +- src/functions/public/Meta/Get-GitHubMeta.ps1 | 2 +- src/functions/public/Meta/Get-GitHubOctocat.ps1 | 2 +- src/functions/public/Meta/Get-GitHubRoot.ps1 | 2 +- src/functions/public/Meta/Get-GitHubZen.ps1 | 2 +- .../Organization/Members/New-GitHubOrganizationInvitation.ps1 | 2 +- .../Members/Remove-GitHubOrganizationInvitation.ps1 | 2 +- .../public/Organization/Remove-GitHubOrganization.ps1 | 2 +- .../public/Organization/Update-GitHubOrganization.ps1 | 2 +- .../Organization/Update-GitHubOrganizationSecurityFeature.ps1 | 2 +- src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 | 2 +- .../public/Releases/Assets/Add-GitHubReleaseAsset.ps1 | 2 +- .../public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 | 2 +- .../public/Releases/Assets/Set-GitHubReleaseAsset.ps1 | 2 +- src/functions/public/Releases/Releases/New-GitHubRelease.ps1 | 2 +- .../public/Releases/Releases/New-GitHubReleaseNote.ps1 | 2 +- .../public/Releases/Releases/Remove-GitHubRelease.ps1 | 2 +- src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 | 2 +- .../Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 | 2 +- .../Autolinks/Remove-GitHubRepositoryAutolink.ps1 | 2 +- .../CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 | 2 +- .../Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 | 2 +- .../Repositories/Disable-GitHubRepositorySecurityFix.ps1 | 2 +- .../Disable-GitHubRepositoryVulnerabilityAlert.ps1 | 2 +- .../Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 | 2 +- .../Repositories/Enable-GitHubRepositorySecurityFix.ps1 | 2 +- .../Enable-GitHubRepositoryVulnerabilityAlert.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryActivity.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryCodeownersError.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryContributor.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryFork.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryLanguage.ps1 | 2 +- .../Repositories/Get-GitHubRepositorySecurityFix.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTag.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 | 2 +- .../Repositories/Repositories/Move-GitHubRepository.ps1 | 2 +- .../Repositories/Repositories/Remove-GitHubRepository.ps1 | 2 +- .../Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 | 2 +- .../Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 | 2 +- .../Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 | 2 +- .../Repositories/Repositories/Update-GitHubRepository.ps1 | 2 +- .../RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 | 2 +- .../RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 | 2 +- .../Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 | 2 +- .../Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 | 2 +- .../Tags/Remove-GitHubRepositoryTagProtection.ps1 | 2 +- src/functions/public/Teams/New-GitHubTeam.ps1 | 2 +- src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 | 2 +- src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 | 2 +- .../public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 | 2 +- .../public/Users/Followers/Add-GitHubUserFollowing.ps1 | 2 +- .../public/Users/Followers/Remove-GitHubUserFollowing.ps1 | 2 +- src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 | 2 +- .../public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 | 2 +- src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 | 2 +- src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 | 2 +- .../Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 | 2 +- .../Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 | 2 +- .../public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 | 2 +- .../public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 | 2 +- src/functions/public/Users/Update-GitHubUser.ps1 | 2 +- tools/Guidelines.md | 1 + 163 files changed, 230 insertions(+), 229 deletions(-) diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 index 762ab6814..01f8419e4 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 @@ -83,7 +83,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -107,7 +107,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/repos/$Owner/$Repo/actions/runs" Body = $body Context = $Context diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 index 4d3572c2c..e1771340c 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 @@ -90,7 +90,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -114,7 +114,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/runs" Body = $body Context = $Context diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 index 3d399dd68..977a6ce71 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 @@ -26,7 +26,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -38,7 +38,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/apps/$AppSlug" Context = $Context } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 6b38af87c..f85bc1cac 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -21,7 +21,7 @@ param( # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -33,7 +33,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = '/app/installations' Context = $Context } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index c836e6e93..b15d1c52b 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -25,7 +25,7 @@ param( # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -37,7 +37,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = '/app' Context = $Context } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index 758b27b7f..7dc368cc2 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -57,7 +57,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" Body = $body Context = $Context diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index a5bb29dd3..77ba7691c 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -33,7 +33,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -49,7 +49,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/orgs/$Organization/installations" Body = $body Context = $Context diff --git a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 index f93b5aa3f..78ac805e7 100644 --- a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -38,7 +38,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index 91112c705..574e29791 100644 --- a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index 719dda1db..05b538251 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -28,7 +28,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -40,7 +40,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/app/hook/deliveries/$ID" Context = $Context } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 74ec44cc9..68fc7741f 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -27,7 +27,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -43,7 +43,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = '/app/hook/deliveries' Body = $body Context = $Context diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 index e81c11160..3cffe1ff6 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 @@ -25,7 +25,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 index 5592d1e78..ee06820a4 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 @@ -68,7 +68,7 @@ $RESTParams = @{ Uri = "https://$HostName/login/oauth/access_token" - Method = 'POST' + Method = 'Post' Body = $body Headers = @{ 'Accept' = 'application/json' } } diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 index 8a0b22662..b07cddbe9 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 @@ -51,7 +51,7 @@ $RESTParams = @{ Uri = "https://$HostName/login/device/code" - Method = 'POST' + Method = 'Post' Body = $body Headers = $headers } diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 index 181dce85e..a6d022531 100644 --- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 @@ -16,7 +16,7 @@ param( # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index 10eecab1e..39259d154 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -29,7 +29,7 @@ function Update-GitHubUserAccessToken { param( # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context, # Return the new access token. diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 index 46c8a8bbc..1ce3f5f87 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 @@ -23,7 +23,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -35,7 +35,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/gitignore/templates/$Name" Accept = 'application/vnd.github.raw+json' Context = $Context diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index d38f44436..2040bcdcd 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -21,7 +21,7 @@ param( # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -33,7 +33,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = '/gitignore/templates' Context = $Context } diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index a591d65d9..4a5492f99 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -26,7 +26,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -41,7 +41,7 @@ Context = $Context APIEndpoint = "/licenses/$Name" Accept = 'application/vnd.github+json' - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index c906f7095..13fcd1839 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -22,7 +22,7 @@ param( # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -34,7 +34,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = '/licenses' Context = $Context } diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index 6d8661478..ecbb18e07 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -35,7 +35,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -52,7 +52,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/repos/$Owner/$Repo/license" ContentType = $contentType Context = $Context diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 1dd526c89..e1bafcbdf 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -52,7 +52,7 @@ process { $inputObject = @{ - Method = 'PUT' + Method = 'Put' APIEndpoint = "/orgs/$Organization/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index c1e1c851e..e5671dce4 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -31,7 +31,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -47,7 +47,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/orgs/$Organization/blocks" Body = $body Context = $Context diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index 0f6346d87..4c039d510 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -39,7 +39,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -51,7 +51,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/orgs/$Organization/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index cdea93dc0..2aa2ed4e6 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -52,7 +52,7 @@ process { $inputObject = @{ - Method = 'DELETE' + Method = 'Delete' APIEndpoint = "/orgs/$Organization/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index ea95b92c9..7a3db22d4 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -33,7 +33,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -53,7 +53,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/organizations' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index 09fddcce9..67d62a5af 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -51,7 +51,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/orgs' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index dcbf69fc5..7a4606df6 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -38,7 +38,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -53,7 +53,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Organization" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index 670e77e00..6a18fb69d 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -53,7 +53,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/orgs" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index 42eccb95f..d91b42d59 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -35,7 +35,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -60,7 +60,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 255c23abe..def1707c1 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -68,7 +68,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index b023675b0..2d842a0b9 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -62,7 +62,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 0bb6a114a..58934a45c 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -33,7 +33,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -57,7 +57,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index 1e561e2ac..b568ba97c 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -56,7 +56,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index 1b24d1f3e..4adbd820b 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -53,7 +53,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/latest" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index 3f85864c6..30592b66e 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -36,7 +36,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -60,7 +60,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index fe19ed524..d57cce3a1 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -30,7 +30,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -54,7 +54,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/autolinks" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index cf5a4b0fd..b97e49c86 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -64,7 +64,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -99,7 +99,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/forks" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index e4cc00c95..e23287174 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -109,7 +109,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -146,7 +146,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/repos' - Method = 'GET' + Method = 'Get' body = $body } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index 2a9657b8b..56c487a65 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -57,7 +57,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index 034a58342..f334742d4 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -48,7 +48,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/repositories' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index f4fac6c53..aa8a76978 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -58,7 +58,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -84,7 +84,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Owner/repos" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index 9f815299a..0d07294d3 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -60,7 +60,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -91,7 +91,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/repos" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index f84ded353..2e13290ed 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -74,7 +74,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -101,7 +101,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$TemplateOwner/$TemplateRepo/generate" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 34e59756d..96c94d150 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -183,7 +183,7 @@ filter New-GitHubRepositoryOrg { # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -252,7 +252,7 @@ filter New-GitHubRepositoryOrg { $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Owner/repos" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index ad0ef4824..f9820e3b9 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -177,7 +177,7 @@ filter New-GitHubRepositoryUser { # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -242,7 +242,7 @@ filter New-GitHubRepositoryUser { $inputObject = @{ Context = $Context APIEndpoint = '/user/repos' - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index c10a69cf4..968aaeef7 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -41,7 +41,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index bd745d9c3..a4e768f83 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -25,7 +25,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index d23199655..140b39819 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -22,7 +22,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index 2f796c879..e12284db1 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -13,7 +13,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 index 5d1db06a5..44996d9c5 100644 --- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 @@ -26,7 +26,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 index b0520e848..2db357673 100644 --- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 @@ -23,7 +23,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index c5d4fc325..67059156d 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -43,7 +43,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/blocks/$Username" - Method = 'PUT' + Method = 'Put' } try { diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index 29613da2c..618d3ddaa 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -24,7 +24,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -43,7 +43,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/blocks' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index 68cf48a67..1d90470e1 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -36,7 +36,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -55,7 +55,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/blocks/$Username" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index 30620f21e..aeac50965 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/blocks/$Username" - Method = 'DELETE' + Method = 'Delete' } try { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index a1a894ec6..d397046aa 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -26,7 +26,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/emails' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index 179781c33..22bc84b49 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -28,7 +28,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -47,7 +47,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/public_emails' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index fefd44369..5f9c182b9 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -53,7 +53,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/followers" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index ecfc06c5b..a38dbe01d 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -25,7 +25,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/following' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index dc47ebbe9..48c5011ea 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -53,7 +53,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/following" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index e8b5584a3..6b76ca2d9 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -26,7 +26,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -45,7 +45,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/followers' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index a14a8c25a..ccb583d1d 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -28,7 +28,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -42,7 +42,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/following/$Username" - Method = 'GET' + Method = 'Get' } try { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index 76ad1f301..6409d48ed 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -48,7 +48,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/following/$Follows" - Method = 'GET' + Method = 'Get' } try { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 index abae1bd2e..937f2e087 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -51,7 +51,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/gpg_keys" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 index 8998a41ce..0bfce3b93 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 @@ -27,7 +27,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -46,7 +46,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/gpg_keys' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 index c310385de..04972070b 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/gpg_keys/$ID" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 949899450..08649a960 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -33,7 +33,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -53,7 +53,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/users' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1 index 47c9dc433..af2e97c9d 100644 --- a/src/functions/private/Users/Get-GitHubMyUser.ps1 +++ b/src/functions/private/Users/Get-GitHubMyUser.ps1 @@ -22,7 +22,7 @@ param( # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -37,7 +37,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user' - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1 index 3a9e18ecc..7756da45b 100644 --- a/src/functions/private/Users/Get-GitHubUserByName.ps1 +++ b/src/functions/private/Users/Get-GitHubUserByName.ps1 @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -55,7 +55,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 index dc682e659..9e66efeb5 100644 --- a/src/functions/private/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/private/Users/Get-GitHubUserCard.ps1 @@ -41,7 +41,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -61,7 +61,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/hovercard" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 index 1afb028a0..24605d5cc 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -51,7 +51,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/keys" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 index 6b7662e8a..2a3843b2f 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 @@ -27,7 +27,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -46,7 +46,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/keys' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 index fdcde9e97..59c126e8f 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/keys/$ID" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { 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 254ca5de4..6470b49fb 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 @@ -27,7 +27,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -46,7 +46,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/ssh_signing_keys' - Method = 'GET' + Method = 'Get' Body = $body } 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 903529875..6ad469d6b 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 @@ -30,7 +30,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -45,7 +45,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/ssh_signing_keys/$ID" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { 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 0e6653f9a..65fac2509 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -51,7 +51,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/ssh_signing_keys" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 index 8d5204a1a..67dc4a02f 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 @@ -25,7 +25,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/social_accounts' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 index ee82b7383..6caa6cbb9 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 @@ -28,7 +28,7 @@ # 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()] + [Parameter(Mandatory)] [GitHubContext] $Context ) @@ -43,7 +43,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/users/$Username/social_accounts" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index 570eb29dd..6490a2daf 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -28,7 +28,7 @@ filter Invoke-GitHubAPI { param( # The HTTP method to be used for the API request. It can be one of the following: GET, POST, PUT, DELETE, or PATCH. [Parameter()] - [Microsoft.PowerShell.Commands.WebRequestMethod] $Method = 'GET', + [Microsoft.PowerShell.Commands.WebRequestMethod] $Method = 'Get', # The base URI for the GitHub API. This is usually `https://api.github.com`, but can be adjusted if necessary. [Parameter( @@ -156,7 +156,7 @@ filter Invoke-GitHubAPI { if ($Body) { # Use body to create the query string for certain situations - if ($Method -eq 'GET') { + if ($Method -eq 'Get') { # If body conatins 'per_page' and its is null, set it to $context.PerPage if ($Body['per_page'] -eq 0) { Write-Debug "Setting per_page to the default value in context [$($Context.PerPage)]." diff --git a/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 index 809f34c9d..59b262daa 100644 --- a/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 @@ -57,7 +57,7 @@ process { $inputObject = @{ - Method = 'DELETE' + Method = 'Delete' APIEndpoint = "repos/$Owner/$Repository/actions/runs/$ID" Context = $Context } diff --git a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 index b1603a091..adf878062 100644 --- a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 @@ -64,7 +64,7 @@ try { $inputObject = @{ Context = $Context - Method = 'POST' + Method = 'Post' APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/rerun" } diff --git a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 index f0f3283f4..68b3c4400 100644 --- a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 @@ -54,7 +54,7 @@ process { try { $inputObject = @{ - Method = 'POST' + Method = 'Post' APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/cancel" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 index 0b5070875..420a807f4 100644 --- a/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 @@ -43,7 +43,7 @@ process { $inputObject = @{ - Method = 'PUT' + Method = 'Put' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/disable" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 index 26fe8df5d..3ba7036ed 100644 --- a/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 @@ -40,7 +40,7 @@ process { $inputObject = @{ - Method = 'PUT' + Method = 'Put' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/enable" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 index b925cf5b6..21e4d4efb 100644 --- a/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 @@ -61,7 +61,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows" Body = $body Context = $Context diff --git a/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 index 9fdcf09aa..3b27d7839 100644 --- a/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 @@ -49,7 +49,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/timing" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 index 5493adca6..c199754b3 100644 --- a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 @@ -76,7 +76,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/dispatches" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 index c15db0c18..5417dad11 100644 --- a/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 @@ -68,7 +68,7 @@ } $inputObject = @{ - Method = 'PATCH' + Method = 'Patch' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/add" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 index 3f5d442ac..43710de83 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 @@ -60,7 +60,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 index ffdb353de..277b0fb3f 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 @@ -70,7 +70,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 index e6934724c..56841d851 100644 --- a/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 @@ -68,7 +68,7 @@ } $inputObject = @{ - Method = 'PATCH' + Method = 'Patch' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/remove" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 index 309a890b1..583083d22 100644 --- a/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 @@ -83,7 +83,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'PATCH' + Method = 'Patch' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 index a8a9b4f28..49526d8a3 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 @@ -44,7 +44,7 @@ } $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations" Body = $body Context = $Context diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 index 9b4441214..32e48b5ab 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 @@ -35,7 +35,7 @@ process { $inputObject = @{ - Method = 'GET' + Method = 'Get' APIEndpoint = '/app/hook/config' Context = $Context } diff --git a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 index 931bc777f..574dfe353 100644 --- a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 @@ -63,7 +63,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'PATCH' + Method = 'Patch' APIEndpoint = '/app/hook/config' Body = $body Context = $Context diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 index 6617cd0dd..f93ffa69f 100644 --- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 +++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 @@ -51,7 +51,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/branches" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 index e8e61bbee..7c45bbdaf 100644 --- a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 +++ b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 @@ -47,7 +47,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/emojis' - Method = 'GET' + Method = 'Get' } $response = Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index 5c8633833..8ed9cc116 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -60,7 +60,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/markdown' - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 index cbdf5c1a6..9fbf73323 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 @@ -45,7 +45,7 @@ Context = $Context APIEndpoint = '/markdown/raw' ContentType = 'text/plain' - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 index 6b97d9e2f..d3cae18e0 100644 --- a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 +++ b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 @@ -35,7 +35,7 @@ $inputObject = @{ Context = $Context ApiEndpoint = '/versions' - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Meta/Get-GitHubMeta.ps1 b/src/functions/public/Meta/Get-GitHubMeta.ps1 index 1aa4ece02..0a5e2dd2d 100644 --- a/src/functions/public/Meta/Get-GitHubMeta.ps1 +++ b/src/functions/public/Meta/Get-GitHubMeta.ps1 @@ -43,7 +43,7 @@ $inputObject = @{ Context = $Context ApiEndpoint = '/meta' - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Meta/Get-GitHubOctocat.ps1 b/src/functions/public/Meta/Get-GitHubOctocat.ps1 index 9ea7534f3..9048e3577 100644 --- a/src/functions/public/Meta/Get-GitHubOctocat.ps1 +++ b/src/functions/public/Meta/Get-GitHubOctocat.ps1 @@ -50,7 +50,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/octocat' - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Meta/Get-GitHubRoot.ps1 b/src/functions/public/Meta/Get-GitHubRoot.ps1 index 566100b1f..0afcc17f7 100644 --- a/src/functions/public/Meta/Get-GitHubRoot.ps1 +++ b/src/functions/public/Meta/Get-GitHubRoot.ps1 @@ -34,7 +34,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/' - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Meta/Get-GitHubZen.ps1 b/src/functions/public/Meta/Get-GitHubZen.ps1 index 63cb00157..343950efb 100644 --- a/src/functions/public/Meta/Get-GitHubZen.ps1 +++ b/src/functions/public/Meta/Get-GitHubZen.ps1 @@ -34,7 +34,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/zen' - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 index 65b05a70e..ad7c7e81e 100644 --- a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 @@ -94,7 +94,7 @@ $inputObject = @{ Context = $Context Body = $body - Method = 'post' + Method = 'Post' APIEndpoint = "/orgs/$Organization/invitations" } diff --git a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 index 183ebdf38..e31149e05 100644 --- a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 @@ -48,7 +48,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Organization/invitations/$ID" - Method = 'DELETE' + Method = 'Delete' } try { diff --git a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 index 1bab1df3c..4ea7797df 100644 --- a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 @@ -54,7 +54,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Organization" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Delete')) { diff --git a/src/functions/public/Organization/Update-GitHubOrganization.ps1 b/src/functions/public/Organization/Update-GitHubOrganization.ps1 index b35e250f1..b622b7d74 100644 --- a/src/functions/public/Organization/Update-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganization.ps1 @@ -215,7 +215,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Organization" - Method = 'PATCH' + Method = 'Patch' Body = $body } diff --git a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 index 44bd8682e..ee7f74dc8 100644 --- a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 @@ -95,7 +95,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 index 4fbb270c2..1cc13fbb0 100644 --- a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 +++ b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 @@ -52,7 +52,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/rate_limit' - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 index c488874d8..76c13cd5f 100644 --- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 @@ -141,7 +141,7 @@ $inputObject = @{ URI = $uploadURI - Method = 'POST' + Method = 'Post' ContentType = $ContentType UploadFilePath = $FilePath } diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 index 9caa5feed..292f91073 100644 --- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 @@ -57,7 +57,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("Asset with ID [$ID] in [$Owner/$Repo]", 'Delete')) { diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 index 52ad07ce7..48028fd4f 100644 --- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 @@ -78,7 +78,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" - Method = 'PATCH' + Method = 'Patch' Body = $body } diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 index 7b73687c1..f9f244472 100644 --- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 @@ -117,7 +117,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases" - Method = 'POST' + Method = 'Post' Body = $requestBody } diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 index 7b7c90a8c..7e481e27c 100644 --- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 @@ -125,7 +125,7 @@ $inputObject = @{ APIEndpoint = "/repos/$Owner/$Repo/releases/generate-notes" - Method = 'POST' + Method = 'Post' Body = $requestBody } diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 index 6539d0dc3..9bb21bb3c 100644 --- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 @@ -60,7 +60,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("Release with ID [$ID] in [$Owner/$Repo]", 'Delete')) { diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 index d2517ae57..996e45a62 100644 --- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 @@ -114,7 +114,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'PATCH' + Method = 'Patch' Body = $requestBody } diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 index 82e09218f..e269e7075 100644 --- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 @@ -76,7 +76,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/autolinks" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 index 9e3070a34..c1428e3fb 100644 --- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 @@ -61,7 +61,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" - Method = 'DELETE' + Method = 'Delete' Body = $body } diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 index 0e30677db..8cdeee215 100644 --- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 +++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 @@ -57,7 +57,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/properties/values" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index ce87b3528..9d92caa3b 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -56,7 +56,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Disable')) { diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 index c390ff1b8..f1fead763 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 @@ -56,7 +56,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Disable')) { diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 index bc9690d9e..2b2e31010 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -56,7 +56,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Disable')) { diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index 2236d79fc..16c7779ed 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -56,7 +56,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" - Method = 'PUT' + Method = 'Put' } if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Enable')) { diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 index 47d8cf67e..a732a8b67 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 @@ -56,7 +56,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'PUT' + Method = 'Put' } if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Enable')) { diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 index 7709b0937..15446f077 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -57,7 +57,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" - Method = 'PUT' + Method = 'Put' } if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Enable')) { diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index 839b4be6f..1758993bf 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -141,7 +141,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/activity" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 index cbc4ebbaa..64d80dd27 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 @@ -67,7 +67,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 index f7562b5f6..cb0b79d77 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 @@ -73,7 +73,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/contributors" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 index 3986c856e..d657fdde4 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 @@ -69,7 +69,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/forks" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 index cbecbb6ff..8e6a63bd8 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 @@ -55,7 +55,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/languages" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 index c109b2f9d..a5243c14b 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 @@ -57,7 +57,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 index 0d5c31fbc..034a8fbc8 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 @@ -63,7 +63,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/tags" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 index b17f5777c..b25a70850 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 @@ -71,7 +71,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/teams" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 index 83e414d77..e7cd218e9 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 @@ -59,7 +59,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/topics" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 index 038962e12..2b17af78e 100644 --- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 @@ -80,7 +80,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/transfer" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 index da62375ad..d4dddd7eb 100644 --- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 @@ -58,7 +58,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repo]", 'Delete')) { diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 index 8bd672d00..e775fda0f 100644 --- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 @@ -62,7 +62,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/topics" - Method = 'PUT' + Method = 'Put' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 index 59694f66f..77c6b8f59 100644 --- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 +++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 @@ -96,7 +96,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/dispatches" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 index ee3d67b7b..c1b7dff33 100644 --- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 @@ -57,7 +57,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" - Method = 'GET' + Method = 'Get' } try { diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 index 614c19f3c..68e37615d 100644 --- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 @@ -235,7 +235,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo" - Method = 'PATCH' + Method = 'Patch' Body = $body } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 index a4b1dc3b6..5ecc552ae 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 @@ -60,7 +60,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 index cb18ef6f4..7d2d5088c 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 @@ -99,7 +99,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites" - Method = 'GET' + Method = 'Get' Body = $body } diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 index 69f68deb4..51a332af0 100644 --- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 @@ -56,7 +56,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/tags/protection" - Method = 'GET' + Method = 'Get' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 index 66612fc1c..e11860a33 100644 --- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 @@ -63,7 +63,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/tags/protection" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 index 54aab7946..fe1283962 100644 --- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 @@ -59,7 +59,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repo]", 'Delete')) { diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1 index b7163c226..3fce6a57e 100644 --- a/src/functions/public/Teams/New-GitHubTeam.ps1 +++ b/src/functions/public/Teams/New-GitHubTeam.ps1 @@ -118,7 +118,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/orgs/$Organization/teams" - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 index 3a2587561..d6676ba2f 100644 --- a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 @@ -50,7 +50,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/emails' - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 index 643e053af..1f3e68a9d 100644 --- a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 @@ -48,7 +48,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/emails' - Method = 'DELETE' + Method = 'Delete' Body = $body } diff --git a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 index 8436e6067..cbe16643e 100644 --- a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 +++ b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 @@ -54,7 +54,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/email/visibility' - Method = 'PATCH' + Method = 'Patch' Body = $body } diff --git a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 index 7ff3a5afc..0160b1e78 100644 --- a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 @@ -46,7 +46,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/following/$Username" - Method = 'PUT' + Method = 'Put' } $null = Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 index c337a6e36..472258b60 100644 --- a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/following/$Username" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("User [$Username]", 'Unfollow')) { diff --git a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 index 230fff1fe..71b755eed 100644 --- a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 @@ -64,7 +64,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/gpg_keys' - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 index 5f1449afd..e29c5475e 100644 --- a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 @@ -44,7 +44,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/gpg_keys/$ID" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) { diff --git a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 index 914060868..29368652f 100644 --- a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 @@ -58,7 +58,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/keys' - Method = 'POST' + Method = 'Post' Body = $body } diff --git a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 index 917b3bc99..6238a86eb 100644 --- a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 @@ -45,7 +45,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/keys/$ID" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("Key with ID [$ID]", 'Delete')) { 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 7484e2f7d..74ef4590e 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 @@ -60,7 +60,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user/ssh_signing_keys' - Method = 'POST' + Method = 'Post' Body = $body } 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 41704ce8f..61d001e20 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 @@ -46,7 +46,7 @@ $inputObject = @{ Context = $Context APIEndpoint = "/user/ssh_signing_keys/$ID" - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) { diff --git a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 index 363aad47d..b7b3bdd97 100644 --- a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 @@ -47,7 +47,7 @@ Context = $Context APIEndpoint = '/user/social_accounts' Body = $body - Method = 'POST' + Method = 'Post' } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 index dcc0e3816..7870f8a53 100644 --- a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 @@ -48,7 +48,7 @@ Context = $Context APIEndpoint = '/user/social_accounts' Body = $body - Method = 'DELETE' + Method = 'Delete' } if ($PSCmdlet.ShouldProcess("Social accounts [$($AccountUrls -join ', ')]", 'Delete')) { diff --git a/src/functions/public/Users/Update-GitHubUser.ps1 b/src/functions/public/Users/Update-GitHubUser.ps1 index 6d8a4ed33..f1d5cf800 100644 --- a/src/functions/public/Users/Update-GitHubUser.ps1 +++ b/src/functions/public/Users/Update-GitHubUser.ps1 @@ -91,7 +91,7 @@ $inputObject = @{ Context = $Context APIEndpoint = '/user' - Method = 'PATCH' + Method = 'Patch' Body = $body } diff --git a/tools/Guidelines.md b/tools/Guidelines.md index 9b37c43e5..04c65cf3e 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -5,6 +5,7 @@ Writing down guidelines so that it can be the basis for pester tests. ## Functions - Group functions by the object type they are working with in a folder based on the name of the object, NOT based on the API. +- DefaultParameterSetName must never be declared unless its different the default parameter set. ### Name From ff2246d0eeb0d4ed12e0fdce7df0da656d6193ae Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 00:46:58 +0100 Subject: [PATCH 37/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Enforce=20ma?= =?UTF-8?q?ndatory=20parameter=20for=20`$Enterprise`=20and=20standardize?= =?UTF-8?q?=20parameter=20handling=20across=20multiple=20functions=20for?= =?UTF-8?q?=20improved=20clarity=20and=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeviceFlow/Request-GitHubAccessToken.ps1 | 8 +- .../DeviceFlow/Request-GitHubDeviceCode.ps1 | 4 +- .../Gitignore/Get-GitHubGitignoreList.ps1 | 18 +-- .../License/Get-GitHubLicenseByName.ps1 | 4 +- .../Get-GitHubAllOrganization.ps1 | 28 ++--- .../Organization/Get-GitHubMyOrganization.ps1 | 26 ++--- .../Get-GitHubOrganizationByName.ps1 | 18 ++- .../Get-GitHubUserOrganization.ps1 | 26 ++--- .../Assets/Get-GitHubReleaseAssetByID.ps1 | 28 ++--- .../Get-GitHubReleaseAssetByReleaseID.ps1 | 26 ++--- .../Releases/Get-GitHubReleaseAll.ps1 | 35 ++---- .../Releases/Get-GitHubReleaseByID.ps1 | 27 ++--- .../Releases/Get-GitHubReleaseByTagName.ps1 | 27 ++--- .../Releases/Get-GitHubReleaseLatest.ps1 | 27 ++--- .../Get-GitHubRepositoryAutolinkById.ps1 | 27 ++--- .../Get-GitHubRepositoryAutolinkList.ps1 | 28 ++--- .../Fork/New-GitHubRepositoryAsFork.ps1 | 46 +++----- .../Repositories/Get-GitHubMyRepositories.ps1 | 58 +++++----- .../Get-GitHubRepositoryByName.ps1 | 28 ++--- .../Get-GitHubRepositoryListByID.ps1 | 26 ++--- .../Get-GitHubRepositoryListByOrg.ps1 | 40 +++---- .../Get-GitHubRepositoryListByUser.ps1 | 43 +++---- .../New-GitHubRepositoryFromTemplate.ps1 | 40 +++---- .../Repositories/New-GitHubRepositoryOrg.ps1 | 72 ++++++------ .../Repositories/New-GitHubRepositoryUser.ps1 | 68 ++++++----- .../Teams/Get-GitHubRESTTeamByName.ps1 | 26 ++--- .../Teams/Get-GitHubRESTTeamListByOrg.ps1 | 26 ++--- .../private/Teams/Get-GitHubRepoTeam.ps1 | 32 ++---- .../Users/Blocking/Block-GitHubUserByUser.ps1 | 17 +-- .../Blocking/Get-GitHubBlockedUserByUser.ps1 | 30 +++-- .../Blocking/Test-GitHubBlockedUserByUser.ps1 | 32 ++---- .../Blocking/Unblock-GitHubUserByUser.ps1 | 22 +--- .../Users/Emails/Get-GitHubUserAllEmail.ps1 | 28 ++--- .../Emails/Get-GitHubUserPublicEmail.ps1 | 26 ++--- .../Get-GitHubUserFollowersOfUser.ps1 | 26 ++--- .../Followers/Get-GitHubUserFollowingMe.ps1 | 30 +++-- .../Followers/Get-GitHubUserFollowingUser.ps1 | 26 ++--- .../Followers/Get-GitHubUserMyFollowers.ps1 | 35 +++--- .../Followers/Test-GitHubUserFollowedByMe.ps1 | 16 +-- .../Test-GitHubUserFollowedByUser.ps1 | 15 +-- .../GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 | 27 ++--- .../Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 | 26 ++--- .../GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 | 20 ++-- .../private/Users/Get-GitHubAllUser.ps1 | 28 ++--- .../private/Users/Get-GitHubMyUser.ps1 | 20 ++-- .../private/Users/Get-GitHubUserByName.ps1 | 18 ++- .../private/Users/Get-GitHubUserCard.ps1 | 28 ++--- .../Users/Keys/Get-GitHubUserKeyForUser.ps1 | 27 ++--- .../Users/Keys/Get-GitHubUserMyKey.ps1 | 26 ++--- .../Users/Keys/Get-GitHubUserMyKeyById.ps1 | 20 ++-- .../Get-GitHubUserMySigningKey.ps1 | 26 ++--- .../Get-GitHubUserMySigningKeyById.ps1 | 20 ++-- .../Get-GitHubUserSigningKeyForUser.ps1 | 27 ++--- .../Get-GitHubMyUserSocials.ps1 | 30 +++-- .../Get-GitHubUserSocialsByName.ps1 | 20 ++-- src/functions/public/API/Invoke-GitHubAPI.ps1 | 1 + .../Restart-GitHubWorkflowRun.ps1 | 29 ++--- .../Workflow Run/Stop-GitHubWorkflowRun.ps1 | 22 ++-- .../Actions/Workflow/Start-GitHubWorkflow.ps1 | 4 +- .../Get-GitHubAppInstallableOrganization.ps1 | 2 +- .../Invoke-GitHubAppWebhookReDelivery.ps1 | 8 +- .../public/Auth/Connect-GitHubAccount.ps1 | 6 - .../public/Branches/Get-GitHubRepoBranch.ps1 | 27 ++--- .../public/Emojis/Get-GitHubEmoji.ps1 | 62 +++++----- .../GraphQL/Invoke-GitHubGraphQLQuery.ps1 | 30 +++-- .../public/Markdown/Get-GitHubMarkdown.ps1 | 30 +++-- .../public/Markdown/Get-GitHubMarkdownRaw.ps1 | 31 +++-- .../public/Meta/Get-GitHubApiVersion.ps1 | 20 ++-- src/functions/public/Meta/Get-GitHubMeta.ps1 | 20 ++-- .../public/Meta/Get-GitHubOctocat.ps1 | 30 ++--- src/functions/public/Meta/Get-GitHubRoot.ps1 | 20 ++-- src/functions/public/Meta/Get-GitHubZen.ps1 | 20 ++-- .../Members/Get-GitHubOrganizationMember.ps1 | 36 +++--- ...et-GitHubOrganizationPendingInvitation.ps1 | 36 +++--- .../New-GitHubOrganizationInvitation.ps1 | 42 +++---- .../Remove-GitHubOrganizationInvitation.ps1 | 25 ++-- .../Remove-GitHubOrganization.ps1 | 28 ++--- .../Update-GitHubOrganization.ps1 | 88 +++++++------- ...date-GitHubOrganizationSecurityFeature.ps1 | 36 ++---- .../public/Rate-Limit/Get-GitHubRateLimit.ps1 | 18 ++- .../Assets/Add-GitHubReleaseAsset.ps1 | 104 ++++++++--------- .../Assets/Remove-GitHubReleaseAsset.ps1 | 34 ++---- .../Assets/Set-GitHubReleaseAsset.ps1 | 48 +++----- .../Releases/Releases/New-GitHubRelease.ps1 | 60 ++++------ .../Releases/New-GitHubReleaseNote.ps1 | 48 +++----- .../Releases/Remove-GitHubRelease.ps1 | 34 ++---- .../Releases/Releases/Set-GitHubRelease.ps1 | 58 ++++------ .../New-GitHubRepositoryAutolink.ps1 | 44 +++---- .../Remove-GitHubRepositoryAutolink.ps1 | 39 +++---- .../Get-GitHubRepositoryCustomProperty.ps1 | 33 ++---- ...epositoryPrivateVulnerabilityReporting.ps1 | 35 ++---- .../Disable-GitHubRepositorySecurityFix.ps1 | 35 ++---- ...ble-GitHubRepositoryVulnerabilityAlert.ps1 | 35 ++---- ...epositoryPrivateVulnerabilityReporting.ps1 | 35 ++---- .../Enable-GitHubRepositorySecurityFix.ps1 | 35 ++---- ...ble-GitHubRepositoryVulnerabilityAlert.ps1 | 35 ++---- .../Get-GitHubRepositoryActivity.ps1 | 57 ++++------ .../Get-GitHubRepositoryCodeownersError.ps1 | 43 +++---- .../Get-GitHubRepositoryContributor.ps1 | 45 +++----- .../Repositories/Get-GitHubRepositoryFork.ps1 | 45 +++----- .../Get-GitHubRepositoryLanguage.ps1 | 33 ++---- .../Get-GitHubRepositorySecurityFix.ps1 | 33 ++---- .../Repositories/Get-GitHubRepositoryTag.ps1 | 41 +++---- .../Repositories/Get-GitHubRepositoryTeam.ps1 | 41 +++---- .../Get-GitHubRepositoryTopic.ps1 | 41 +++---- .../Repositories/Move-GitHubRepository.ps1 | 47 +++----- .../Repositories/Remove-GitHubRepository.ps1 | 37 ++---- .../Set-GitHubRepositoryTopic.ps1 | 43 +++---- .../Start-GitHubRepositoryEvent.ps1 | 45 +++----- ...est-GitHubRepositoryVulnerabilityAlert.ps1 | 29 +---- .../Repositories/Update-GitHubRepository.ps1 | 107 ++++++++---------- .../Get-GitHubRepositoryRuleSuiteById.ps1 | 33 ++---- .../Get-GitHubRepositoryRuleSuiteList.ps1 | 51 ++++----- .../Get-GitHubRepositoryTagProtection.ps1 | 33 ++---- .../New-GitHubRepositoryTagProtection.ps1 | 43 +++---- .../Remove-GitHubRepositoryTagProtection.ps1 | 35 ++---- src/functions/public/Teams/New-GitHubTeam.ps1 | 86 +++++++------- .../public/Teams/Remove-GitHubTeam.ps1 | 31 ++--- .../public/Teams/Update-GitHubTeam.ps1 | 88 +++++++------- .../Users/Emails/Add-GitHubUserEmail.ps1 | 30 +++-- .../Users/Emails/Remove-GitHubUserEmail.ps1 | 30 +++-- .../Update-GitHubUserEmailVisibility.ps1 | 28 ++--- .../Followers/Add-GitHubUserFollowing.ps1 | 18 +-- .../Followers/Remove-GitHubUserFollowing.ps1 | 20 ++-- .../Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 | 30 +++-- .../GPG-Keys/Remove-GitHubUserGpgKey.ps1 | 20 ++-- .../public/Users/Keys/Add-GitHubUserKey.ps1 | 28 ++--- .../Users/Keys/Remove-GitHubUserKey.ps1 | 20 ++-- .../Add-GitHubUserSigningKey.ps1 | 28 ++--- .../Remove-GitHubUserSigningKey.ps1 | 20 ++-- .../Social-Accounts/Add-GitHubUserSocial.ps1 | 30 +++-- .../Remove-GitHubUserSocial.ps1 | 32 +++--- .../public/Users/Update-GitHubUser.ps1 | 44 ++++--- 133 files changed, 1653 insertions(+), 2723 deletions(-) diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 index ee06820a4..37022a64f 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 @@ -66,11 +66,15 @@ } } + $headers = @{ + 'Accept' = 'application/json' + } + $RESTParams = @{ - Uri = "https://$HostName/login/oauth/access_token" Method = 'Post' + Uri = "https://$HostName/login/oauth/access_token" + Headers = $headers Body = $body - Headers = @{ 'Accept' = 'application/json' } } try { diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 index b07cddbe9..2137e9d26 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 @@ -50,10 +50,10 @@ } $RESTParams = @{ - Uri = "https://$HostName/login/device/code" Method = 'Post' - Body = $body + Uri = "https://$HostName/login/device/code" Headers = $headers + Body = $body } try { diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index 2040bcdcd..27d493e75 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -32,15 +32,15 @@ } process { - $inputObject = @{ - Method = 'Get' - APIEndpoint = '/gitignore/templates' - Context = $Context - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/gitignore/templates' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } } end { diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index 4a5492f99..775d556ca 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -38,10 +38,10 @@ process { $inputObject = @{ - Context = $Context + Method = 'Get' APIEndpoint = "/licenses/$Name" Accept = 'application/vnd.github+json' - Method = 'Get' + Context = $Context } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index 7a3db22d4..13788020a 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -44,24 +44,20 @@ } process { - try { - $body = @{ - since = $Since - per_page = $PerPage - } + $body = @{ + since = $Since + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/organizations' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/organizations' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index 67d62a5af..2e7de44bc 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -43,23 +43,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/orgs' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/orgs' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index 7a4606df6..b89e67ed8 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -49,18 +49,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index 6a18fb69d..a60448efc 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -45,23 +45,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/orgs" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/orgs" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index d91b42d59..6ba7f3761 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -43,31 +43,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index def1707c1..1eb39a5e1 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -60,23 +60,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index 2d842a0b9..b1b658f8e 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -42,35 +42,22 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 58934a45c..5d35a3d69 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -41,30 +41,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index b568ba97c..9165b2cc0 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -40,30 +40,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index 4adbd820b..c452767aa 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -37,30 +37,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/latest" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/latest" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index 30592b66e..55e607925 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -44,30 +44,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index d57cce3a1..95638fab0 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -21,7 +21,6 @@ param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -38,30 +37,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/autolinks" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index b97e49c86..aeeaf0026 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -72,44 +72,26 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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]" - - if ([string]::IsNullorEmpty($Name)) { - $Name = $Repo - } - Write-Debug "Name: [$Name]" } process { - try { - $body = @{ - organization = $Organization - name = $Name - default_branch_only = $DefaultBranchOnly - } + $body = @{ + organization = $Organization + name = $Name + default_branch_only = $DefaultBranchOnly + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/forks" - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/forks" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index e23287174..12c81202e 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -120,41 +120,37 @@ } process { - try { - $body = @{ - sort = $Sort - direction = $Direction - per_page = $PerPage - } - 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') + $body = @{ + sort = $Sort + direction = $Direction + per_page = $PerPage + } + 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') + } + Write-Debug "ParamSet: [$($PSCmdlet.ParameterSetName)]" + switch ($PSCmdlet.ParameterSetName) { + 'Aff-Vis' { + $body['affiliation'] = $Affiliation -join ',' + $body['visibility'] = $Visibility } - Write-Debug "ParamSet: [$($PSCmdlet.ParameterSetName)]" - switch ($PSCmdlet.ParameterSetName) { - 'Aff-Vis' { - $body['affiliation'] = $Affiliation -join ',' - $body['visibility'] = $Visibility - } - 'Type' { - $body['type'] = $Type - } + 'Type' { + $body['type'] = $Type } + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/repos' - Method = 'Get' - body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/repos' + body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index 56c487a65..98645f6e0 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -40,31 +40,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index f334742d4..04a904b5e 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -40,23 +40,19 @@ } process { - try { - $body = @{ - since = $Since - } + $body = @{ + since = $Since + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/repositories' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/repositories' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index aa8a76978..0c1ea9773 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -66,33 +66,25 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - Write-Debug "Owner: [$Owner]" } 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 $_ + $body = @{ + sort = $Sort + type = $Type + direction = $Direction + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Owner/repos" + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index 0d07294d3..6f3930ef6 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -68,38 +68,25 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + } + + process { + $body = @{ + sort = $Sort + type = $Type + direction = $Direction + per_page = $PerPage } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/repos" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index 2e13290ed..a00eae03e 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -82,36 +82,28 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - Write-Debug "Owner: [$Owner]" } process { - try { - $body = @{ - owner = $Owner - name = $Name - description = $Description - include_all_branches = $IncludeAllBranches - private = $Private - } + $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 - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$TemplateOwner/$TemplateRepo/generate" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 96c94d150..1304ffca0 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -217,52 +217,44 @@ filter New-GitHubRepositoryOrg { Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT $GitignoreTemplate = $PSBoundParameters['GitignoreTemplate'] $LicenseTemplate = $PSBoundParameters['LicenseTemplate'] - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - Write-Debug "Owner: [$Owner]" } process { - 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 = @{ + 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' + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Owner/repos" - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Owner/repos" + Body = $body + Context = $Context + } - 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 $_ } } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index f9820e3b9..377b12622 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -214,45 +214,41 @@ filter New-GitHubRepositoryUser { } process { - 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 = @{ + 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' + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/repos' - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/repos' + Body = $body + Context = $Context + } - 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 $_ } } diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index a4e768f83..0a2e1b0a2 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -20,7 +20,6 @@ # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. @@ -33,26 +32,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/teams/$Name" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/teams/$Name" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index 140b39819..bfbdfa6bd 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -17,7 +17,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. @@ -30,26 +29,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/teams" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/teams" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index e12284db1..407b6e657 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -5,10 +5,10 @@ #> [CmdletBinding()] param( - [Parameter()] + [Parameter(Mandatory)] [string] $Owner, - [Parameter()] + [Parameter(Mandatory)] [string] $Repo, # The context to run the command in. Used to get the details for the API call. @@ -21,31 +21,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/teams" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/teams" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index 67059156d..9c917a354 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -41,23 +41,12 @@ process { $inputObject = @{ - Context = $Context - APIEndpoint = "/user/blocks/$Username" Method = 'Put' + APIEndpoint = "/user/blocks/$Username" + Context = $Context } - 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 $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index 618d3ddaa..72e0cfe8c 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -35,23 +35,19 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/blocks' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index 1d90470e1..0122933d7 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -47,30 +47,18 @@ } process { - try { - $body = @{ - per_page = $PerPage - } - - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/blocks/$Username" - Method = 'Get' - Body = $body - } + $body = @{ + per_page = $PerPage + } - try { - (Invoke-GitHubAPI @inputObject).StatusCode -eq 204 - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/blocks/$Username" + Body = $body + Context = $Context } + + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index aeac50965..a6faaff90 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -40,23 +40,13 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/blocks/$Username" - Method = 'Delete' - } - - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - Write-Error $_.Exception.Response - throw $_ - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/blocks/$Username" + Context = $Context } + + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index d397046aa..ff42b473a 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -37,22 +37,18 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/emails' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index 22bc84b49..678c218fa 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -39,23 +39,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/public_emails' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/public_emails' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index 5f9c182b9..ecd946e7c 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -45,23 +45,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/followers" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/followers" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index a38dbe01d..397c7cf5f 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -36,23 +36,19 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/following' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index 48c5011ea..1dd8afb31 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -45,23 +45,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/following" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/following" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index 6b76ca2d9..112c6ce7c 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -16,7 +16,10 @@ #> [OutputType([pscustomobject])] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'Private function, not exposed to user.')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSUseSingularNouns', '', + Justification = 'Private function, not exposed to user.' + )] [CmdletBinding()] param( # The number of results per page (max 100). @@ -37,23 +40,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } - - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/followers' - Method = 'Get' - Body = $body - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/followers' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index ccb583d1d..83960bdd6 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -24,6 +24,7 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # The context to run the command in. Used to get the details for the API call. @@ -40,21 +41,12 @@ process { $inputObject = @{ - Context = $Context - APIEndpoint = "/user/following/$Username" Method = 'Get' + APIEndpoint = "/user/following/$Username" + Context = $Context } - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index 6409d48ed..f577993f2 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -46,21 +46,12 @@ process { $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/following/$Follows" Method = 'Get' + APIEndpoint = "/users/$Username/following/$Follows" + Context = $Context } - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 index 937f2e087..c13a4241c 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 @@ -23,6 +23,7 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # The number of results per page (max 100). @@ -43,23 +44,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/gpg_keys" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/gpg_keys" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 index 0bfce3b93..ad4d735c4 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/gpg_keys' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/gpg_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 index 04972070b..cd66be651 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 @@ -40,18 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/gpg_keys/$ID" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/gpg_keys/$ID" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 08649a960..08c162cf6 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -44,24 +44,20 @@ } process { - try { - $body = @{ - since = $Since - per_page = $PerPage - } + $body = @{ + since = $Since + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/users' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/users' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1 index af2e97c9d..93cc1a7f4 100644 --- a/src/functions/private/Users/Get-GitHubMyUser.ps1 +++ b/src/functions/private/Users/Get-GitHubMyUser.ps1 @@ -33,18 +33,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/user' - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1 index 7756da45b..3a521812e 100644 --- a/src/functions/private/Users/Get-GitHubUserByName.ps1 +++ b/src/functions/private/Users/Get-GitHubUserByName.ps1 @@ -51,18 +51,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 index 9e66efeb5..4bc77143e 100644 --- a/src/functions/private/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/private/Users/Get-GitHubUserCard.ps1 @@ -52,24 +52,20 @@ } process { - try { - $body = @{ - subject_type = $SubjectType - subject_id = $SubjectID - } + $body = @{ + subject_type = $SubjectType + subject_id = $SubjectID + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/hovercard" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/hovercard" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 index 24605d5cc..0dd50d01e 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 @@ -23,6 +23,7 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # The number of results per page (max 100). @@ -43,23 +44,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/keys" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/keys" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 index 2a3843b2f..5d3d92fcc 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/keys' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 index 59c126e8f..fe526f254 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 @@ -40,18 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/keys/$ID" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/keys/$ID" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 6470b49fb..a82601dd5 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/ssh_signing_keys' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/ssh_signing_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 6ad469d6b..3a3337488 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 @@ -41,18 +41,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/ssh_signing_keys/$ID" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/ssh_signing_keys/$ID" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 65fac2509..5e2d1af49 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 @@ -23,6 +23,7 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # The number of results per page (max 100). @@ -43,23 +44,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/ssh_signing_keys" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/ssh_signing_keys" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 index 67dc4a02f..9b5effa17 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 @@ -36,23 +36,19 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/social_accounts' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 index 6caa6cbb9..2182c1eae 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 @@ -39,18 +39,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/social_accounts" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/social_accounts" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index 6490a2daf..4f7e42990 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -45,6 +45,7 @@ filter Invoke-GitHubAPI { # The body of the API request. This can be a hashtable or a string. If a hashtable is provided, it will be converted to JSON. [Parameter()] + [Alias('Query')] [Object] $Body, # The 'Accept' header for the API request. If not provided, the default will be used by GitHub's API. diff --git a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 index adf878062..e8bad08dd 100644 --- a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 @@ -49,32 +49,19 @@ 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 { - $inputObject = @{ - Context = $Context - Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/rerun" - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/rerun" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Re-run')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Re-run')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 index 68b3c4400..b3db67aef 100644 --- a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 @@ -31,11 +31,11 @@ )] [string] $Repository, - [Alias('workflow_id', 'WorkflowID')] [Parameter( Mandatory, ValueFromPipelineByPropertyName )] + [Alias('workflow_id', 'WorkflowID')] [string] $ID, # The context to run the command in. Used to get the details for the API call. @@ -52,20 +52,16 @@ } process { - try { - $inputObject = @{ - Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/cancel" - Context = $Context - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/cancel" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Cancel/Stop workflow run')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Cancel/Stop workflow run')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 index c199754b3..dc469d41f 100644 --- a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 @@ -74,10 +74,10 @@ } $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/dispatches" Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/dispatches" Body = $body + Context = $Context } if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Start workflow')) { diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 index 49526d8a3..8cc6baf15 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 @@ -16,7 +16,7 @@ [CmdletBinding()] param( # The enterprise slug or ID. - [Parameter()] + [Parameter(Mandatory)] [string] $Enterprise, # The number of results per page (max 100). diff --git a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 index f902c6e07..88ddd4988 100644 --- a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 @@ -26,7 +26,11 @@ )] param( # The ID of the delivery. - [Parameter(Mandatory)] + [Parameter( + Mandatory, + ValueFromPipeline, + ValueFromPipelineByPropertyName + )] [Alias('delivery_id', 'DeliveryID')] [string] $ID, @@ -46,8 +50,8 @@ process { $inputObject = @{ Method = 'Post' - Context = $Context APIEndpoint = "/app/hook/deliveries/$ID/attempts" + Context = $Context } if ($PSCmdlet.ShouldProcess("[$ID]", 'Redeliver event')) { diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index 92ca09f6f..88ec28889 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -43,13 +43,7 @@ .NOTES [Authenticating to the REST API](https://docs.github.com/rest/overview/other-authentication-methods#authenticating-for-saml-sso) #> - [Alias('Connect-GHAccount')] [Alias('Connect-GitHub')] - [Alias('Connect-GH')] - [Alias('Login-GitHubAccount')] - [Alias('Login-GHAccount')] - [Alias('Login-GitHub')] - [Alias('Login-GH')] [OutputType([void])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 index f93ffa69f..8ba269e11 100644 --- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 +++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 @@ -35,30 +35,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/branches" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/branches" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 index 7c45bbdaf..04006591b 100644 --- a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 +++ b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 @@ -20,13 +20,10 @@ .NOTES [Get emojis](https://docs.github.com/rest/reference/emojis#get-emojis) #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The path to the directory where the emojis will be downloaded. - [Parameter( - Mandatory, - ParameterSetName = 'Download' - )] + [Parameter()] [string] $Destination, # The context to run the command in. Used to get the details for the API call. @@ -43,39 +40,34 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/emojis' - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/emojis' + Context = $Context + } - $response = Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response + $response = Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response - if ($PSCmdlet.ParameterSetName -eq 'Download') { - $failedEmojis = @() - if (-not (Test-Path -Path $Destination)) { - $null = New-Item -Path $Destination -ItemType Directory -Force - } - $failedEmojis = $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel { - $emoji = $_ - Write-Verbose "Downloading [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" - try { - Invoke-WebRequest -Uri $emoji.Value -OutFile "$using:Destination/$($emoji.Name).png" -RetryIntervalSec 1 -MaximumRetryCount 5 - } catch { - $emoji - Write-Warning "Could not download [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" - } - } - if ($failedEmojis.Count -gt 0) { - Write-Warning 'Failed to download the following emojis:' - $failedEmojis | Out-String -Stream | ForEach-Object { Write-Warning $_ } - } - } else { - $response + if (-not $Destination) { + $response + } + + $failedEmojis = @() + if (-not (Test-Path -Path $Destination)) { + $null = New-Item -Path $Destination -ItemType Directory -Force + } + $failedEmojis = $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel { + $emoji = $_ + Write-Verbose "Downloading [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" + try { + Invoke-WebRequest -Uri $emoji.Value -OutFile "$using:Destination/$($emoji.Name).png" -RetryIntervalSec 1 -MaximumRetryCount 5 + } catch { + Write-Warning "Could not download [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" } - } catch { - throw $_ + } + if ($failedEmojis.Count -gt 0) { + Write-Warning 'Failed to download the following emojis:' + $failedEmojis | Out-String -Stream | ForEach-Object { Write-Warning $_ } } } diff --git a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 index a34a49d2d..e3c13aee4 100644 --- a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 +++ b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 @@ -36,22 +36,20 @@ } process { - 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 $_ + $body = @{ + 'query' = $Query + 'variables' = $Variables + } + + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/graphql' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index 8ed9cc116..ab5cd81ff 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -50,25 +50,21 @@ } process { - try { - $body = @{ - context = $RepoContext - mode = $Mode - text = $Text - } + $body = @{ + context = $RepoContext + mode = $Mode + text = $Text + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/markdown' - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/markdown' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 index 9fbf73323..2b95365c8 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 @@ -37,23 +37,20 @@ } process { - try { - $body = @{ - text = $Text - } - $inputObject = @{ - Context = $Context - APIEndpoint = '/markdown/raw' - ContentType = 'text/plain' - Method = 'Post' - Body = $body - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $body = @{ + text = $Text + } + + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/markdown/raw' + ContentType = 'text/plain' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 index d3cae18e0..fed1c2fce 100644 --- a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 +++ b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 @@ -31,18 +31,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - ApiEndpoint = '/versions' - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + ApiEndpoint = '/versions' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubMeta.ps1 b/src/functions/public/Meta/Get-GitHubMeta.ps1 index 0a5e2dd2d..77861c59b 100644 --- a/src/functions/public/Meta/Get-GitHubMeta.ps1 +++ b/src/functions/public/Meta/Get-GitHubMeta.ps1 @@ -39,18 +39,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - ApiEndpoint = '/meta' - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + ApiEndpoint = '/meta' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubOctocat.ps1 b/src/functions/public/Meta/Get-GitHubOctocat.ps1 index 9048e3577..975c95ac8 100644 --- a/src/functions/public/Meta/Get-GitHubOctocat.ps1 +++ b/src/functions/public/Meta/Get-GitHubOctocat.ps1 @@ -24,9 +24,7 @@ param( # The words to show in Octocat's speech bubble [Parameter()] - [Alias('Say')] - [Alias('Saying')] - [string] $S, + [string] $Saying, # 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. @@ -42,23 +40,19 @@ } process { - try { - $body = @{ - s = $S - } + $body = @{ + s = $Saying + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/octocat' - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/octocat' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubRoot.ps1 b/src/functions/public/Meta/Get-GitHubRoot.ps1 index 0afcc17f7..bb21e6a0a 100644 --- a/src/functions/public/Meta/Get-GitHubRoot.ps1 +++ b/src/functions/public/Meta/Get-GitHubRoot.ps1 @@ -30,18 +30,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/' - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubZen.ps1 b/src/functions/public/Meta/Get-GitHubZen.ps1 index 343950efb..1acd7c953 100644 --- a/src/functions/public/Meta/Get-GitHubZen.ps1 +++ b/src/functions/public/Meta/Get-GitHubZen.ps1 @@ -30,18 +30,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/zen' - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/zen' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 index 05f0f1c51..e82ea1a19 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 @@ -15,7 +15,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # Filter members returned in the list. @@ -46,33 +45,24 @@ 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]" } process { - try { - $body = @{ - filter = $Filter - role = $Role - per_page = $PerPage - } + $body = @{ + filter = $Filter + role = $Role + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - Body = $body - Method = 'Get' - APIEndpoint = "/orgs/$Organization/members" - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/members" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 index 6b44e355a..cae4a29cf 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 @@ -26,7 +26,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # Filter invitations by their member role. @@ -55,33 +54,24 @@ 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]" } process { - try { - $body = @{ - role = $Role - invitation_source = $InvitationSource - per_page = $PerPage - } + $body = @{ + role = $Role + invitation_source = $InvitationSource + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - Body = $body - Method = 'Get' - APIEndpoint = "/orgs/$Organization/invitations" - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/invitations" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 index ad7c7e81e..4606230aa 100644 --- a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 @@ -29,7 +29,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # GitHub user ID for the person you are inviting. @@ -74,37 +73,28 @@ 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]" } process { - try { - $body = @{ - invitee_id = $PSBoundParameters.ContainsKey('InviteeID') ? $InviteeID : $null - email = $Email - role = $Role - team_ids = $TeamIDs - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + invitee_id = $PSBoundParameters.ContainsKey('InviteeID') ? $InviteeID : $null + email = $Email + role = $Role + team_ids = $TeamIDs + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - Body = $body - Method = 'Post' - APIEndpoint = "/orgs/$Organization/invitations" - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Organization/invitations" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$InviteeID$Email to organization $Organization", 'Invite')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$InviteeID$Email to organization $Organization", 'Invite')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 index e31149e05..73fd9158f 100644 --- a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 @@ -22,7 +22,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # The unique identifier of the invitation. @@ -44,24 +43,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/invitations/$ID" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/orgs/$Organization/invitations/$ID" + Context = $Context + } - try { - if ($PSCmdlet.ShouldProcess('GitHub Organization invitation', 'Remove')) { - $null = (Invoke-GitHubAPI @inputObject) - } - return $true - } catch { - Write-Error $_.Exception.Response - throw $_ - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess('GitHub Organization invitation', 'Remove')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 index 4ea7797df..b98b5bf0c 100644 --- a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 @@ -26,9 +26,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] - [Alias('login')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. @@ -42,28 +39,19 @@ 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]" } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/orgs/$Organization" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Organization/Update-GitHubOrganization.ps1 b/src/functions/public/Organization/Update-GitHubOrganization.ps1 index b622b7d74..30f972cf0 100644 --- a/src/functions/public/Organization/Update-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganization.ps1 @@ -14,9 +14,9 @@ .EXAMPLE $param = @{ - Organization = 'GitHub' - MembersCanCreatePublicRepositories = $true - MembersCanCreatePrivateRepositories = $true + Organization = 'GitHub' + MembersCanCreatePublicRepositories = $true + MembersCanCreatePrivateRepositories = $true MembersCanCreateInternalRepositories = $true } Update-GitHubOrganization @param @@ -40,9 +40,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] - [Alias('login')] [string] $Organization, # Billing email address. This address is not publicized. @@ -176,56 +173,47 @@ 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]" } process { - try { - $body = @{ - name = $Name - billing_email = $BillingEmail - blog = $Blog - company = $Company - description = $Description - email = $Email - location = $Location - twitter_username = $TwitterUsername - has_organization_projects = $PSBoundParameters.ContainsKey('HasOrganizationProjects') ? $HasOrganizationProjects : $null - has_repository_projects = $PSBoundParameters.ContainsKey('HasRepositoryProjects') ? $HasRepositoryProjects : $null - default_repository_permission = $PSBoundParameters.ContainsKey('DefaultRepositoryPermission') ? $DefaultRepositoryPermission : $null - members_can_create_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateRepositories') ? $MembersCanCreateRepositories : $null - members_can_create_internal_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateInternalRepositories') ? $MembersCanCreateInternalRepositories : $null - members_can_create_private_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePrivateRepositories') ? $MembersCanCreatePrivateRepositories : $null - members_can_create_public_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePublicRepositories') ? $MembersCanCreatePublicRepositories : $null - members_can_create_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePages') ? $MembersCanCreatePages : $null - members_can_create_public_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePublicPages') ? $MembersCanCreatePublicPages : $null - members_can_create_private_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePrivatePages') ? $MembersCanCreatePrivatePages : $null - members_can_fork_private_repositories = $PSBoundParameters.ContainsKey('MembersCanForkPrivateRepositories') ? $MembersCanForkPrivateRepositories : $null - web_commit_signoff_required = $PSBoundParameters.ContainsKey('WebCommitSignoffRequired') ? $WebCommitSignoffRequired : $null - secret_scanning_push_protection_enabled_for_new_repositories = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionEnabledForNewRepositories') ? $SecretScanningPushProtectionEnabledForNewRepositories : $null - secret_scanning_push_protection_custom_link_enabled = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLinkEnabled') ? $SecretScanningPushProtectionCustomLinkEnabled : $null - secret_scanning_push_protection_custom_link = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLink') ? $SecretScanningPushProtectionCustomLink : $null - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + name = $Name + billing_email = $BillingEmail + blog = $Blog + company = $Company + description = $Description + email = $Email + location = $Location + twitter_username = $TwitterUsername + has_organization_projects = $PSBoundParameters.ContainsKey('HasOrganizationProjects') ? $HasOrganizationProjects : $null + has_repository_projects = $PSBoundParameters.ContainsKey('HasRepositoryProjects') ? $HasRepositoryProjects : $null + default_repository_permission = $PSBoundParameters.ContainsKey('DefaultRepositoryPermission') ? $DefaultRepositoryPermission : $null + members_can_create_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateRepositories') ? $MembersCanCreateRepositories : $null + members_can_create_internal_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateInternalRepositories') ? $MembersCanCreateInternalRepositories : $null + members_can_create_private_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePrivateRepositories') ? $MembersCanCreatePrivateRepositories : $null + members_can_create_public_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePublicRepositories') ? $MembersCanCreatePublicRepositories : $null + members_can_create_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePages') ? $MembersCanCreatePages : $null + members_can_create_public_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePublicPages') ? $MembersCanCreatePublicPages : $null + members_can_create_private_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePrivatePages') ? $MembersCanCreatePrivatePages : $null + members_can_fork_private_repositories = $PSBoundParameters.ContainsKey('MembersCanForkPrivateRepositories') ? $MembersCanForkPrivateRepositories : $null + web_commit_signoff_required = $PSBoundParameters.ContainsKey('WebCommitSignoffRequired') ? $WebCommitSignoffRequired : $null + secret_scanning_push_protection_enabled_for_new_repositories = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionEnabledForNewRepositories') ? $SecretScanningPushProtectionEnabledForNewRepositories : $null + secret_scanning_push_protection_custom_link_enabled = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLinkEnabled') ? $SecretScanningPushProtectionCustomLinkEnabled : $null + secret_scanning_push_protection_custom_link = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLink') ? $SecretScanningPushProtectionCustomLink : $null + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization" - Method = 'Patch' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/orgs/$Organization" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 index ee7f74dc8..802fb86c3 100644 --- a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 @@ -27,9 +27,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] - [Alias('owner')] - [Alias('login')] [string] $Organization, # The security feature to enable or disable. @@ -79,33 +76,24 @@ 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]" } process { - try { - $body = @{ - query_suite = $QuerySuite - } + $body = @{ + query_suite = $QuerySuite + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement" - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("security feature [$SecurityProduct] on organization [$Organization]", 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("security feature [$SecurityProduct] on organization [$Organization]", 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 index 1cc13fbb0..bdba61482 100644 --- a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 +++ b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 @@ -48,18 +48,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/rate_limit' - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/rate_limit' + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.Resources - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.Resources } } diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 index 76c13cd5f..0d8203d49 100644 --- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 @@ -47,11 +47,13 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] [string] $Repo, # The unique identifier of the release. @@ -73,7 +75,7 @@ # The path to the asset file. [Parameter(Mandatory)] - [alias('fullname')] + [alias('FullName')] [string] $FilePath, # The context to run the command in. Used to get the details for the API call. @@ -87,70 +89,56 @@ 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 { - # If name is not provided, use the name of the file - if (!$Name) { - $Name = (Get-Item $FilePath).Name - } + # 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 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' } - } + # 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)" + $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 - } + $inputObject = @{ + Method = 'Post' + URI = $uploadURI + ContentType = $ContentType + UploadFilePath = $FilePath + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 index 292f91073..4816a18a0 100644 --- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 @@ -17,7 +17,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -40,33 +42,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 index 48028fd4f..44a452b34 100644 --- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 @@ -18,7 +18,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -54,41 +56,27 @@ 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 = @{ - name = $Name - label = $Label - state = $State - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $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 - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repo]", 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repo]", 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 index f9f244472..1c8f0df57 100644 --- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 @@ -23,7 +23,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -87,47 +89,33 @@ 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 { - $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 + $body = @{ + 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 + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases" - Method = 'Post' - Body = $requestBody - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/releases" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create a release')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create a release')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 index 7e481e27c..1973bc9ab 100644 --- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 @@ -57,7 +57,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -101,41 +103,27 @@ 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 { - $requestBody = @{ - tag_name = $TagName - target_commitish = $TargetCommitish - previous_tag_name = $PreviousTagName - configuration_file_path = $ConfigurationFilePath - } - $requestBody | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + tag_name = $TagName + target_commitish = $TargetCommitish + previous_tag_name = $PreviousTagName + configuration_file_path = $ConfigurationFilePath + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - APIEndpoint = "/repos/$Owner/$Repo/releases/generate-notes" - Method = 'Post' - Body = $requestBody - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/releases/generate-notes" + Body = $body + } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create release notes')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create release notes')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 index 9bb21bb3c..7dd3cf7a8 100644 --- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 @@ -18,7 +18,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -43,33 +45,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 index 996e45a62..b9735c024 100644 --- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 @@ -19,7 +19,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -85,46 +87,32 @@ 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 { - $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 + $body = @{ + tag_name = $TagName + target_commitish = $TargetCommitish + name = $Name + body = $Body + discussion_category_name = $DiscussionCategoryName + make_latest = $MakeLatest + draft = $Draft + prerelease = $Prerelease + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'Patch' - Body = $requestBody - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repo]", 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repo]", 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 index e269e7075..764a28309 100644 --- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 @@ -20,6 +20,8 @@ param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -53,40 +55,26 @@ 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 = @{ - key_prefix = $KeyPrefix - url_template = $UrlTemplate - is_alphanumeric = $IsAlphanumeric - } + $body = @{ + key_prefix = $KeyPrefix + url_template = $UrlTemplate + is_alphanumeric = $IsAlphanumeric + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks" - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/autolinks" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repo]", 'Create')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repo]", 'Create')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 index c1428e3fb..f27d58389 100644 --- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 @@ -21,6 +21,8 @@ param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -29,9 +31,8 @@ # The unique identifier of the autolink. [Parameter(Mandatory)] - [Alias('autolink_id')] - [Alias('ID')] - [int] $AutolinkId, + [Alias('autolink_id', 'AutolinkID')] + [int] $ID, # 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. @@ -44,34 +45,20 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" - Method = 'Delete' - Body = $body - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo/autolinks/$ID" + Body = $body + Context = $Context + } - 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 [$ID] for repository [$Owner/$Repo]", 'Delete')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 index 8cdeee215..492bd3d9e 100644 --- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 +++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 @@ -21,8 +21,9 @@ [OutputType([pscustomobject])] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -40,31 +41,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/properties/values" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/properties/values" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index 9d92caa3b..15117d382 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -20,8 +20,9 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 index f1fead763..6ea2be0f2 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 @@ -20,8 +20,9 @@ [Alias('Disable-GitHubRepositorySecurityFixes')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 index 2b2e31010..dfef9074e 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -20,8 +20,9 @@ [Alias('Disable-GitHubRepositoryVulnerabilityAlerts')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index 16c7779ed..0092db3b3 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -20,8 +20,9 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" - Method = 'Put' - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 index a732a8b67..661521923 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 @@ -20,8 +20,9 @@ [Alias('Enable-GitHubRepositorySecurityFixes')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'Put' - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 index 15446f077..c0b45bca9 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -21,8 +21,9 @@ [Alias('Enable-GitHubRepositoryVulnerabilityAlerts')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -40,33 +41,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" - Method = 'Put' - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index 1758993bf..6abd62d77 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -51,8 +51,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -112,44 +113,30 @@ Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + } - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + process { + $body = @{ + direction = $Direction + per_page = $PerPage + before = $Before + after = $After + ref = $Ref + actor = $Actor + time_period = $TimePeriod + activity_type = $ActivityType } - Write-Debug "Owner: [$Owner]" + $body | Remove-HashtableEntry -NullOrEmptyValues - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/activity" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 index 64d80dd27..d2bec4685 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 @@ -21,8 +21,9 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -45,37 +46,23 @@ 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 = @{ - ref = $Ref - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + ref = $Ref + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 index cb0b79d77..b39b3505c 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 @@ -22,8 +22,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -50,38 +51,24 @@ 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 = @{ - anon = $Anon - per_page = $PerPage - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + anon = $Anon + per_page = $PerPage + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/contributors" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/contributors" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 index d657fdde4..c0a9245fd 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 @@ -17,8 +17,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -46,38 +47,24 @@ 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 = @{ - sort = $Sort - per_page = $PerPage - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + sort = $Sort + per_page = $PerPage + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/forks" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/forks" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 index 8e6a63bd8..ff1a868d3 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 @@ -19,8 +19,9 @@ [Alias('Get-GitHubRepositoryLanguages')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -38,31 +39,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/languages" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/languages" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 index a5243c14b..9643ef79e 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 @@ -21,8 +21,9 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -40,31 +41,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 index 034a8fbc8..750be8223 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 @@ -18,8 +18,9 @@ [Alias('Get-GitHubRepositoryTags')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -42,36 +43,22 @@ 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/tags" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 index b25a70850..2d78f86d1 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 @@ -26,8 +26,9 @@ [Alias('Get-GitHubRepositoryTeams')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -50,36 +51,22 @@ Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + } - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + process { + $body = @{ + per_page = $PerPage } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/teams" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 index e7cd218e9..04b11e8d8 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 @@ -14,8 +14,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -38,36 +39,22 @@ 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/topics" - Method = 'Get' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/topics" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.names - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.names } } diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 index 2b17af78e..1842f5474 100644 --- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 @@ -22,8 +22,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -56,39 +57,25 @@ 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 = @{ - new_owner = $NewOwner - new_name = $NewName - team_ids = $TeamIds - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $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 - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/transfer" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 index d4dddd7eb..b97a29cbc 100644 --- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 @@ -17,13 +17,12 @@ .NOTES [Delete a repository](https://docs.github.com/rest/repos/repos#delete-a-repository) #> - #TODO: Set high impact - [CmdletBinding(SupportsShouldProcess)] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] - [Alias('login')] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -41,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 index e775fda0f..3c00c68bf 100644 --- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 @@ -17,8 +17,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -41,38 +42,24 @@ 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 = @{ - names = $Names | ForEach-Object { $_.ToLower() } - } + $body = @{ + names = $Names | ForEach-Object { $_.ToLower() } + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/topics" - Method = 'Put' - Body = $body - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repo/topics" + Body = $body + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 index 77c6b8f59..b9e422d6e 100644 --- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 +++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 @@ -43,8 +43,9 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -73,38 +74,24 @@ 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 = @{ - event_type = $EventType - client_payload = $ClientPayload - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + event_type = $EventType + client_payload = $ClientPayload + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/dispatches" - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/dispatches" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 index c1b7dff33..75af6b8e4 100644 --- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 @@ -22,8 +22,9 @@ [Alias('Test-GitHubRepositoryVulnerabilityAlerts')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -41,34 +42,16 @@ 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 { $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" + Context = $Context } - try { - (Invoke-GitHubAPI @inputObject).StatusCode -eq 204 - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 index 68e37615d..705c6a7a4 100644 --- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 @@ -26,8 +26,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -182,70 +183,56 @@ 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 = @{ - 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 - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $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 + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo" - Method = 'Patch' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/repos/$Owner/$Repo" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repo]", 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repo]", 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 index 5ecc552ae..62948a67d 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 @@ -20,8 +20,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -43,31 +44,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 index 7d2d5088c..3fd845043 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 @@ -28,8 +28,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -73,41 +74,27 @@ Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + } - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + process { + $body = @{ + ref = $Ref + time_period = $TimePeriod + actor_name = $ActorName + rule_suite_result = $RuleSuiteResult + per_page = $PerPage } - Write-Debug "Owner: [$Owner]" + $body | Remove-HashtableEntry -NullOrEmptyValues - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 index 51a332af0..2eeea7a92 100644 --- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 @@ -20,8 +20,9 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -39,31 +40,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags/protection" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/tags/protection" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 index e11860a33..c6e25ed27 100644 --- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 @@ -19,8 +19,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -42,38 +43,24 @@ 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 = @{ - pattern = $Pattern - } + $body = @{ + pattern = $Pattern + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags/protection" - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/tags/protection" + Body = $body + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 index fe1283962..34ba7c109 100644 --- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 @@ -19,8 +19,9 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -42,33 +43,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1 index 3fce6a57e..74a9d2297 100644 --- a/src/functions/public/Teams/New-GitHubTeam.ps1 +++ b/src/functions/public/Teams/New-GitHubTeam.ps1 @@ -36,8 +36,7 @@ # The organization name. The name is not case sensitive. # If not provided, the organization from the context is used. - [Parameter()] - [Alias('Org')] + [Parameter(Mandatory)] [string] $Organization, # The description of the team. @@ -91,61 +90,52 @@ $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" - if (-not $Visible -and $ParentTeamID -gt 0) { throw 'A nested team cannot be secret (invisible).' } } process { - try { - $body = @{ - name = $Name - description = $Description - maintainers = $Maintainers - repo_names = $RepoNames - privacy = $Visible ? 'closed' : 'secret' - notification_setting = $Notifications ? 'notifications_enabled' : 'notifications_disabled' - permission = $Permission - parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + name = $Name + description = $Description + maintainers = $Maintainers + repo_names = $RepoNames + privacy = $Visible ? 'closed' : 'secret' + notification_setting = $Notifications ? 'notifications_enabled' : 'notifications_disabled' + 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 - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Organization/teams" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("'$Name' in '$Organization'", 'Create team')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - $team = $_.Response - [GitHubTeam]( - @{ - Name = $team.name - Slug = $team.slug - NodeID = $team.node_id - CombinedSlug = $Organization + '/' + $team.slug - DatabaseId = $team.id - Description = $team.description - Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false - Visible = $team.privacy -eq 'closed' ? $true : $false - ParentTeam = $team.parent.slug - Organization = $team.organization.login - ChildTeams = @() - CreatedAt = $team.created_at - UpdatedAt = $team.updated_at - } - ) - } + if ($PSCmdlet.ShouldProcess("'$Name' in '$Organization'", 'Create team')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + $team = $_.Response + [GitHubTeam]( + @{ + Name = $team.name + Slug = $team.slug + NodeID = $team.node_id + CombinedSlug = $Organization + '/' + $team.slug + DatabaseId = $team.id + Description = $team.description + Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false + Visible = $team.privacy -eq 'closed' ? $true : $false + ParentTeam = $team.parent.slug + Organization = $team.organization.login + ChildTeams = @() + CreatedAt = $team.created_at + UpdatedAt = $team.updated_at + } + ) } - } catch { - throw $_ } } diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1 index 066df8804..71889c919 100644 --- a/src/functions/public/Teams/Remove-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1 @@ -21,15 +21,15 @@ Mandatory, ValueFromPipelineByPropertyName )] - [Alias('team_slug')] - [string] $Slug, + [Alias('team_slug', 'Slug')] + [string] $Name, # The organization name. The name is not case sensitive. # If not provided, the organization from the context is used. [Parameter( + Mandatory, ValueFromPipelineByPropertyName )] - [Alias('Org')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. @@ -43,28 +43,19 @@ 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]" } process { - try { - $inputObject = @{ - Context = $Context - Method = 'Delete' - APIEndpoint = "/orgs/$Organization/teams/$Slug" - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/orgs/$Organization/teams/$Name" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$Organization/$Slug", '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 $_ } } diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1 index 21b6b4f2f..98ab729c3 100644 --- a/src/functions/public/Teams/Update-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Update-GitHubTeam.ps1 @@ -30,19 +30,18 @@ param( # The slug of the team name. [Parameter(Mandatory)] - [Alias('team_slug')] - [string] $Slug, + [Alias('team_slug', 'Slug')] + [string] $Name, # The organization name. The name is not case sensitive. # If you do not provide this parameter, the command will use the organization from the context. - [Parameter()] - [Alias('Org')] + [Parameter(Mandatory)] [string] $Organization, # The new team name. [Parameter()] [Alias()] - [string] $Name, + [string] $NewName, # The description of the team. [Parameter()] @@ -86,57 +85,48 @@ 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]" } process { - try { - $body = @{ - name = $Name - description = $Description - privacy = $PSBoundParameters.ContainsKey('Visible') ? ($Visible ? 'closed' : 'secret') : $null - notification_setting = $PSBoundParameters.ContainsKey('Notifications') ? + $body = @{ + name = $NewName + description = $Description + privacy = $PSBoundParameters.ContainsKey('Visible') ? ($Visible ? 'closed' : 'secret') : $null + notification_setting = $PSBoundParameters.ContainsKey('Notifications') ? ($Notifications ? 'notifications_enabled' : 'notifications_disabled') : $null - permission = $Permission - parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID - } - $body | Remove-HashtableEntry -NullOrEmptyValues + permission = $Permission + parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/teams/$Slug" - Method = 'Patch' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/orgs/$Organization/teams/$Name" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$Organization/$Slug", 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - $team = $_.Response - [GitHubTeam]( - @{ - Name = $team.name - Slug = $team.slug - NodeID = $team.node_id - CombinedSlug = $Organization + '/' + $team.slug - DatabaseId = $team.id - Description = $team.description - Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false - Visible = $team.privacy -eq 'closed' ? $true : $false - ParentTeam = $team.parent.slug - Organization = $team.organization.login - ChildTeams = @() - CreatedAt = $team.created_at - UpdatedAt = $team.updated_at - } - ) - } + if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + $team = $_.Response + [GitHubTeam]( + @{ + Name = $team.name + Slug = $team.slug + NodeID = $team.node_id + CombinedSlug = $Organization + '/' + $team.slug + DatabaseId = $team.id + Description = $team.description + Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false + Visible = $team.privacy -eq 'closed' ? $true : $false + ParentTeam = $team.parent.slug + Organization = $team.organization.login + ChildTeams = @() + CreatedAt = $team.created_at + UpdatedAt = $team.updated_at + } + ) } - } catch { - throw $_ } } diff --git a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 index d6676ba2f..7d4527afd 100644 --- a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 @@ -7,7 +7,7 @@ This endpoint is accessible with the `user` scope. .EXAMPLE - Add-GitHubUserEmail -Emails 'octocat@github.com','firstname.lastname@work.com' + Add-GitHubUserEmail -Email 'octocat@github.com','firstname.lastname@work.com' Adds the email addresses `octocat@github.com` and `firstname.lastname@work.com` to the authenticated user's account. @@ -26,7 +26,7 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [string[]] $Emails, + [string[]] $Email, # 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. @@ -42,23 +42,19 @@ } process { - try { - $body = @{ - emails = $Emails - } + $body = @{ + emails = $Email + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/emails' - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/emails' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 index 1f3e68a9d..2ace0b7de 100644 --- a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 @@ -24,7 +24,7 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [string[]] $Emails, + [string[]] $Email, # 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. @@ -40,25 +40,21 @@ } process { - try { - $body = @{ - emails = $Emails - } + $body = @{ + emails = $Email + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/emails' - Method = 'Delete' - Body = $body - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = '/user/emails' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Email addresses [$($Emails -join ', ')]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Email addresses [$($Email -join ', ')]", 'Delete')) { + $null = Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 index cbe16643e..947dbe9a2 100644 --- a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 +++ b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 @@ -46,25 +46,21 @@ } process { - try { - $body = @{ - visibility = $Visibility - } + $body = @{ + visibility = $Visibility + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/email/visibility' - Method = 'Patch' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = '/user/email/visibility' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Email visibility [$Visibility]", 'Set')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Email visibility [$Visibility]", 'Set')) { + $null = Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 index 0160b1e78..3f4c0a79a 100644 --- a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 @@ -42,19 +42,13 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/following/$Username" - Method = 'Put' - } - - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/user/following/$Username" + Context = $Context } + + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 index 472258b60..57512912d 100644 --- a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 @@ -40,20 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/following/$Username" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/following/$Username" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("User [$Username]", 'Unfollow')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("User [$Username]", 'Unfollow')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 index 71b755eed..8b8503b82 100644 --- a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 @@ -24,7 +24,7 @@ #> [OutputType([pscustomobject])] [CmdletBinding()] - param( + param ( # A descriptive name for the new key. [Parameter( Mandatory, @@ -55,24 +55,20 @@ } process { - try { - $body = @{ - name = $Name - armored_public_key = $ArmoredPublicKey - } + $body = @{ + name = $Name + armored_public_key = $ArmoredPublicKey + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/gpg_keys' - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/gpg_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 index e29c5475e..3398b9745 100644 --- a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 @@ -40,20 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/gpg_keys/$ID" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/gpg_keys/$ID" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 index 29368652f..a676dda90 100644 --- a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 @@ -49,24 +49,20 @@ } process { - try { - $body = @{ - title = $Title - key = $Key - } + $body = @{ + title = $Title + key = $Key + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/keys' - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 index 6238a86eb..535b76464 100644 --- a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 @@ -41,20 +41,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/keys/$ID" - Method = 'Delete' - } + $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 $_ + if ($PSCmdlet.ShouldProcess("Key with ID [$ID]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } 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 74ef4590e..ff451fadf 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 @@ -51,24 +51,20 @@ } process { - try { - $body = @{ - title = $Title - key = $Key - } + $body = @{ + title = $Title + key = $Key + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/ssh_signing_keys' - Method = 'Post' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/ssh_signing_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 61d001e20..dcda75f2e 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 @@ -42,20 +42,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/ssh_signing_keys/$ID" - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/ssh_signing_keys/$ID" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 index b7b3bdd97..c28aeb43f 100644 --- a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 @@ -21,8 +21,8 @@ param( # Full URLs for the social media profiles to add. [Parameter(Mandatory)] - [Alias('account_urls')] - [string[]] $AccountUrls, + [Alias('account_urls', 'social_accounts', 'AccountUrls')] + [string[]] $URL, # 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. @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - account_urls = $AccountUrls - } + $body = @{ + account_urls = $URL + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/social_accounts' - Body = $body - Method = 'Post' - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/social_accounts' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 index 7870f8a53..334537a91 100644 --- a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 @@ -22,8 +22,8 @@ param( # Full URLs for the social media profiles to add. [Parameter(Mandatory)] - [Alias('account_urls')] - [string[]] $AccountUrls, + [Alias('account_urls', 'social_accounts', 'AccountUrls')] + [string[]] $URL, # 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. @@ -39,25 +39,19 @@ } process { - try { - $body = @{ - account_urls = $AccountUrls - } + $body = @{ + account_urls = $URL + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/social_accounts' - Body = $body - Method = 'Delete' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = '/user/social_accounts' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Social accounts [$($AccountUrls -join ', ')]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("Social accounts [$($URL -join ', ')]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Update-GitHubUser.ps1 b/src/functions/public/Users/Update-GitHubUser.ps1 index f1d5cf800..da8e4afa1 100644 --- a/src/functions/public/Users/Update-GitHubUser.ps1 +++ b/src/functions/public/Users/Update-GitHubUser.ps1 @@ -75,33 +75,29 @@ } process { - try { - $body = @{ - name = $Name - email = $Email - blog = $Blog - twitter_username = $TwitterUsername - company = $Company - location = $Location - hireable = $Hireable - bio = $Bio - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + name = $Name + email = $Email + blog = $Blog + twitter_username = $TwitterUsername + company = $Company + location = $Location + hireable = $Hireable + bio = $Bio + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = '/user' - Method = 'Patch' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = '/user' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('authenticated user', 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess('authenticated user', 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } From 1b2652ea652e16da5dc204ab0bbd4b55e1549aca Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 01:11:24 +0100 Subject: [PATCH 38/71] [Refactor]: Rename `$Repo` parameter to `$Repository` for consistency across multiple functions --- src/classes/public/Context/GitHubContext.ps1 | 2 +- .../Actions/Get-GitHubWorkflowRunByRepo.ps1 | 10 +- .../Get-GitHubWorkflowRunByWorkflow.ps1 | 8 +- .../Auth/Context/Set-GitHubContext.ps1 | 10 +- .../License/Get-GitHubRepositoryLicense.ps1 | 10 +- .../Assets/Get-GitHubReleaseAssetByID.ps1 | 6 +- .../Get-GitHubReleaseAssetByReleaseID.ps1 | 15 +- .../Releases/Get-GitHubReleaseAll.ps1 | 6 +- .../Releases/Get-GitHubReleaseByID.ps1 | 6 +- .../Releases/Get-GitHubReleaseByTagName.ps1 | 6 +- .../Releases/Get-GitHubReleaseLatest.ps1 | 6 +- .../Get-GitHubRepositoryAutolinkById.ps1 | 6 +- .../Get-GitHubRepositoryAutolinkList.ps1 | 6 +- .../Fork/New-GitHubRepositoryAsFork.ps1 | 6 +- .../Get-GitHubRepositoryByName.ps1 | 6 +- .../private/Teams/Get-GitHubRepoTeam.ps1 | 4 +- .../Workflow Run/Get-GitHubWorkflowRun.ps1 | 12 +- .../Workflow Run/Remove-GitHubWorkflowRun.ps1 | 4 +- .../Restart-GitHubWorkflowRun.ps1 | 4 +- .../Workflow Run/Stop-GitHubWorkflowRun.ps1 | 4 +- .../Actions/Workflow/Get-GitHubWorkflow.ps1 | 4 +- .../Actions/Workflow/Start-GitHubWorkflow.ps1 | 2 +- .../public/Auth/Connect-GitHubAccount.ps1 | 8 +- .../public/Branches/Get-GitHubRepoBranch.ps1 | 12 +- .../public/License/Get-GitHubLicense.ps1 | 35 ++-- .../public/Markdown/Get-GitHubMarkdown.ps1 | 4 +- .../Assets/Add-GitHubReleaseAsset.ps1 | 6 +- .../Assets/Get-GitHubReleaseAsset.ps1 | 34 ++-- .../Assets/Remove-GitHubReleaseAsset.ps1 | 10 +- .../Assets/Set-GitHubReleaseAsset.ps1 | 8 +- .../Releases/Releases/Get-GitHubRelease.ps1 | 34 ++-- .../Releases/Releases/New-GitHubRelease.ps1 | 10 +- .../Releases/New-GitHubReleaseNote.ps1 | 8 +- .../Releases/Remove-GitHubRelease.ps1 | 10 +- .../Releases/Releases/Set-GitHubRelease.ps1 | 10 +- .../Get-GitHubRepositoryAutolink.ps1 | 34 ++-- .../New-GitHubRepositoryAutolink.ps1 | 8 +- .../Remove-GitHubRepositoryAutolink.ps1 | 8 +- .../Get-GitHubRepositoryCustomProperty.ps1 | 8 +- ...epositoryPrivateVulnerabilityReporting.ps1 | 10 +- .../Disable-GitHubRepositorySecurityFix.ps1 | 10 +- ...ble-GitHubRepositoryVulnerabilityAlert.ps1 | 10 +- ...epositoryPrivateVulnerabilityReporting.ps1 | 10 +- .../Enable-GitHubRepositorySecurityFix.ps1 | 10 +- ...ble-GitHubRepositoryVulnerabilityAlert.ps1 | 10 +- .../Repositories/Get-GitHubRepository.ps1 | 158 ++++++++---------- .../Get-GitHubRepositoryActivity.ps1 | 22 +-- .../Get-GitHubRepositoryCodeownersError.ps1 | 8 +- .../Get-GitHubRepositoryContributor.ps1 | 8 +- .../Repositories/Get-GitHubRepositoryFork.ps1 | 8 +- .../Get-GitHubRepositoryLanguage.ps1 | 8 +- .../Get-GitHubRepositorySecurityFix.ps1 | 8 +- .../Repositories/Get-GitHubRepositoryTag.ps1 | 8 +- .../Repositories/Get-GitHubRepositoryTeam.ps1 | 8 +- .../Get-GitHubRepositoryTopic.ps1 | 6 +- .../Repositories/Move-GitHubRepository.ps1 | 8 +- .../Repositories/Remove-GitHubRepository.ps1 | 8 +- .../Set-GitHubRepositoryTopic.ps1 | 10 +- .../Start-GitHubRepositoryEvent.ps1 | 6 +- ...est-GitHubRepositoryVulnerabilityAlert.ps1 | 8 +- .../Repositories/Update-GitHubRepository.ps1 | 10 +- .../Get-GitHubRepositoryRuleSuite.ps1 | 60 +++---- .../Get-GitHubRepositoryRuleSuiteById.ps1 | 11 +- .../Get-GitHubRepositoryRuleSuiteList.ps1 | 6 +- .../Get-GitHubRepositoryTagProtection.ps1 | 8 +- .../New-GitHubRepositoryTagProtection.ps1 | 10 +- .../Remove-GitHubRepositoryTagProtection.ps1 | 10 +- 67 files changed, 384 insertions(+), 463 deletions(-) diff --git a/src/classes/public/Context/GitHubContext.ps1 b/src/classes/public/Context/GitHubContext.ps1 index 8d54ac1b9..ff2a4133b 100644 --- a/src/classes/public/Context/GitHubContext.ps1 +++ b/src/classes/public/Context/GitHubContext.ps1 @@ -54,7 +54,7 @@ [string] $Owner # The default value for the Repo parameter. - [string] $Repo + [string] $Repository # The default value for the HTTP protocol version. [string] $HttpVersion diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 index 01f8419e4..5d3d2f0ed 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 @@ -12,19 +12,19 @@ `created`, `event`, `head_sha`, `status`. .EXAMPLE - Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repo 'repo' + Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repository 'repo' Lists all workflow runs for a repository. .EXAMPLE - Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repo 'repo' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success' + Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repository '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')] + [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'Event', Justification = 'A parameter that is used in the api call.')] @@ -35,7 +35,7 @@ # The name of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # Returns someone's workflow runs. Use the login for the user who created the push associated with the check suite or workflow run. [Parameter()] @@ -108,7 +108,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/actions/runs" + APIEndpoint = "/repos/$Owner/$Repository/actions/runs" Body = $body Context = $Context } diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 index e1771340c..27ff075cb 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 @@ -13,12 +13,12 @@ `created`, `event`, `head_sha`, `status`. .EXAMPLE - Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repo 'Hello-World' -ID '42' + Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repository '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' + Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repository '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`. @@ -37,7 +37,7 @@ # The name of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The ID of the workflow. You can also pass the workflow filename as a string. [Parameter(Mandatory)] @@ -115,7 +115,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/runs" + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/runs" Body = $body Context = $Context } diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index 1266214ff..2f9bcea3f 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -17,7 +17,7 @@ function Set-GitHubContext { AuthType = 'PAT' Enterprise = 'msx' Owner = 'octocat' - Repo = 'Hello-World' + Repository = 'Hello-World' } Set-GitHubContext -Context $context @@ -92,11 +92,11 @@ function Set-GitHubContext { $enterprise = $gitHubEvent.enterprise.slug $organization = $gitHubEvent.organization.login $owner = $gitHubEvent.repository.owner.login - $repo = $gitHubEvent.repository.name + $Repository = $gitHubEvent.repository.name $gh_sender = $gitHubEvent.sender.login # sender is an automatic variable in Powershell Write-Debug "Enterprise: $enterprise" Write-Debug "Organization: $organization" - Write-Debug "Repository: $repo" + Write-Debug "Repository: $Repository" Write-Debug "Repository Owner: $owner" Write-Debug "Repository Owner Type: $installationType" Write-Debug "Sender: $gh_sender" @@ -106,8 +106,8 @@ function Set-GitHubContext { if ([string]::IsNullOrEmpty($contextObj['Owner'])) { $contextObj['Owner'] = [string]$owner } - if ([string]::IsNullOrEmpty($contextObj['Repo'])) { - $contextObj['Repo'] = [string]$repo + if ([string]::IsNullOrEmpty($contextObj['Repository'])) { + $contextObj['Repository'] = [string]$Repository } if ([string]::IsNullOrEmpty($contextObj['InstallationType'])) { $contextObj['InstallationType'] = [string]$installationType diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index ecbb18e07..1d7a4512d 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -10,7 +10,7 @@ [custom media types](https://docs.github.com/rest/overview/media-types) for retrieving the raw license content or rendered license HTML. .EXAMPLE - Get-GitHubRepositoryLicense -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryLicense -Owner 'octocat' -Repository 'Hello-World' Get the license for the Hello-World repository from the octocat account. @@ -21,12 +21,12 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The type of data to return. Can be either 'raw' or 'html'. [Parameter()] @@ -53,7 +53,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/license" + APIEndpoint = "/repos/$Owner/$Repository/license" ContentType = $contentType Context = $Context } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index 6ba7f3761..ba44d8793 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -10,7 +10,7 @@ possible. API clients should handle both a `200` or `302` response. .EXAMPLE - Get-GitHubReleaseAssetByID -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseAssetByID -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release asset with the ID '1234567' for the repository 'octocat/hello-world'. @@ -26,7 +26,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the asset. [Parameter(Mandatory)] @@ -48,7 +48,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" Context = $Context } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 1eb39a5e1..c31fd7efa 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -7,7 +7,7 @@ List release assets .EXAMPLE - Get-GitHubReleaseAssetByReleaseID -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseAssetByReleaseID -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release assets for the release with the ID '1234567' for the repository 'octocat/hello-world'. @@ -23,7 +23,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the release. [Parameter( @@ -48,15 +48,6 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { @@ -66,7 +57,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets" + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID/assets" Body = $body Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index b1b658f8e..c13b6de84 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -9,7 +9,7 @@ Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. .EXAMPLE - Get-GitHubReleaseAll -Owner 'octocat' -Repo 'hello-world' + Get-GitHubReleaseAll -Owner 'octocat' -Repository 'hello-world' Gets all the releases for the repository 'hello-world' owned by 'octocat'. @@ -25,7 +25,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The number of results per page (max 100). [Parameter(ParameterSetName = 'AllUsers')] @@ -51,7 +51,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases" + APIEndpoint = "/repos/$Owner/$Repository/releases" Body = $body Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 5d35a3d69..153908c37 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -8,7 +8,7 @@ This key is a [hypermedia resource](https://docs.github.com/rest/overview/resources-in-the-rest-api#hypermedia). .EXAMPLE - Get-GitHubReleaseById -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseById -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release with the ID '1234567' for the repository 'hello-world' owned by 'octocat'. @@ -24,7 +24,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the release. [Parameter(Mandatory)] @@ -46,7 +46,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index 9165b2cc0..87cf0c065 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -7,7 +7,7 @@ Get a published release with the specified tag. .EXAMPLE - Get-GitHubReleaseByTagName -Owner 'octocat' -Repo 'hello-world' -Tag 'v1.0.0' + Get-GitHubReleaseByTagName -Owner 'octocat' -Repository 'hello-world' -Tag 'v1.0.0' Gets the release with the tag 'v1.0.0' for the repository 'hello-world' owned by 'octocat'. @@ -23,7 +23,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The name of the tag to get a release from. [Parameter(Mandatory)] @@ -45,7 +45,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag" + APIEndpoint = "/repos/$Owner/$Repository/releases/tags/$Tag" Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index c452767aa..2634dd5cd 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -9,7 +9,7 @@ The `created_at` attribute is the date of the commit used for the release, and not the date when the release was drafted or published. .EXAMPLE - Get-GitHubReleaseLatest -Owner 'octocat' -Repo 'hello-world' + Get-GitHubReleaseLatest -Owner 'octocat' -Repository 'hello-world' Gets the latest releases for the repository 'hello-world' owned by 'octocat'. @@ -25,7 +25,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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. @@ -42,7 +42,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/latest" + APIEndpoint = "/repos/$Owner/$Repository/releases/latest" Context = $Context } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index 55e607925..e66b81216 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -9,7 +9,7 @@ Information about autolinks are only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryAutolinkById -Owner 'octocat' -Repo 'Hello-World' -ID 1 + Get-GitHubRepositoryAutolinkById -Owner 'octocat' -Repository 'Hello-World' -ID 1 Gets the autolink with the ID 1 for the repository 'Hello-World' owned by 'octocat'. @@ -26,7 +26,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the autolink. [Parameter(Mandatory)] @@ -49,7 +49,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" + APIEndpoint = "/repos/$Owner/$Repository/autolinks/$AutolinkId" Context = $Context } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index 95638fab0..4bca16a8c 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -9,7 +9,7 @@ Information about autolinks are only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryAutolinkList -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryAutolinkList -Owner 'octocat' -Repository 'Hello-World' Gets all autolinks for the repository 'Hello-World' owned by 'octocat'. @@ -25,7 +25,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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. @@ -42,7 +42,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/autolinks" + APIEndpoint = "/repos/$Owner/$Repository/autolinks" Context = $Context } diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index aeeaf0026..4ba5974b0 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -46,7 +46,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The organization or person who will own the new repository. # To create a new repository in an organization, the authenticated user must be a member of the specified organization. @@ -83,12 +83,12 @@ $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/forks" + APIEndpoint = "/repos/$Owner/$Repository/forks" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) { + if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repository]", 'Create')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index 98645f6e0..22aec464c 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -11,7 +11,7 @@ For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." .EXAMPLE - Get-GitHubRepositoryByName -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryByName -Owner 'octocat' -Repository 'Hello-World' Gets the repository 'Hello-World' for the organization 'octocat'. @@ -28,7 +28,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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. @@ -45,7 +45,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo" + APIEndpoint = "/repos/$Owner/$Repository" Context = $Context } diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index 407b6e657..600ebd71f 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -9,7 +9,7 @@ [string] $Owner, [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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. @@ -26,7 +26,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/teams" + APIEndpoint = "/repos/$Owner/$Repository/teams" Context = $Context } diff --git a/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 index 61dfe752f..55b252dce 100644 --- a/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 @@ -12,22 +12,22 @@ `event`, `head_sha`, `status`. .EXAMPLE - Get-GitHubWorkflowRun -Owner 'owner' -Repo 'repo' + Get-GitHubWorkflowRun -Owner 'owner' -Repository 'repo' Lists all workflow runs for a repository. .EXAMPLE - Get-GitHubWorkflowRun -Owner 'owner' -Repo 'repo' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success' + Get-GitHubWorkflowRun -Owner 'owner' -Repository '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' + Get-GitHubWorkflowRun -Owner 'octocat' -Repository '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' + Get-GitHubWorkflowRun -Owner 'octocat' -Repository '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`. @@ -132,7 +132,7 @@ process { $params = @{ Owner = $Owner - Repo = $Repo + Repository = $Repository Actor = $Actor Branch = $Branch Event = $Event @@ -151,7 +151,7 @@ } 'ByName' { - $params['ID'] = (Get-GitHubWorkflow -Owner $Owner -Repo $Repository -Name $Name).id + $params['ID'] = (Get-GitHubWorkflow -Owner $Owner -Repository $Repository -Name $Name).id Get-GitHubWorkflowRunByWorkflow @params } diff --git a/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 index 59b262daa..74bf22dbb 100644 --- a/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 @@ -9,7 +9,7 @@ this endpoint. .EXAMPLE - Remove-GitHubWorkflowRun -Owner 'octocat' -Repo 'Hello-World' -ID 123456789 + Remove-GitHubWorkflowRun -Owner 'octocat' -Repository 'Hello-World' -ID 123456789 Deletes the workflow run with the ID 123456789 from the 'Hello-World' repository owned by 'octocat' @@ -62,7 +62,7 @@ Context = $Context } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Delete workflow run')) { + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Delete workflow run')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 index e8bad08dd..887a45891 100644 --- a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 @@ -7,7 +7,7 @@ Re-runs your workflow run using its `run_id`. You can also specify a branch or tag name to re-run a workflow run from a branch .EXAMPLE - Start-GitHubWorkflowReRun -Owner 'octocat' -Repo 'Hello-World' -ID 123456789 + Start-GitHubWorkflowReRun -Owner 'octocat' -Repository 'Hello-World' -ID 123456789 .NOTES [Re-run a workflow](https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-workflow) @@ -58,7 +58,7 @@ Context = $Context } - if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Re-run')) { + if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repository]", 'Re-run')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 index b3db67aef..454affeba 100644 --- a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 @@ -7,7 +7,7 @@ Cancels a workflow run using its `run_id`. You can use this endpoint to cancel a workflow run that is in progress or waiting .EXAMPLE - Stop-GitHubWorkflowRun -Owner 'octocat' -Repo 'Hello-World' -ID 123456789 + Stop-GitHubWorkflowRun -Owner 'octocat' -Repository 'Hello-World' -ID 123456789 Cancels the workflow run with the ID 123456789 from the 'Hello-World' repository owned by 'octocat' @@ -58,7 +58,7 @@ Context = $Context } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Cancel/Stop workflow run')) { + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Cancel/Stop workflow run')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 index 21e4d4efb..883933483 100644 --- a/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 @@ -9,12 +9,12 @@ GitHub Apps must have the actions:read permission to use this endpoint. .EXAMPLE - Get-GitHubWorkflow -Owner 'octocat' -Repo 'hello-world' + Get-GitHubWorkflow -Owner 'octocat' -Repository 'hello-world' Gets all workflows in the 'octocat/hello-world' repository. .EXAMPLE - Get-GitHubWorkflow -Owner 'octocat' -Repo 'hello-world' -Name 'hello-world.yml' + Get-GitHubWorkflow -Owner 'octocat' -Repository 'hello-world' -Name 'hello-world.yml' Gets the 'hello-world.yml' workflow in the 'octocat/hello-world' repository. diff --git a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 index dc469d41f..81f1dce53 100644 --- a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 @@ -80,7 +80,7 @@ Context = $Context } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo/$ID", 'Start workflow')) { + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Start workflow')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index 88ec28889..99ce6bd02 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -110,13 +110,11 @@ # Set the default owner to use in commands. [Parameter()] [Alias('Organization')] - [Alias('Org')] [string] $Owner, # Set the default repository to use in commands. [Parameter()] - [Alias('Repository')] - [string] $Repo, + [string] $Repository, # The host to connect to. Can use $env:GITHUB_SERVER_URL to set the host, as the protocol is removed automatically. # Example: github.com, github.enterprise.com, msx.ghe.com @@ -128,8 +126,6 @@ # Suppresses the output of the function. [Parameter()] [Alias('Quiet')] - [Alias('q')] - [Alias('s')] [switch] $Silent, # Make the connected context NOT the default context. @@ -185,7 +181,7 @@ AuthType = [string]$authType Enterprise = [string]$Enterprise Owner = [string]$Owner - Repo = [string]$Repo + Repository = [string]$Repository } Write-Verbose ($context | Format-Table | Out-String) diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 index 8ba269e11..512a00564 100644 --- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 +++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 @@ -7,7 +7,7 @@ Lists all branches from a repository .EXAMPLE - Get-GitHubRepoBranch -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepoBranch -Owner 'octocat' -Repository 'Hello-World' Gets all the branches from the 'Hello-World' repository owned by 'octocat' @@ -17,12 +17,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -40,7 +42,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/branches" + APIEndpoint = "/repos/$Owner/$Repository/branches" Context = $Context } diff --git a/src/functions/public/License/Get-GitHubLicense.ps1 b/src/functions/public/License/Get-GitHubLicense.ps1 index 8ec620b6a..ebcb95f1c 100644 --- a/src/functions/public/License/Get-GitHubLicense.ps1 +++ b/src/functions/public/License/Get-GitHubLicense.ps1 @@ -19,7 +19,7 @@ Get the mit license template .EXAMPLE - Get-GitHubLicense -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubLicense -Owner 'octocat' -Repository 'Hello-World' Get the license for the Hello-World repository from the octocat account. @@ -39,7 +39,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(ParameterSetName = 'Repository')] - [string] $Repo, + [string] $Repository, # The license keyword, license name, or license SPDX ID. For example, mit or mpl-2.0. [Parameter(ParameterSetName = 'Name')] @@ -56,32 +56,19 @@ 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 { - switch ($PSCmdlet.ParameterSetName) { - 'List' { - Get-GitHubLicenseList -Context $Context - } - 'Name' { - Get-GitHubLicenseByName -Name $Name -Context $Context - } - 'Repository' { - Get-GitHubRepositoryLicense -Owner $Owner -Repo $Repo -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + 'List' { + Get-GitHubLicenseList -Context $Context + } + 'Name' { + Get-GitHubLicenseByName -Name $Name -Context $Context + } + 'Repository' { + Get-GitHubRepositoryLicense -Owner $Owner -Repository $Repository -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index ab5cd81ff..89f949003 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -31,8 +31,8 @@ [ValidateSet('markdown', 'gfm')] [string] $Mode = 'markdown', - # 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. + # The repository context to use when creating references in `gfm` mode. For example, setting `context` to `octo-org/octo-Repository` will change the + # text `#42` into an HTML link to issue 42 in the `octo-org/octo-Repository` repository. [Parameter()] [string] $RepoContext, diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 index 0d8203d49..7e7a5efa1 100644 --- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 @@ -37,7 +37,7 @@ the old file before you can re-upload the new asset. .EXAMPLE - Add-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '7654321' -FilePath 'C:\Users\octocat\Downloads\hello-world.zip' + Add-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '7654321' -FilePath 'C:\Users\octocat\Downloads\hello-world.zip' Gets the release assets for the release with the ID '1234567' for the repository 'octocat/hello-world'. @@ -54,7 +54,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the release. [Parameter(Mandatory)] @@ -127,7 +127,7 @@ } } - $release = Get-GitHubRelease -Owner $Owner -Repo $Repo -ID $ID + $release = Get-GitHubRelease -Owner $Owner -Repository $Repository -ID $ID $uploadURI = $release.upload_url -replace '{\?name,label}', "?name=$($Name)&label=$($Label)" $inputObject = @{ diff --git a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 index 227f7da3d..627d64498 100644 --- a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 @@ -8,12 +8,12 @@ If a release ID is provided, all assets for the release are returned. .EXAMPLE - Get-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release asset with the ID '1234567' for the repository 'octocat/hello-world'. .EXAMPLE - Get-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ReleaseID '7654321' + Get-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ReleaseID '7654321' Gets the release assets for the release with the ID '7654321' for the repository 'octocat/hello-world'. @@ -23,12 +23,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the asset. [Parameter( @@ -57,28 +59,16 @@ 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 { - if ($ReleaseID) { - Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repo $Repo -ReleaseID $ReleaseID -Context $Context + switch ($PSCmdlet.ParameterSetName) { + 'ReleaseID' { + Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repository $Repository -ReleaseID $ReleaseID -Context $Context } - if ($ID) { - Get-GitHubReleaseAssetByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context + 'ID' { + Get-GitHubReleaseAssetByID -Owner $Owner -Repository $Repository -ID $ID -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 index 4816a18a0..295eab381 100644 --- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 @@ -7,7 +7,7 @@ Delete a release asset .EXAMPLE - Remove-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Remove-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Deletes the release asset with the ID '1234567' for the repository 'octocat/hello-world'. @@ -23,8 +23,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the asset. [Parameter(Mandatory)] @@ -47,11 +47,11 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" Context = $Context } - if ($PSCmdlet.ShouldProcess("Asset with ID [$ID] in [$Owner/$Repo]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Asset with ID [$ID] in [$Owner/$Repository]", 'Delete')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 index 44a452b34..7041a7721 100644 --- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 @@ -7,7 +7,7 @@ Users with push access to the repository can edit a release asset. .EXAMPLE - Set-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '1234567' -Name 'new_asset_name' -Label 'new_asset_label' + Set-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '1234567' -Name 'new_asset_name' -Label 'new_asset_label' Updates the release asset with the ID '1234567' for the repository 'octocat/hello-world' with the new name 'new_asset_name' and label 'new_asset_label'. @@ -25,7 +25,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter()] - [string] $Repo, + [string] $Repository, # The unique identifier of the asset. [Parameter(Mandatory)] @@ -68,12 +68,12 @@ $inputObject = @{ Method = 'Patch' - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repo]", 'Set')) { + if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repository]", 'Set')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 index 7b228b075..15d784595 100644 --- a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 @@ -9,22 +9,22 @@ Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' Gets the releases for the repository 'hello-world' owned by 'octocat'. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -Latest + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -Latest Gets the latest releases for the repository 'hello-world' owned by 'octocat'. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -Tag 'v1.0.0' + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -Tag 'v1.0.0' Gets the release with the tag 'v1.0.0' for the repository 'hello-world' owned by 'octocat'. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release with the ID '1234567' for the repository 'hello-world' owned by 'octocat'. @@ -36,12 +36,14 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'Latest', Justification = 'Required for parameter set')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter(ParameterSetName = 'All')] @@ -82,32 +84,22 @@ 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 { switch ($PSCmdlet.ParameterSetName) { 'All' { - Get-GitHubReleaseAll -Owner $Owner -Repo $Repo -PerPage $PerPage -Context $Context + Get-GitHubReleaseAll -Owner $Owner -Repository $Repository -PerPage $PerPage -Context $Context } 'Latest' { - Get-GitHubReleaseLatest -Owner $Owner -Repo $Repo -Context $Context + Get-GitHubReleaseLatest -Owner $Owner -Repository $Repository -Context $Context } 'Tag' { - Get-GitHubReleaseByTagName -Owner $Owner -Repo $Repo -Tag $Tag -Context $Context + Get-GitHubReleaseByTagName -Owner $Owner -Repository $Repository -Tag $Tag -Context $Context } 'ID' { - Get-GitHubReleaseByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context + Get-GitHubReleaseByID -Owner $Owner -Repository $Repository -ID $ID -Context $Context } } } catch { diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 index 1c8f0df57..ab2f2d755 100644 --- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 @@ -11,7 +11,7 @@ and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. .EXAMPLE - New-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -TagName 'v1.0.0' -TargetCommitish 'main' -Body 'Release notes' + New-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -TagName 'v1.0.0' -TargetCommitish 'main' -Body 'Release notes' Creates a release for the repository 'octocat/hello-world' with the tag 'v1.0.0' and the target commitish 'main'. @@ -29,8 +29,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the tag. [Parameter(Mandatory)] @@ -107,12 +107,12 @@ $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/releases" + APIEndpoint = "/repos/$Owner/$Repository/releases" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create a release')) { + if ($PSCmdlet.ShouldProcess("$Owner/$Repository", 'Create a release')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 index 1973bc9ab..7a0fa45f4 100644 --- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 @@ -63,8 +63,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The tag name for the release. This can be an existing tag or a new one. [Parameter(Mandatory)] @@ -116,11 +116,11 @@ $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/releases/generate-notes" + APIEndpoint = "/repos/$Owner/$Repository/releases/generate-notes" Body = $body } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create release notes')) { + if ($PSCmdlet.ShouldProcess("$Owner/$Repository", 'Create release notes')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 index 7dd3cf7a8..80542040e 100644 --- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 @@ -7,7 +7,7 @@ Users with push access to the repository can delete a release. .EXAMPLE - Remove-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Remove-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Deletes the release with the ID '1234567' for the repository 'octocat/hello-world'. @@ -24,8 +24,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the release. [Parameter( @@ -50,11 +50,11 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" Context = $Context } - if ($PSCmdlet.ShouldProcess("Release with ID [$ID] in [$Owner/$Repo]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Release with ID [$ID] in [$Owner/$Repository]", 'Delete')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 index b9735c024..5108990a5 100644 --- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 @@ -7,7 +7,7 @@ Users with push access to the repository can edit a release. .EXAMPLE - Set-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -ID '1234567' -Body 'Release notes' + Set-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -ID '1234567' -Body 'Release notes' Updates the release with the ID '1234567' for the repository 'octocat/hello-world' with the body 'Release notes'. @@ -25,8 +25,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the release. [Parameter(Mandatory)] @@ -104,12 +104,12 @@ $inputObject = @{ Method = 'Patch' - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repo]", 'Update')) { + if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repository]", 'Update')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 index 8f97fa861..b4c77ab70 100644 --- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 @@ -9,12 +9,12 @@ Information about autolinks are only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' Gets all autolinks for the repository 'Hello-World' owned by 'octocat'. .EXAMPLE - Get-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' -ID 1 + Get-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' -ID 1 Gets the autolink with the ID 1 for the repository 'Hello-World' owned by 'octocat'. @@ -22,25 +22,25 @@ [Get all autolinks of a repository](https://docs.github.com/rest/repos/autolinks#list-all-autolinks-of-a-repository) #> [Alias('Get-GitHubRepositoryAutolinks')] - [CmdletBinding(DefaultParameterSetName = 'Default')] + [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the autolink. [Parameter( Mandatory, ParameterSetName = 'ById' )] - [Alias('autolink_id')] - [Alias('ID')] - [int] $AutolinkId, + [Alias('autolink_id', 'AutolinkID')] + [int] $ID, # 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. @@ -53,26 +53,16 @@ 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 { switch ($PSCmdlet.ParameterSetName) { 'ById' { - Get-GitHubRepositoryAutolinkById -Owner $Owner -Repo $Repo -ID $AutolinkId -Context $Context + Get-GitHubRepositoryAutolinkById -Owner $Owner -Repository $Repository -ID $ID -Context $Context } default { - Get-GitHubRepositoryAutolinkList -Owner $Owner -Repo $Repo -Context $Context + Get-GitHubRepositoryAutolinkList -Owner $Owner -Repository $Repository -Context $Context } } } catch { diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 index 764a28309..daffe6beb 100644 --- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 @@ -7,7 +7,7 @@ Users with admin access to the repository can create an autolink. .EXAMPLE - New-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' -KeyPrefix 'GH-' -UrlTemplate 'https://www.example.com/issue/' + New-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' -KeyPrefix 'GH-' -UrlTemplate 'https://www.example.com/issue/' Creates an autolink for the repository 'Hello-World' owned by 'octocat' that links to when the prefix 'GH-' is found in an issue, pull request, or commit. @@ -26,7 +26,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit. [Parameter(Mandatory)] @@ -66,12 +66,12 @@ $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/autolinks" + APIEndpoint = "/repos/$Owner/$Repository/autolinks" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repo]", 'Create')) { + if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repository]", 'Create')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 index f27d58389..c662e7337 100644 --- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 @@ -9,7 +9,7 @@ Information about autolinks are only available to repository administrators. .EXAMPLE - Remove-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' -AutolinkId 1 + Remove-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' -AutolinkId 1 Deletes the autolink with ID 1 for the repository 'Hello-World' owned by 'octocat'. @@ -27,7 +27,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the autolink. [Parameter(Mandatory)] @@ -50,12 +50,12 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo/autolinks/$ID" + APIEndpoint = "/repos/$Owner/$Repository/autolinks/$ID" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Autolink with ID [$ID] for repository [$Owner/$Repo]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Autolink with ID [$ID] for repository [$Owner/$Repository]", 'Delete')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 index 492bd3d9e..2bad4715d 100644 --- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 +++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 @@ -8,7 +8,7 @@ Users with read access to the repository can use this endpoint. .EXAMPLE - Get-GitHubRepositoryCustomProperty -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRepositoryCustomProperty -Owner 'octocat' -Repository 'hello-world' Gets all custom property values that are set for the 'hello-world' repository. @@ -27,8 +27,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -46,7 +46,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/properties/values" + APIEndpoint = "/repos/$Owner/$Repository/properties/values" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index 15117d382..f92a7fafd 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -9,7 +9,7 @@ "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)". .EXAMPLE - Disable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repo 'GitHub' + Disable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repository 'GitHub' Disables private vulnerability reporting for the PSModule/GitHub repository. @@ -26,8 +26,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -45,11 +45,11 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" + APIEndpoint = "/repos/$Owner/$Repository/private-vulnerability-reporting" Context = $Context } - if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Disable')) { + if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repository]", 'Disable')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 index 6ea2be0f2..a3c0a256d 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 @@ -9,7 +9,7 @@ "[Configuring automated security fixes](https://docs.github.com/articles/configuring-automated-security-fixes)". .EXAMPLE - Disable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repo 'GitHub' + Disable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repository 'GitHub' Disables automated security fixes for the repository. @@ -26,8 +26,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -45,11 +45,11 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" + APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" Context = $Context } - if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Disable')) { + if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repository]", 'Disable')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 index dfef9074e..ba694aef5 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -9,7 +9,7 @@ "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". .EXAMPLE - Disable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repo 'hello-world' + Disable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repository 'hello-world' Disables vulnerability alerts for the 'octocat/hello-world' repository. @@ -26,8 +26,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -45,11 +45,11 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" + APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" Context = $Context } - if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Disable')) { + if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repository]", 'Disable')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index 0092db3b3..45ed9ac0a 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -9,7 +9,7 @@ "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)." .EXAMPLE - Enable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repo 'GitHub' + Enable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repository 'GitHub' Enables private vulnerability reporting for the PSModule/GitHub repository. @@ -26,8 +26,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -45,11 +45,11 @@ process { $inputObject = @{ Method = 'Put' - APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" + APIEndpoint = "/repos/$Owner/$Repository/private-vulnerability-reporting" Context = $Context } - if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Enable')) { + if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repository]", 'Enable')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 index 661521923..1617d42a4 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 @@ -9,7 +9,7 @@ "[Configuring automated security fixes](https://docs.github.com/articles/configuring-automated-security-fixes)". .EXAMPLE - Enable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repo 'GitHub' + Enable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repository 'GitHub' Enables automated security fixes for the repository. @@ -26,8 +26,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -45,11 +45,11 @@ process { $inputObject = @{ Method = 'Put' - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" + APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" Context = $Context } - if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Enable')) { + if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repository]", 'Enable')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 index c0b45bca9..c820d34e6 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -10,7 +10,7 @@ "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". .EXAMPLE - Enable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repo 'hello-world' + Enable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repository 'hello-world' Enables vulnerability alerts for the 'octocat/hello-world' repository. @@ -27,8 +27,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -46,11 +46,11 @@ process { $inputObject = @{ Method = 'Put' - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" + APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" Context = $Context } - if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Enable')) { + if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repository]", 'Enable')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 index 5fbd22311..487ffa468 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 @@ -37,7 +37,7 @@ filter Get-GitHubRepository { Gets the repositories with an ID equals and greater than 123456789. .EXAMPLE - Get-GitHubRepository -Owner 'github' -Repo 'octocat' + Get-GitHubRepository -Owner 'github' -Repository 'octocat' Gets the specified repository. @@ -89,7 +89,7 @@ filter Get-GitHubRepository { Mandatory, ParameterSetName = 'ByName' )] - [string] $Repo, + [string] $Repository, # The handle for the GitHub user account. [Parameter( @@ -166,100 +166,86 @@ filter Get-GitHubRepository { 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 { - $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 + $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 } - '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 + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubMyRepositories @params + } + 'MyRepos_Aff-Vis' { + $params = @{ + Context = $Context + Visibility = $Visibility + Affiliation = $Affiliation + Sort = $Sort + Direction = $Direction + PerPage = $PerPage + Since = $Since + Before = $Before } - 'ByName' { - $params = @{ - Context = $Context - Owner = $Owner - Repo = $Repo - } - $params | Remove-HashtableEntry -NullOrEmptyValues - Write-Verbose ($params | Format-List | Out-String) - Get-GitHubRepositoryByName @params + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubMyRepositories @params + } + 'ByName' { + $params = @{ + Context = $Context + Owner = $Owner + Repository = $Repository } - 'ListByID' { - $params = @{ - Context = $Context - Since = $SinceID - } - $params | Remove-HashtableEntry -NullOrEmptyValues - Write-Verbose ($params | Format-List | Out-String) - Get-GitHubRepositoryListByID @params + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubRepositoryByName @params + } + 'ListByID' { + $params = @{ + Context = $Context + Since = $SinceID } - '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 + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubRepositoryListByID @params + } + 'ListByOrg' { + $params = @{ + Context = $Context + Owner = $Owner + 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 + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubRepositoryListByOrg @params + } + '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 } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index 6abd62d77..7c7e346e0 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -11,25 +11,25 @@ see "[Viewing activity and data for your repository](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository)." .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Direction 'asc' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Direction 'asc' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -PerPage 100 + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -PerPage 100 .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Before '2021-01-01T00:00:00Z' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Before '2021-01-01T00:00:00Z' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -After '2021-01-01T00:00:00Z' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -After '2021-01-01T00:00:00Z' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Ref 'refs/heads/main' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Ref 'refs/heads/main' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Actor 'octocat' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Actor 'octocat' .EXAMPLE $params = @{ @@ -43,7 +43,7 @@ Gets the activity for the past 24 hours and selects the actor, activity type, ref, and timestamp. .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -ActivityType 'push','force_push' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -ActivityType 'push','force_push' .NOTES [List repository activities](https://docs.github.com/rest/repos/repos#list-repository-activities) @@ -57,8 +57,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The direction to sort the results by. [Parameter()] @@ -130,7 +130,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/activity" + APIEndpoint = "/repos/$Owner/$Repository/activity" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 index d2bec4685..14fd9511b 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 @@ -10,7 +10,7 @@ see "[About code owners](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)." .EXAMPLE - Get-GitHubRepositoryCodeownersError -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryCodeownersError -Owner 'PSModule' -Repository 'GitHub' Gets the CODEOWNERS errors for the repository. @@ -27,8 +27,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # A branch, tag or commit name used to determine which version of the CODEOWNERS file to use. # Default: the repository's default branch (e.g. main) @@ -56,7 +56,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors" + APIEndpoint = "/repos/$Owner/$Repository/codeowners/errors" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 index b39b3505c..47dbaae2a 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 @@ -12,7 +12,7 @@ in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information. .EXAMPLE - Get-GitHubRepositoryContributor -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryContributor -Owner 'PSModule' -Repository 'GitHub' Gets all contributors to the GitHub repository. @@ -28,8 +28,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # Wether to include anonymous contributors in results. [Parameter()] @@ -62,7 +62,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/contributors" + APIEndpoint = "/repos/$Owner/$Repository/contributors" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 index c0a9245fd..0335d6158 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 @@ -7,7 +7,7 @@ List forks of a named repository. .EXAMPLE - Get-GitHubRepositoryFork -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryFork -Owner 'octocat' -Repository 'Hello-World' List forks of the 'Hello-World' repository owned by 'octocat'. @@ -23,8 +23,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The direction to sort the results by. [Parameter()] @@ -58,7 +58,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/forks" + APIEndpoint = "/repos/$Owner/$Repository/forks" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 index ff1a868d3..715221bb3 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 @@ -8,7 +8,7 @@ bytes of code written in that language. .EXAMPLE - Get-GitHubRepositoryLanguage -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRepositoryLanguage -Owner 'octocat' -Repository 'hello-world' Gets the languages for the 'hello-world' repository owned by 'octocat'. @@ -25,8 +25,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -44,7 +44,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/languages" + APIEndpoint = "/repos/$Owner/$Repository/languages" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 index 9643ef79e..cf84e7180 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 @@ -9,7 +9,7 @@ "[Configuring automated security fixes](https://docs.github.com/articles/configuring-automated-security-fixes)". .EXAMPLE - Get-GitHubRepositorySecurityFix -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositorySecurityFix -Owner 'PSModule' -Repository 'GitHub' Gets the automated security fixes status for the GitHub repository. @@ -27,8 +27,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -46,7 +46,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" + APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 index 750be8223..1be5b3066 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 @@ -7,7 +7,7 @@ List repository tags .EXAMPLE - Get-GitHubRepositoryTag -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryTag -Owner 'PSModule' -Repository 'GitHub' Gets all tags of the GitHub repository. @@ -24,8 +24,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -52,7 +52,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/tags" + APIEndpoint = "/repos/$Owner/$Repository/tags" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 index 2d78f86d1..301e3c881 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 @@ -15,7 +15,7 @@ This endpoint is not compatible with fine-grained personal access tokens. .EXAMPLE - Get-GitHubRepositoryTeam -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryTeam -Owner 'PSModule' -Repository 'GitHub' Lists the teams that have access to the specified repository and that are also visible to the authenticated user. @@ -32,8 +32,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -60,7 +60,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/teams" + APIEndpoint = "/repos/$Owner/$Repository/teams" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 index 04b11e8d8..cd92be828 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 @@ -20,8 +20,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -48,7 +48,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/topics" + APIEndpoint = "/repos/$Owner/$Repository/topics" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 index 1842f5474..9a975465d 100644 --- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 @@ -12,7 +12,7 @@ a fine-grained personal access token cannot be used because they are only granted access to a single account. .EXAMPLE - Move-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' -NewOwner 'GitHub' -NewName 'PowerShell' + Move-GitHubRepository -Owner 'PSModule' -Repository 'GitHub' -NewOwner 'GitHub' -NewName 'PowerShell' Moves the GitHub repository to the PSModule organization and renames it to GitHub. @@ -28,8 +28,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The username or organization name the repository will be transferred to. [Parameter(Mandatory)] @@ -69,7 +69,7 @@ $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/transfer" + APIEndpoint = "/repos/$Owner/$Repository/transfer" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 index b97a29cbc..0f363939e 100644 --- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 @@ -10,7 +10,7 @@ repositories, you will get a `403 Forbidden` response. .EXAMPLE - Remove-GitHubRepository -Owner 'PSModule' -Repo 'Hello-World' + Remove-GitHubRepository -Owner 'PSModule' -Repository 'Hello-World' Deletes the repository `Hello-World` in the `PSModule` organization. @@ -27,7 +27,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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. @@ -45,11 +45,11 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo" + APIEndpoint = "/repos/$Owner/$Repository" Context = $Context } - if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repo]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repository]", 'Delete')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 index 3c00c68bf..ea243e9b6 100644 --- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 @@ -7,7 +7,7 @@ Replace all repository topics .EXAMPLE - Set-GitHubRepositoryTopic -Owner 'octocat' -Repo 'hello-world' -Names 'octocat', 'octo', 'octocat/hello-world' + Set-GitHubRepositoryTopic -Owner 'octocat' -Repository 'hello-world' -Names 'octocat', 'octo', 'octocat/hello-world' Replaces all topics for the repository 'octocat/hello-world' with the topics 'octocat', 'octo', 'octocat/hello-world'. @@ -23,8 +23,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -51,12 +51,12 @@ $inputObject = @{ Method = 'Put' - APIEndpoint = "/repos/$Owner/$Repo/topics" + APIEndpoint = "/repos/$Owner/$Repository/topics" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("topics for repo [$Owner/$Repo]", 'Set')) { + if ($PSCmdlet.ShouldProcess("topics for repo [$Owner/$Repository]", 'Set')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response.names } diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 index b9e422d6e..490d53d10 100644 --- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 +++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 @@ -49,8 +49,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # A custom webhook event name. Must be 100 characters or fewer. [Parameter(Mandatory)] @@ -85,7 +85,7 @@ $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/dispatches" + APIEndpoint = "/repos/$Owner/$Repository/dispatches" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 index 75af6b8e4..12f361893 100644 --- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 @@ -10,7 +10,7 @@ "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". .EXAMPLE - Test-GitHubRepositoryVulnerabilityAlert -Owner 'PSModule' -Repo 'GitHub' + Test-GitHubRepositoryVulnerabilityAlert -Owner 'PSModule' -Repository 'GitHub' Checks if vulnerability alerts are enabled for the PSModule/GitHub repository. @@ -28,8 +28,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -47,7 +47,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" + APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 index 705c6a7a4..4c708d204 100644 --- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 @@ -14,7 +14,7 @@ $params = @{ Owner = 'octocat' Repo = 'Hello-World' - name = 'Hello-World-Repo + name = 'Hello-World-Repository description = 'This is your first repository' homepage = 'https://github.com' } @@ -32,8 +32,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the repository. [Parameter()] @@ -224,12 +224,12 @@ $inputObject = @{ Method = 'Patch' - APIEndpoint = "/repos/$Owner/$Repo" + APIEndpoint = "/repos/$Owner/$Repository" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repo]", 'Update')) { + if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repository]", 'Update')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 index ec1dddde2..f9a14ed0e 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 @@ -22,7 +22,7 @@ Gets a list of rule suites for the main branch of the hello-world repository owned by octocat. .EXAMPLE - Get-GitHubRepositoryRuleSuite -Owner 'octocat' -Repo 'hello-world' -RuleSuiteId 123456789 + Get-GitHubRepositoryRuleSuite -Owner 'octocat' -Repository 'hello-world' -RuleSuiteId 123456789 Gets information about a suite of rule evaluations with ID 123456789 from within the octocat/hello-world repository. @@ -32,7 +32,7 @@ #> [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] - [CmdletBinding(DefaultParameterSetName = 'Default')] + [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. [Parameter()] @@ -40,8 +40,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the ref. Cannot contain wildcard characters. # When specified, only rule evaluations triggered for this ref will be returned. @@ -87,46 +87,32 @@ 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 { - $params = @{ - Context = $Context - Owner = $Owner - Repo = $Repo - } + $params = @{ + Context = $Context + Owner = $Owner + Repository = $Repository + } - switch ($PSCmdlet.ParameterSetName) { - 'Default' { - $params += @{ - Ref = $Ref - TimePeriod = $TimePeriod - ActorName = $ActorName - RuleSuiteResult = $RuleSuiteResult - PerPage = $PerPage - } - Get-GitHubRepositoryRuleSuiteList @params + switch ($PSCmdlet.ParameterSetName) { + 'ById' { + $params += @{ + RuleSuiteId = $RuleSuiteId } - 'ById' { - $params += @{ - RuleSuiteId = $RuleSuiteId - } - Get-GitHubRepositoryRuleSuiteById @params + Get-GitHubRepositoryRuleSuiteById @params + } + default { + $params += @{ + Ref = $Ref + TimePeriod = $TimePeriod + ActorName = $ActorName + RuleSuiteResult = $RuleSuiteResult + PerPage = $PerPage } + Get-GitHubRepositoryRuleSuiteList @params } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 index 62948a67d..d7233a5e9 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 @@ -8,7 +8,7 @@ For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)." .EXAMPLE - Get-GitHubRepositoryRuleSuiteById -Owner 'octocat' -Repo 'hello-world' -RuleSuiteId 123456789 + Get-GitHubRepositoryRuleSuiteById -Owner 'octocat' -Repository 'hello-world' -RuleSuiteId 123456789 Gets information about a suite of rule evaluations with ID 123456789 from within the octocat/hello-world repository. @@ -26,12 +26,13 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the rule suite result. To get this ID, you can use GET /repos/ { owner }/ { repo }/rulesets/rule-suites for repositories and GET /orgs/ { org }/rulesets/rule-suites for organizations. [Parameter(Mandatory)] - [int] $RuleSuiteId, + [Alias('RuleSuiteId')] + [int] $ID, # 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. @@ -49,7 +50,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId" + APIEndpoint = "/repos/$Owner/$Repository/rulesets/rule-suites/$ID" Context = $Context } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 index 3fd845043..15f040993 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 @@ -34,8 +34,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the ref. Cannot contain wildcard characters. # When specified, only rule evaluations triggered for this ref will be returned. @@ -88,7 +88,7 @@ $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites" + APIEndpoint = "/repos/$Owner/$Repository/rulesets/rule-suites" Body = $body Context = $Context } diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 index 2eeea7a92..50759e4a2 100644 --- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 @@ -9,7 +9,7 @@ This information is only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRepositoryTagProtection -Owner 'octocat' -Repository 'hello-world' Gets the tag protection states of the 'hello-world' repository. @@ -26,8 +26,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -45,7 +45,7 @@ process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/tags/protection" + APIEndpoint = "/repos/$Owner/$Repository/tags/protection" Context = $Context } diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 index c6e25ed27..41910a68c 100644 --- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 @@ -8,7 +8,7 @@ This endpoint is only available to repository administrators. .EXAMPLE - New-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -Pattern 'v1.*' + New-GitHubRepositoryTagProtection -Owner 'octocat' -Repository 'hello-world' -Pattern 'v1.*' Creates a tag protection state for the 'hello-world' repository with the pattern 'v1.*'. @@ -25,8 +25,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # An optional glob pattern to match against when enforcing tag protection. [Parameter(Mandatory)] @@ -52,12 +52,12 @@ $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/tags/protection" + APIEndpoint = "/repos/$Owner/$Repository/tags/protection" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("tag protection state on pattern [$Pattern] for repository [$Owner/$Repo]", 'Create')) { + if ($PSCmdlet.ShouldProcess("tag protection state on pattern [$Pattern] for repository [$Owner/$Repository]", 'Create')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 index 34ba7c109..952adfed1 100644 --- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 @@ -8,7 +8,7 @@ This endpoint is only available to repository administrators. .EXAMPLE - Remove-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -TagProtectionId 1 + Remove-GitHubRepositoryTagProtection -Owner 'octocat' -Repository 'hello-world' -TagProtectionId 1 Deletes the tag protection state with the ID 1 for the 'hello-world' repository. @@ -25,8 +25,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the tag protection. [Parameter(Mandatory)] @@ -48,11 +48,11 @@ process { $inputObject = @{ Method = 'Delete' - APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId" + APIEndpoint = "/repos/$Owner/$Repository/tags/protection/$TagProtectionId" Context = $Context } - if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repo]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repository]", 'Delete')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } From e6d78f21255432e60470b9071989d2c666f88900 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 01:12:22 +0100 Subject: [PATCH 39/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Rename=20`$R?= =?UTF-8?q?epo`=20parameter=20to=20`$Repository`=20in=20test=20cases=20for?= =?UTF-8?q?=20consistency=20across=20multiple=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/GitHub.Tests.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 5ece25162..54f287d12 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -440,7 +440,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (USER_FG_PAT)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { @@ -462,7 +462,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets a specific repository (USER_FG_PAT)' { - { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubRepository -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets all repositories from a organization (USER_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw @@ -597,7 +597,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (ORG_FG_PAT)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { @@ -619,7 +619,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets a specific repository (ORG_FG_PAT)' { - { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubRepository -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets all repositories from a organization (ORG_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw @@ -777,7 +777,7 @@ Describe 'As a user - Classic PAT token (PAT)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (PAT)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { @@ -956,7 +956,7 @@ Describe 'As GitHub Actions (GHA)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (GHA)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { From fb3d97eddff59780487109ff8d275e9aabf4987d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 01:17:38 +0100 Subject: [PATCH 40/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20def?= =?UTF-8?q?ault=20parameter=20set=20name=20in=20CmdletBinding=20for=20cons?= =?UTF-8?q?istency=20across=20multiple=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/private/Teams/Get-GitHubRESTTeam.ps1 | 4 ++-- src/functions/private/Utilities/Hashtable/Join-Object.ps1 | 6 +++--- src/functions/public/Auth/Connect-GitHubApp.ps1 | 4 +--- src/functions/public/Auth/Context/Get-GitHubContext.ps1 | 4 ++-- .../public/Organization/Get-GitHubOrganization.ps1 | 3 --- src/functions/public/Teams/Get-GitHubTeam.ps1 | 4 ++-- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index 968aaeef7..e485799b5 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -23,7 +23,7 @@ [Get team by name](https://docs.github.com/en/rest/teams/teams#get-a-team-by-name) #> [OutputType([pscustomobject])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The organization name. The name is not case sensitive. # If not provided, the organization from the context is used. @@ -66,7 +66,7 @@ 'GetByName' { Get-GitHubRESTTeamByName @params -Name $Name } - '__AllParameterSets' { + default { Get-GitHubTeamListByOrg @params } } diff --git a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 index 3e90ae272..84921ab82 100644 --- a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 +++ b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 @@ -52,7 +52,7 @@ [OutputType([pscustomobject])] [OutputType(ParameterSetName = 'AsHashTable', [hashtable])] [Alias('Merge-Object')] - [CmdletBinding(DefaultParameterSetName = '__DefaultSet')] + [CmdletBinding()] param( # The main object to merge into. This object will be cloned, so the original object will not be modified. [Parameter( @@ -82,13 +82,13 @@ try { if ($Main -isnot [hashtable]) { - $Main = $Main | ConvertTo-HashTable + $Main = $Main | ConvertTo-Hashtable } $hashtable = $Main.clone() foreach ($Override in $Overrides) { if ($Override -isnot [hashtable]) { - $Override = $Override | ConvertTo-HashTable + $Override = $Override | ConvertTo-Hashtable } $Override.Keys | ForEach-Object { diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 0596085f1..242ecc6dc 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -38,7 +38,7 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'The tokens are recieved as clear text. Mitigating exposure by removing variables and performing garbage collection.')] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The user account to connect to. [Parameter(ParameterSetName = 'Filtered')] @@ -62,8 +62,6 @@ # Suppresses the output of the function. [Parameter()] [Alias('Quiet')] - [Alias('q')] - [Alias('s')] [switch] $Silent, # Set as the default context. diff --git a/src/functions/public/Auth/Context/Get-GitHubContext.ps1 b/src/functions/public/Auth/Context/Get-GitHubContext.ps1 index fb4615d1a..ea5817fbf 100644 --- a/src/functions/public/Auth/Context/Get-GitHubContext.ps1 +++ b/src/functions/public/Auth/Context/Get-GitHubContext.ps1 @@ -18,7 +18,7 @@ function Get-GitHubContext { Justification = 'Encapsulated in a function. Never leaves as a plain text.' )] [OutputType([GitHubContext])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The name of the context. [Parameter( @@ -54,7 +54,7 @@ function Get-GitHubContext { $ID = "$($script:GitHub.Config.ID)/*" Write-Verbose "Getting available contexts for [$ID]" } - '__AllParameterSets' { + default { Write-Verbose 'Getting default context.' $ID = "$($script:GitHub.Config.ID)/$($script:GitHub.Config.DefaultContext)" if ([string]::IsNullOrEmpty($ID)) { diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index 962f71944..2a7c20dfd 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -42,9 +42,6 @@ ParameterSetName = 'NamedOrg', ValueFromPipelineByPropertyName )] - [Alias('login')] - [Alias('org')] - [Alias('owner')] [string] $Organization, # The handle for the GitHub user account. diff --git a/src/functions/public/Teams/Get-GitHubTeam.ps1 b/src/functions/public/Teams/Get-GitHubTeam.ps1 index 54862c043..eaaec36b0 100644 --- a/src/functions/public/Teams/Get-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Get-GitHubTeam.ps1 @@ -19,7 +19,7 @@ Gets the team with the slug 'my-team-name' in the `github` organization. #> [OutputType([GitHubTeam])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The slug of the team name. [Parameter( @@ -63,7 +63,7 @@ 'BySlug' { Get-GitHubTeamBySlug @params -Slug $Slug } - '__AllParameterSets' { + default { Get-GitHubTeamListByOrg @params } } From 89c1a29a1244ce3979f13ef5421ce91dc1d96d67 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 01:18:15 +0100 Subject: [PATCH 41/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20'Sk?= =?UTF-8?q?ipTests'=20parameter=20from=20GitHub=20Actions=20workflow=20for?= =?UTF-8?q?=20improved=20clarity=20and=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Process-PSModule.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index bc8b830f0..5252ed337 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -36,5 +36,3 @@ jobs: TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} - with: - SkipTests: All From a823176fabb14bc7caeefd5a209fa8b6ed7a9077 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 01:29:45 +0100 Subject: [PATCH 42/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Add=20debug?= =?UTF-8?q?=20output=20for=20parameter=20set=20handling=20in=20Get-GitHubA?= =?UTF-8?q?ppWebhookDelivery=20function=20for=20improved=20traceability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 index 3d9cdfe39..01c078b6d 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 @@ -66,12 +66,15 @@ process { switch ($PSCmdlet.ParameterSetName) { 'ByID' { + Write-Debug "ByID: [$ID]" Get-GitHubAppWebhookDeliveryByID -ID $ID -Context $Context } 'Redelivery' { + Write-Debug "Redelivery: [$NeedingRedelivery]" Get-GitHubAppWebhookDeliveryToRedeliver -Context $Context -PerPage $PerPage -TimeSpan $TimeSpan } default { + Write-Debug 'ByList' Get-GitHubAppWebhookDeliveryByList -Context $Context -PerPage $PerPage } } From 49338066737e95e0d4c76748a9be6a7ea89dd95d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 01:29:53 +0100 Subject: [PATCH 43/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Remove=20unn?= =?UTF-8?q?ecessary=20comment=20from=20Update-GitHubUserAccessToken=20func?= =?UTF-8?q?tion=20for=20cleaner=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index 39259d154..a653ef76e 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } - -function Update-GitHubUserAccessToken { +function Update-GitHubUserAccessToken { <# .SYNOPSIS Updates the GitHub access token. From 33d75da455691a2a9f4241ee29332a51199664e4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 01:34:12 +0100 Subject: [PATCH 44/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20com?= =?UTF-8?q?ment=20formatting=20for=20clarity=20in=20Get-GitHubMarkdown=20f?= =?UTF-8?q?unction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Markdown/Get-GitHubMarkdown.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index 89f949003..5fbb8d5cd 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -31,8 +31,8 @@ [ValidateSet('markdown', 'gfm')] [string] $Mode = 'markdown', - # The repository context to use when creating references in `gfm` mode. For example, setting `context` to `octo-org/octo-Repository` will change the - # text `#42` into an HTML link to issue 42 in the `octo-org/octo-Repository` repository. + # The repository context to use when creating references in `gfm` mode. For example, setting `context` to `octo-org/octo-Repository` will + # change the text `#42` into an HTML link to issue 42 in the `octo-org/octo-Repository` repository. [Parameter()] [string] $RepoContext, From f7c7a4c5202d106b058e3e3f7906fb8d70185db0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 02:01:30 +0100 Subject: [PATCH 45/71] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Update=20gui?= =?UTF-8?q?deline=20headers=20to=20use=20proper=20PowerShell=20documentati?= =?UTF-8?q?on=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/Guidelines.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/Guidelines.md b/tools/Guidelines.md index 04c65cf3e..e7d7f42a8 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -19,25 +19,25 @@ Writing down guidelines so that it can be the basis for pester tests. ### Documentation -#### SYNOPSIS +#### .SYNOPSIS -#### DESCRIPTION +#### .DESCRIPTION -#### EXAMPLES +#### .EXAMPLES - PSModule framework removes the default fencing. So, we need to add the fencing back in the examples where we see fit. -#### PARAMETERS +#### .PARAMETERS - Parameter docs do not go in the comment block. They are in the `param` block above each parameter. Principle: Keep documentation close to the code it documents. -#### NOTES +#### .NOTES - Have a link to the documentation with the display name of the official documentation. This is so that when user search on the online function documentation they can search based on the official documentation. -#### LINK +#### .LINK - First link is to the function documentation that is generated for the PowerShell module. - Other links can be to the official documentation. From ad728629229c2dbf9bca4c38a1744d7ea5544f7a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 12:21:51 +0100 Subject: [PATCH 46/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enable=20Debug?= =?UTF-8?q?=20and=20Verbose=20output=20in=20Process-PSModule=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Process-PSModule.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index bc8b830f0..3d703e6a5 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -37,4 +37,5 @@ jobs: TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} with: - SkipTests: All + Debug: true + Verbose: true From 13547e0570ad95d25ca7fd14181fb0e66b6a373f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 12:33:21 +0100 Subject: [PATCH 47/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20unnece?= =?UTF-8?q?ssary=20comment=20from=20Update-GitHubUserAccessToken=20functio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index cea9919e6..0f7fcbd4c 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } - -function Update-GitHubUserAccessToken { +function Update-GitHubUserAccessToken { <# .SYNOPSIS Updates the GitHub access token. From 2b637862e480ffd01eeaec47ec1404ba03353f54 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 14:49:34 +0100 Subject: [PATCH 48/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Make=20`$Contex?= =?UTF-8?q?t`=20parameter=20optional=20and=20change=20its=20type=20to=20`o?= =?UTF-8?q?bject`=20in=20GitHub=20Apps=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubAuthenticatedApp.ps1 | 4 +-- ...bEnterpriseOrganizationAppInstallation.ps1 | 4 +-- .../Get-GitHubOrganizationAppInstallation.ps1 | 4 +-- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 4 +-- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 4 +-- .../Get-GitHubAppWebhookDeliveryByID.ps1 | 4 +-- .../Get-GitHubAppWebhookDeliveryByList.ps1 | 4 +-- ...et-GitHubAppWebhookDeliveryToRedeliver.ps1 | 4 +-- .../Gitignore/Get-GitHubGitignoreByName.ps1 | 26 ++++++++----------- 9 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index b15d1c52b..ad85c6b0b 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -25,8 +25,8 @@ param( # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index 7dc368cc2..8349ddfeb 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -40,8 +40,8 @@ # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index 77ba7691c..958a09cbd 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -33,8 +33,8 @@ # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 index 78ac805e7..7849873ba 100644 --- a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -38,8 +38,8 @@ # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index 574e29791..770d9d143 100644 --- a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -29,8 +29,8 @@ # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index 05b538251..c1625f6ae 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -28,8 +28,8 @@ # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 68fc7741f..81423d7fa 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -27,8 +27,8 @@ # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 index 3cffe1ff6..c6a69b1f9 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 @@ -25,8 +25,8 @@ # 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(Mandatory)] - [GitHubContext] $Context + [Parameter()] + [object] $Context ) begin { diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 index 3d168a329..1ce3f5f87 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 @@ -23,8 +23,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -34,19 +34,15 @@ } process { - 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 $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/gitignore/templates/$Name" + Accept = 'application/vnd.github.raw+json' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } From d1cc8f4f0839699fb9e59258f71014e4164fede5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 16:15:18 +0100 Subject: [PATCH 49/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Make=20`$Contex?= =?UTF-8?q?t`=20parameter=20mandatory=20in=20multiple=20functions=20and=20?= =?UTF-8?q?standardize=20REST=20API=20method=20usage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/Context/Assert-GitHubContext.ps1 | 13 ++- .../Auth/Context/Resolve-GitHubContext.ps1 | 52 ++++----- .../Auth/Context/Set-GitHubContext.ps1 | 4 +- .../DeviceFlow/Request-GitHubAccessToken.ps1 | 8 +- .../DeviceFlow/Request-GitHubDeviceCode.ps1 | 4 +- .../Test-GitHubAccessTokenRefreshRequired.ps1 | 4 +- .../Update-GitHubUserAccessToken.ps1 | 4 +- .../Gitignore/Get-GitHubGitignoreList.ps1 | 24 ++-- .../License/Get-GitHubLicenseByName.ps1 | 26 ++--- .../private/License/Get-GitHubLicenseList.ps1 | 24 ++-- .../License/Get-GitHubRepositoryLicense.ps1 | 48 +++----- .../Block-GitHubUserByOrganization.ps1 | 21 +--- .../Get-GitHubBlockedUserByOrganization.ps1 | 30 +++-- .../Test-GitHubBlockedUserByOrganization.ps1 | 18 +-- .../Unblock-GitHubUserByOrganization.ps1 | 17 +-- .../Get-GitHubAllOrganization.ps1 | 32 +++--- .../Organization/Get-GitHubMyOrganization.ps1 | 30 +++-- .../Get-GitHubOrganizationByName.ps1 | 22 ++-- .../Get-GitHubUserOrganization.ps1 | 30 +++-- .../Assets/Get-GitHubReleaseAssetByID.ps1 | 32 ++---- .../Get-GitHubReleaseAssetByReleaseID.ps1 | 39 +++---- .../Releases/Get-GitHubReleaseAll.ps1 | 39 +++---- .../Releases/Get-GitHubReleaseByID.ps1 | 31 ++--- .../Releases/Get-GitHubReleaseByTagName.ps1 | 31 ++--- .../Releases/Get-GitHubReleaseLatest.ps1 | 31 ++--- .../Get-GitHubRepositoryAutolinkById.ps1 | 35 ++---- src/functions/public/API/Invoke-GitHubAPI.ps1 | 5 +- tools/Guidelines.md | 106 ++++++++++++++++++ 28 files changed, 358 insertions(+), 402 deletions(-) create mode 100644 tools/Guidelines.md diff --git a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 index d54844545..bd1741389 100644 --- a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 @@ -1,4 +1,4 @@ -filter Assert-GitHubContext { +filter Assert-GitHubContext { <# .SYNOPSIS Check if the context meets the requirements for the command. @@ -8,7 +8,7 @@ If the context does not meet the requirements, an error is thrown. .EXAMPLE - Assert-GitHubContext -Context 'github.com/Octocat' -TokenType 'App' + Assert-GitHubContext -Context 'github.com/Octocat' -AuthType 'App' #> [OutputType([void])] [CmdletBinding()] @@ -23,6 +23,11 @@ # The required authtypes for the command. [Parameter(Mandatory)] [string[]] $AuthType + + # TODO: Implement permission check + # # The required permission for the command. + # [Parameter()] + # [string] $Permission ) begin { @@ -36,6 +41,10 @@ if ($Context.AuthType -notin $AuthType) { throw "The context '$($Context.Name)' does not match the required AuthTypes [$AuthType] for [$command]." } + # TODO: Implement permission check + # if ($Context.AuthType -in 'IAT' -and $Context.Permission -notin $Permission) { + # throw "The context '$($Context.Name)' does not match the required Permission [$Permission] for [$command]." + # } } end { diff --git a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 index 68b5659bd..60f1b3158 100644 --- a/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Resolve-GitHubContext.ps1 @@ -25,7 +25,10 @@ param( # The context to resolve into an object. Used to get the details for the API call. # Can be either a string or a GitHubContext object. - [Parameter(ValueFromPipeline)] + [Parameter( + Mandatory, + ValueFromPipeline + )] [object] $Context ) @@ -36,36 +39,33 @@ } process { - 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 ($Context -is [string]) { + $contextName = $Context + Write-Debug "Getting context: [$contextName]" + $Context = Get-GitHubContext -Context $contextName + } - # 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 $_ + if (-not $Context) { + throw "Please provide a valid context or log in using 'Connect-GitHub'." } + + # TODO: Implement App installation context resolution + # 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 } + # } + # } + # } + Write-Output $Context } end { Write-Debug "[$stackPath] - End" - Write-Output $Context } } diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index 5f3af22ad..2b65f3888 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } +#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } function Set-GitHubContext { <# @@ -82,7 +82,7 @@ function Set-GitHubContext { $app = Get-GitHubApp -AppSlug $contextObj['Username'] -Context $contextObj $contextObj['DisplayName'] = [string]$app.name } catch { - Write-Warning "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." + Write-Debug "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." } } if ($script:GitHub.EnvironmentType -eq 'GHA') { diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 index 5592d1e78..37022a64f 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 @@ -66,11 +66,15 @@ } } + $headers = @{ + 'Accept' = 'application/json' + } + $RESTParams = @{ + Method = 'Post' Uri = "https://$HostName/login/oauth/access_token" - Method = 'POST' + Headers = $headers Body = $body - Headers = @{ 'Accept' = 'application/json' } } try { diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 index 8a0b22662..2137e9d26 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 @@ -50,10 +50,10 @@ } $RESTParams = @{ + Method = 'Post' Uri = "https://$HostName/login/device/code" - Method = 'POST' - Body = $body Headers = $headers + Body = $body } try { diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 index 1d0774e8c..609dee52f 100644 --- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 @@ -1,4 +1,4 @@ -function Test-GitHubAccessTokenRefreshRequired { +function Test-GitHubAccessTokenRefreshRequired { <# .SYNOPSIS Test if the GitHub access token should be refreshed. @@ -16,7 +16,7 @@ param( # 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()] + [Parameter(Mandatory)] [object] $Context ) diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index 0f7fcbd4c..992976ebc 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -1,4 +1,4 @@ -function Update-GitHubUserAccessToken { +function Update-GitHubUserAccessToken { <# .SYNOPSIS Updates the GitHub access token. @@ -27,7 +27,7 @@ param( # 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()] + [Parameter(Mandatory)] [object] $Context, # Return the new access token. diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index 257bd7514..22bbba823 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubGitignoreList { +filter Get-GitHubGitignoreList { <# .SYNOPSIS Get all gitignore templates @@ -21,7 +21,7 @@ param( # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -32,18 +32,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/gitignore/templates' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/gitignore/templates' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index 4dc6b32f6..7455e5a69 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubLicenseByName { +filter Get-GitHubLicenseByName { <# .SYNOPSIS Get a license @@ -26,7 +26,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -37,19 +37,15 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/licenses/$Name" - Accept = 'application/vnd.github+json' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/licenses/$Name" + Accept = 'application/vnd.github+json' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index d741aaced..bef458d37 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubLicenseList { +filter Get-GitHubLicenseList { <# .SYNOPSIS Get all commonly used licenses @@ -22,7 +22,7 @@ param( # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -33,18 +33,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/licenses' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/licenses' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index 387cc991c..f120c60ac 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryLicense { +filter Get-GitHubRepositoryLicense { <# .SYNOPSIS Get the license for a repository @@ -21,11 +21,11 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] [string] $Repo, # The type of data to return. Can be either 'raw' or 'html'. @@ -35,7 +35,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -43,40 +43,26 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { $contentType = switch ($Type) { 'raw' { 'application/vnd.github.raw+json' } 'html' { 'application/vnd.github.html+json' } } - } - process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/license" - ContentType = $contentType - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/license" + ContentType = $contentType + Context = $Context + } - 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 $_ + 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 } } end { diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 52d47ce19..6cc150aff 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Block-GitHubUserByOrganization { +filter Block-GitHubUserByOrganization { <# .SYNOPSIS Block a user from an organization @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -52,23 +52,12 @@ process { $inputObject = @{ - Context = $Context + Method = 'Put' APIEndpoint = "/orgs/$Organization/blocks/$Username" - Method = 'PUT' + Context = $Context } - 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 $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index b76586c66..eb4aa38d0 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubBlockedUserByOrganization { +filter Get-GitHubBlockedUserByOrganization { <# .SYNOPSIS List users blocked by an organization @@ -31,7 +31,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -42,23 +42,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/blocks" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/blocks" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index cde0a4aa3..793804ede 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubBlockedUserByOrganization { +filter Test-GitHubBlockedUserByOrganization { <# .SYNOPSIS Check if a user is blocked by an organization @@ -39,7 +39,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -51,20 +51,12 @@ process { $inputObject = @{ - Context = $Context + Method = 'Get' APIEndpoint = "/orgs/$Organization/blocks/$Username" - Method = 'GET' + Context = $Context } - try { - (Invoke-GitHubAPI @inputObject).StatusCode -eq 204 - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index 712528a72..37cacea02 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Unblock-GitHubUserByOrganization { +filter Unblock-GitHubUserByOrganization { <# .SYNOPSIS Unblock a user from an organization @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -52,18 +52,11 @@ process { $inputObject = @{ - Context = $Context + Method = 'Delete' APIEndpoint = "/orgs/$Organization/blocks/$Username" - Method = 'DELETE' - } - - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - Write-Error $_.Exception.Response - throw $_ + Context = $Context } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index 3c42c016d..fc3494857 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubAllOrganization { +filter Get-GitHubAllOrganization { <# .SYNOPSIS List organizations @@ -33,7 +33,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -44,24 +44,20 @@ } process { - try { - $body = @{ - since = $Since - per_page = $PerPage - } + $body = @{ + since = $Since + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/organizations' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/organizations' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index 0640e4f70..9ff4fcef4 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubMyOrganization { +filter Get-GitHubMyOrganization { <# .SYNOPSIS List organizations for the authenticated user @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -43,23 +43,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/orgs' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/orgs' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index 07f0fc6c6..8532ba696 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubOrganizationByName { +filter Get-GitHubOrganizationByName { <# .SYNOPSIS Get an organization @@ -38,7 +38,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -49,18 +49,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index 0d56c7735..47a5dc85e 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserOrganization { +filter Get-GitHubUserOrganization { <# .SYNOPSIS List organizations for a user @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -45,23 +45,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/orgs" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/orgs" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index 94826c337..6cab42f09 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAssetByID { +filter Get-GitHubReleaseAssetByID { <# .SYNOPSIS Get a release asset @@ -35,7 +35,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -43,31 +43,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 751207633..27f0858ca 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAssetByReleaseID { +filter Get-GitHubReleaseAssetByReleaseID { <# .SYNOPSIS List release assets @@ -40,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -48,35 +48,22 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index b747c3577..e974d58f2 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAll { +filter Get-GitHubReleaseAll { <# .SYNOPSIS List releases @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -42,35 +42,22 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 05fe2ac60..4acdfef66 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseByID { +filter Get-GitHubReleaseByID { <# .SYNOPSIS Get a release @@ -33,7 +33,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -41,30 +41,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index 6f658e55c..944f744f1 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseByTagName { +filter Get-GitHubReleaseByTagName { <# .SYNOPSIS Get a release by tag name @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -40,30 +40,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index 537eb0833..a8aa34f47 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseLatest { +filter Get-GitHubReleaseLatest { <# .SYNOPSIS Get the latest release @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -37,30 +37,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/latest" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/releases/latest" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index 7c1c0149a..6498a8d03 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryAutolinkById { +filter Get-GitHubRepositoryAutolinkById { <# .SYNOPSIS Get an autolink reference of a repository @@ -31,12 +31,12 @@ # The unique identifier of the autolink. [Parameter(Mandatory)] [Alias('autolink_id')] - [Alias('ID')] - [int] $AutolinkId, + [Alias('AutolinkId')] + [int] $ID, # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -44,30 +44,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/autolinks/$ID" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index 570eb29dd..4f7e42990 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -28,7 +28,7 @@ filter Invoke-GitHubAPI { param( # The HTTP method to be used for the API request. It can be one of the following: GET, POST, PUT, DELETE, or PATCH. [Parameter()] - [Microsoft.PowerShell.Commands.WebRequestMethod] $Method = 'GET', + [Microsoft.PowerShell.Commands.WebRequestMethod] $Method = 'Get', # The base URI for the GitHub API. This is usually `https://api.github.com`, but can be adjusted if necessary. [Parameter( @@ -45,6 +45,7 @@ filter Invoke-GitHubAPI { # The body of the API request. This can be a hashtable or a string. If a hashtable is provided, it will be converted to JSON. [Parameter()] + [Alias('Query')] [Object] $Body, # The 'Accept' header for the API request. If not provided, the default will be used by GitHub's API. @@ -156,7 +157,7 @@ filter Invoke-GitHubAPI { if ($Body) { # Use body to create the query string for certain situations - if ($Method -eq 'GET') { + if ($Method -eq 'Get') { # If body conatins 'per_page' and its is null, set it to $context.PerPage if ($Body['per_page'] -eq 0) { Write-Debug "Setting per_page to the default value in context [$($Context.PerPage)]." diff --git a/tools/Guidelines.md b/tools/Guidelines.md new file mode 100644 index 000000000..e7d7f42a8 --- /dev/null +++ b/tools/Guidelines.md @@ -0,0 +1,106 @@ +# Guidelines + +Writing down guidelines so that it can be the basis for pester tests. + +## Functions + +- Group functions by the object type they are working with in a folder based on the name of the object, NOT based on the API. +- DefaultParameterSetName must never be declared unless its different the default parameter set. + +### Name + +- Verb-GitHubNoun - based on what object type they are working with. Let parameters dictate the scope of the function. + +#### Name - Public functions + +#### Name - Private functions + +- No aliases + +### Documentation + +#### .SYNOPSIS + +#### .DESCRIPTION + +#### .EXAMPLES + +- PSModule framework removes the default fencing. So, we need to add the fencing back in the examples where we see fit. + +#### .PARAMETERS + +- Parameter docs do not go in the comment block. They are in the `param` block above each parameter. + Principle: Keep documentation close to the code it documents. + +#### .NOTES + +- Have a link to the documentation with the display name of the official documentation. This is so that when user search on the online +function documentation they can search based on the official documentation. + +#### .LINK + +- First link is to the function documentation that is generated for the PowerShell module. +- Other links can be to the official documentation. + +### Parameters + +- Parameters use the PascalCase version of the parameter name in the official documentation. + +#### Parameters - public functions + +- `Context` parameter supports `string` and `GitHubContext`. -> This is why we have `Resolve-GitHubContext` in the public functions. +- Evaluation of default values for other scoping parameters happen in `process` block. +- `Owner` always have `User` and `Organization` as aliases +- `Repository` is always spelled out. +- `ID` when needed, should be the short form, but have the long form as an alias supporting both lower_snake_case and PascalCase. + +#### Parameters - private functions + +- No aliases +- `Context` parameter is `GitHubContext`. Calling function should have resolved the context to a `GitHubContext` object already. + +### Content + +- Use begin, process, end and optionally clean blocks. +- begin block is for parameter validation and setup. +- process block is for the main logic. This should also have a foreach loop for pipelining. +- All context defaults must be evaluated in the process block. +- One API call = one function +- API parameters are always splatted + - The name of the splat is `$inputObject` + - The order of the splat is: + - `Method` + - `APIEndpoint` + - `Body` + - `Context` +- API Body is always a hashtable + +- If function calls `Invoke-GitHubAPI`, `Invoke-RestMethod` or `Invoke-WebRequest` that requires a `Context` parameter: + - Function must also have `Assert-GitHubContext` in begin block. + - Add a comment below `Assert-GitHubContext` stating the permissions needed for the API call. + +### Content - Public + +- If Public function + - Resolve-GitHubContext + +- To select underlying private functions use parameter sets, in a swticth statement. + - Use the `default` block to cover the default parameter set `__AllParameterSets`. + +### Content - Private + +- Pipelining is not supported + +#### Parameters + + + + + + + +## Classes + +- One class pr type of resource +- Properties are PascalCased (as expected by PowerShell users) + From 89cd7834c9c7de83cb4ed64bff6419ba8fac5c7b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 16:22:41 +0100 Subject: [PATCH 50/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Make=20`$Contex?= =?UTF-8?q?t`=20parameter=20mandatory=20in=20multiple=20repository=20funct?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Update-GitHubUserAccessToken.ps1 | 2 +- .../Get-GitHubRepositoryAutolinkList.ps1 | 32 ++++-------- .../Fork/New-GitHubRepositoryAsFork.ps1 | 50 ++++++------------- .../Repositories/Get-GitHubMyRepositories.ps1 | 4 +- 4 files changed, 28 insertions(+), 60 deletions(-) diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index 992976ebc..c3cd9a12d 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -1,4 +1,4 @@ -function Update-GitHubUserAccessToken { +function Update-GitHubUserAccessToken { <# .SYNOPSIS Updates the GitHub access token. diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index 1f9bf863b..bb7e75a02 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryAutolinkList { +filter Get-GitHubRepositoryAutolinkList { <# .SYNOPSIS List all autolinks of a repository @@ -21,7 +21,6 @@ param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. @@ -30,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -38,30 +37,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/autolinks" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index 6137b628a..237e5c086 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -1,4 +1,4 @@ -filter New-GitHubRepositoryAsFork { +filter New-GitHubRepositoryAsFork { <# .SYNOPSIS Create a fork @@ -64,7 +64,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -72,44 +72,26 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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]" - - if ([string]::IsNullorEmpty($Name)) { - $Name = $Repo - } - Write-Debug "Name: [$Name]" } process { - try { - $body = @{ - organization = $Organization - name = $Name - default_branch_only = $DefaultBranchOnly - } + $body = @{ + organization = $Organization + name = $Name + default_branch_only = $DefaultBranchOnly + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/forks" - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repo/forks" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index 6cbf70952..ff4ed60d4 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubMyRepositories { +filter Get-GitHubMyRepositories { <# .SYNOPSIS List repositories for the authenticated user @@ -109,7 +109,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) From ef2fc8c7ad99d6caaa28e3a19de26d17b208d400 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 17:11:27 +0100 Subject: [PATCH 51/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Make=20`$Contex?= =?UTF-8?q?t`=20parameter=20mandatory=20in=20multiple=20user=20and=20team?= =?UTF-8?q?=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/Get-GitHubMyRepositories.ps1 | 58 +++++++------- .../Get-GitHubRepositoryByName.ps1 | 32 +++----- .../Get-GitHubRepositoryListByID.ps1 | 30 ++++---- .../Get-GitHubRepositoryListByOrg.ps1 | 44 +++++------ .../Get-GitHubRepositoryListByUser.ps1 | 47 +++++------- .../New-GitHubRepositoryFromTemplate.ps1 | 44 +++++------ .../Repositories/New-GitHubRepositoryOrg.ps1 | 76 +++++++++---------- .../Repositories/New-GitHubRepositoryUser.ps1 | 72 +++++++++--------- .../private/Teams/Get-GitHubRESTTeam.ps1 | 34 +++------ .../Teams/Get-GitHubRESTTeamByName.ps1 | 30 +++----- .../Teams/Get-GitHubRESTTeamListByOrg.ps1 | 30 +++----- .../private/Teams/Get-GitHubRepoTeam.ps1 | 36 +++------ .../private/Teams/Get-GitHubTeamBySlug.ps1 | 10 +-- .../private/Teams/Get-GitHubTeamListByOrg.ps1 | 12 +-- .../Users/Blocking/Block-GitHubUserByUser.ps1 | 21 ++--- .../Blocking/Get-GitHubBlockedUserByUser.ps1 | 34 ++++----- .../Blocking/Test-GitHubBlockedUserByUser.ps1 | 36 +++------ .../Blocking/Unblock-GitHubUserByUser.ps1 | 26 ++----- .../Users/Emails/Get-GitHubUserAllEmail.ps1 | 32 ++++---- .../Emails/Get-GitHubUserPublicEmail.ps1 | 30 ++++---- .../Get-GitHubUserFollowersOfUser.ps1 | 30 ++++---- .../Followers/Get-GitHubUserFollowingMe.ps1 | 34 ++++----- .../Followers/Get-GitHubUserFollowingUser.ps1 | 30 ++++---- .../Followers/Get-GitHubUserMyFollowers.ps1 | 39 +++++----- .../Followers/Test-GitHubUserFollowedByMe.ps1 | 20 ++--- .../Test-GitHubUserFollowedByUser.ps1 | 4 +- .../Utilities/Hashtable/Join-Object.ps1 | 13 ++-- tools/Guidelines.md | 8 -- 28 files changed, 358 insertions(+), 554 deletions(-) diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index ff4ed60d4..e2623b638 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -120,41 +120,37 @@ filter Get-GitHubMyRepositories { } process { - try { - $body = @{ - sort = $Sort - direction = $Direction - per_page = $PerPage - } - 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') + $body = @{ + sort = $Sort + direction = $Direction + per_page = $PerPage + } + 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') + } + Write-Debug "ParamSet: [$($PSCmdlet.ParameterSetName)]" + switch ($PSCmdlet.ParameterSetName) { + 'Aff-Vis' { + $body['affiliation'] = $Affiliation -join ',' + $body['visibility'] = $Visibility } - Write-Debug "ParamSet: [$($PSCmdlet.ParameterSetName)]" - switch ($PSCmdlet.ParameterSetName) { - 'Aff-Vis' { - $body['affiliation'] = $Affiliation -join ',' - $body['visibility'] = $Visibility - } - 'Type' { - $body['type'] = $Type - } + 'Type' { + $body['type'] = $Type } + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/repos' - Method = 'GET' - body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/repos' + body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index ade44e09f..db9a3ab3d 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryByName { +filter Get-GitHubRepositoryByName { <# .SYNOPSIS Get a repository @@ -32,7 +32,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -40,31 +40,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index 27d3e1942..1fbea0082 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryListByID { +filter Get-GitHubRepositoryListByID { <# .SYNOPSIS List public repositories @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -40,23 +40,19 @@ } process { - try { - $body = @{ - since = $Since - } + $body = @{ + since = $Since + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/repositories' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/repositories' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index 3f06ead09..e40db9b3a 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryListByOrg { +filter Get-GitHubRepositoryListByOrg { <# .SYNOPSIS List organization repositories @@ -58,7 +58,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -66,33 +66,25 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - Write-Debug "Owner: [$Owner]" } 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 $_ + $body = @{ + sort = $Sort + type = $Type + direction = $Direction + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Owner/repos" + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index 0eb7e421f..f6ac46d76 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryListByUser { +filter Get-GitHubRepositoryListByUser { <# .SYNOPSIS List repositories for a user @@ -60,7 +60,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -68,38 +68,25 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + } + + process { + $body = @{ + sort = $Sort + type = $Type + direction = $Direction + per_page = $PerPage } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/repos" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index e6ea2ff61..2182c21b6 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -1,4 +1,4 @@ -filter New-GitHubRepositoryFromTemplate { +filter New-GitHubRepositoryFromTemplate { <# .SYNOPSIS Create a repository using a template @@ -74,7 +74,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -82,36 +82,28 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - Write-Debug "Owner: [$Owner]" } process { - try { - $body = @{ - owner = $Owner - name = $Name - description = $Description - include_all_branches = $IncludeAllBranches - private = $Private - } + $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 - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$TemplateOwner/$TemplateRepo/generate" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 0ff2e5dd2..5082c3812 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } +#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } filter New-GitHubRepositoryOrg { <# @@ -183,7 +183,7 @@ filter New-GitHubRepositoryOrg { # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -217,52 +217,44 @@ filter New-GitHubRepositoryOrg { Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT $GitignoreTemplate = $PSBoundParameters['GitignoreTemplate'] $LicenseTemplate = $PSBoundParameters['LicenseTemplate'] - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - Write-Debug "Owner: [$Owner]" } process { - 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 = @{ + 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' + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Owner/repos" - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Owner/repos" + Body = $body + Context = $Context + } - 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 $_ } } diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index b953b4059..9e46edd1f 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } +#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } filter New-GitHubRepositoryUser { <# @@ -177,7 +177,7 @@ filter New-GitHubRepositoryUser { # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -214,45 +214,41 @@ filter New-GitHubRepositoryUser { } process { - 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 = @{ + 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' + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/repos' - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/repos' + Body = $body + Context = $Context + } - 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 $_ } } diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index 63bb92ab6..b3ea3dcb5 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubRESTTeam { +function Get-GitHubRESTTeam { <# .SYNOPSIS List teams from an org or get a team by name @@ -27,8 +27,7 @@ param( # The organization name. The name is not case sensitive. # If not provided, the organization from the context is used. - [Parameter()] - [Alias('Org')] + [Parameter(Mandatory)] [string] $Organization, # The slug of the team name. @@ -41,7 +40,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -49,29 +48,20 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" } process { - try { - $params = @{ - Organization = $Organization - Context = $Context + $params = @{ + Organization = $Organization + Context = $Context + } + switch ($PSCmdlet.ParameterSetName) { + 'GetByName' { + Get-GitHubRESTTeamByName @params -Name $Name } - switch ($PSCmdlet.ParameterSetName) { - 'GetByName' { - Get-GitHubRESTTeamByName @params -Name $Name - } - '__AllParameterSets' { - Get-GitHubTeamListByOrg @params - } + default { + Get-GitHubTeamListByOrg @params } - } catch { - throw $_ } } diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index 1291cf2b8..12035b15b 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubRESTTeamByName { +function Get-GitHubRESTTeamByName { <# .SYNOPSIS Get a team by name @@ -20,12 +20,11 @@ # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -33,26 +32,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/teams/$Name" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/teams/$Name" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index fdbeb69f3..0bd846db4 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubRESTTeamListByOrg { +function Get-GitHubRESTTeamListByOrg { <# .SYNOPSIS List teams @@ -17,12 +17,11 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -30,26 +29,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/teams" - Method = 'Get' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/teams" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index 7c4e327aa..a616d5c64 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -1,19 +1,19 @@ -filter Get-GitHubRepoTeam { +filter Get-GitHubRepoTeam { <# .NOTES [List repository teams](https://docs.github.com/rest/reference/repos#get-a-repository) #> [CmdletBinding()] param( - [Parameter()] + [Parameter(Mandatory)] [string] $Owner, - [Parameter()] + [Parameter(Mandatory)] [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()] + [Parameter(Mandatory)] [object] $Context ) @@ -21,31 +21,17 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/teams" - Method = 'Get' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repo/teams" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 index f545c93e0..c2ceaea44 100644 --- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeamBySlug { +function Get-GitHubTeamBySlug { <# .SYNOPSIS Get a team by name @@ -21,12 +21,11 @@ # The organization name. The name is not case sensitive. # If not provided, the owner from the context will be used. [Parameter()] - [Alias('Org')] [string] $Organization, # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -34,11 +33,6 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" } process { diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 index 407308d43..ac51a9466 100644 --- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeamListByOrg { +function Get-GitHubTeamListByOrg { <# .SYNOPSIS List teams @@ -17,13 +17,12 @@ param( # The organization name. The name is not case sensitive. # If you don't provide this parameter, the command will use the owner of the context. - [Parameter()] - [Alias('Org')] + [Parameter(Mandatory)] [string] $Organization, # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -31,11 +30,6 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" } process { diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index 9d76b002d..86f770813 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Block-GitHubUserByUser { +filter Block-GitHubUserByUser { <# .SYNOPSIS Block a user @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -41,23 +41,12 @@ process { $inputObject = @{ - Context = $Context + Method = 'Put' APIEndpoint = "/user/blocks/$Username" - Method = 'PUT' + Context = $Context } - 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 $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index 603a4374b..d9949ced7 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubBlockedUserByUser { +filter Get-GitHubBlockedUserByUser { <# .SYNOPSIS List users blocked by the authenticated user @@ -24,7 +24,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -35,23 +35,19 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/blocks' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index 1f2f547ef..70df6df0e 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubBlockedUserByUser { +filter Test-GitHubBlockedUserByUser { <# .SYNOPSIS Check if a user is blocked by the authenticated user @@ -36,7 +36,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -47,30 +47,18 @@ } process { - try { - $body = @{ - per_page = $PerPage - } - - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/blocks/$Username" - Method = 'GET' - Body = $body - } + $body = @{ + per_page = $PerPage + } - try { - (Invoke-GitHubAPI @inputObject).StatusCode -eq 204 - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/blocks/$Username" + Body = $body + Context = $Context } + + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index fa9810262..c2030759f 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Unblock-GitHubUserByUser { +filter Unblock-GitHubUserByUser { <# .SYNOPSIS Unblock a user @@ -29,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -40,23 +40,13 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/blocks/$Username" - Method = 'DELETE' - } - - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - Write-Error $_.Exception.Response - throw $_ - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/blocks/$Username" + Context = $Context } + + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index c6a236301..b3e313786 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserAllEmail { +filter Get-GitHubUserAllEmail { <# .SYNOPSIS List email addresses for the authenticated user @@ -26,7 +26,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -37,22 +37,18 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/emails' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index 8fe9f8791..745d0e8da 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserPublicEmail { +filter Get-GitHubUserPublicEmail { <# .SYNOPSIS List public email addresses for the authenticated user @@ -28,7 +28,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -39,23 +39,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/public_emails' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/public_emails' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index a12689b74..2be3f433b 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserFollowersOfUser { +filter Get-GitHubUserFollowersOfUser { <# .SYNOPSIS List followers of a user @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -45,23 +45,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/followers" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/followers" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index 9f6ea98d8..8e3d6d047 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserFollowingMe { +filter Get-GitHubUserFollowingMe { <# .SYNOPSIS List the people the authenticated user follows @@ -25,7 +25,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -36,23 +36,19 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/following' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index 22a002103..3801b5dd5 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserFollowingUser { +filter Get-GitHubUserFollowingUser { <# .SYNOPSIS List the people a user follows @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -45,23 +45,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/following" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/following" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index 0cdcded2a..21b5f7548 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserMyFollowers { +filter Get-GitHubUserMyFollowers { <# .SYNOPSIS List followers of the authenticated user @@ -16,7 +16,10 @@ #> [OutputType([pscustomobject])] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'Private function, not exposed to user.')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSUseSingularNouns', '', + Justification = 'Private function, not exposed to user.' + )] [CmdletBinding()] param( # The number of results per page (max 100). @@ -26,7 +29,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -37,23 +40,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } - - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/followers' - Method = 'GET' - Body = $body - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/followers' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index c9c0c26f2..fe34676dd 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubUserFollowedByMe { +filter Test-GitHubUserFollowedByMe { <# .SYNOPSIS Check if a person is followed by the authenticated user @@ -24,11 +24,12 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # 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()] + [Parameter(Mandatory)] [object] $Context ) @@ -40,21 +41,12 @@ process { $inputObject = @{ - Context = $Context + Method = 'Get' APIEndpoint = "/user/following/$Username" - Method = 'GET' + Context = $Context } - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index 42ef3a84b..317ca6cbd 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubUserFollowedByUser { +filter Test-GitHubUserFollowedByUser { <# .SYNOPSIS Check if a user follows another user @@ -34,7 +34,7 @@ # 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()] + [Parameter(Mandatory)] [object] $Context ) diff --git a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 index 3e90ae272..275d12647 100644 --- a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 +++ b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 @@ -1,4 +1,4 @@ -filter Join-Object { +filter Join-Object { <# .SYNOPSIS Merges two or more objects into a single object @@ -52,7 +52,7 @@ [OutputType([pscustomobject])] [OutputType(ParameterSetName = 'AsHashTable', [hashtable])] [Alias('Merge-Object')] - [CmdletBinding(DefaultParameterSetName = '__DefaultSet')] + [CmdletBinding()] param( # The main object to merge into. This object will be cloned, so the original object will not be modified. [Parameter( @@ -66,10 +66,7 @@ [object[]] $Overrides, # Return the result as a hashtable instead of a pscustomobject - [Parameter( - Mandatory, - ParameterSetName = 'AsHashTable' - )] + [Parameter()] [switch] $AsHashtable ) @@ -82,13 +79,13 @@ try { if ($Main -isnot [hashtable]) { - $Main = $Main | ConvertTo-HashTable + $Main = $Main | ConvertTo-Hashtable } $hashtable = $Main.clone() foreach ($Override in $Overrides) { if ($Override -isnot [hashtable]) { - $Override = $Override | ConvertTo-HashTable + $Override = $Override | ConvertTo-Hashtable } $Override.Keys | ForEach-Object { diff --git a/tools/Guidelines.md b/tools/Guidelines.md index e7d7f42a8..1fe2e5e46 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -91,14 +91,6 @@ function documentation they can search based on the official documentation. - Pipelining is not supported -#### Parameters - - - - - - - ## Classes - One class pr type of resource From 2114b9d403d787dda0a22dfa4e113a5085434238 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 19:39:15 +0100 Subject: [PATCH 52/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20`$Cont?= =?UTF-8?q?ext`=20parameter=20type=20to=20`GitHubContext`=20and=20make=20i?= =?UTF-8?q?t=20mandatory=20in=20multiple=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Actions/Get-GitHubWorkflowRunByRepo.ps1 | 66 +++----- .../Get-GitHubWorkflowRunByWorkflow.ps1 | 66 +++----- .../Actions/Import-GitHubEventData.ps1 | 74 ++++---- .../Actions/Import-GitHubRunnerData.ps1 | 26 ++- .../Apps/GitHub Apps/Get-GitHubAppByName.ps1 | 5 +- ...tHubAppInstallationForAuthenticatedApp.ps1 | 5 +- .../Get-GitHubAuthenticatedApp.ps1 | 5 +- ...bEnterpriseOrganizationAppInstallation.ps1 | 5 +- .../Get-GitHubOrganizationAppInstallation.ps1 | 5 +- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 5 +- ...tall-GitHubAppOnEnterpriseOrganization.ps1 | 5 +- .../Get-GitHubAppWebhookDeliveryByID.ps1 | 5 +- .../Get-GitHubAppWebhookDeliveryByList.ps1 | 5 +- ...et-GitHubAppWebhookDeliveryToRedeliver.ps1 | 5 +- .../Auth/Context/Assert-GitHubContext.ps1 | 2 +- .../Auth/Context/Set-GitHubContext.ps1 | 20 +-- .../Test-GitHubAccessTokenRefreshRequired.ps1 | 4 +- .../Update-GitHubUserAccessToken.ps1 | 2 +- .../Gitignore/Get-GitHubGitignoreList.ps1 | 4 +- .../License/Get-GitHubLicenseByName.ps1 | 4 +- .../private/License/Get-GitHubLicenseList.ps1 | 4 +- .../License/Get-GitHubRepositoryLicense.ps1 | 10 +- .../Block-GitHubUserByOrganization.ps1 | 4 +- .../Get-GitHubBlockedUserByOrganization.ps1 | 4 +- .../Test-GitHubBlockedUserByOrganization.ps1 | 4 +- .../Unblock-GitHubUserByOrganization.ps1 | 4 +- .../Get-GitHubAllOrganization.ps1 | 4 +- .../Organization/Get-GitHubMyOrganization.ps1 | 4 +- .../Get-GitHubOrganizationByName.ps1 | 4 +- .../Get-GitHubUserOrganization.ps1 | 4 +- .../Assets/Get-GitHubReleaseAssetByID.ps1 | 10 +- .../Get-GitHubReleaseAssetByReleaseID.ps1 | 10 +- .../Releases/Get-GitHubReleaseAll.ps1 | 10 +- .../Releases/Get-GitHubReleaseByID.ps1 | 10 +- .../Releases/Get-GitHubReleaseByTagName.ps1 | 10 +- .../Releases/Get-GitHubReleaseLatest.ps1 | 10 +- .../Get-GitHubRepositoryAutolinkById.ps1 | 10 +- .../Get-GitHubRepositoryAutolinkList.ps1 | 10 +- .../Fork/New-GitHubRepositoryAsFork.ps1 | 10 +- .../Repositories/Get-GitHubMyRepositories.ps1 | 4 +- .../Get-GitHubRepositoryByName.ps1 | 10 +- .../Get-GitHubRepositoryListByID.ps1 | 4 +- .../Get-GitHubRepositoryListByOrg.ps1 | 4 +- .../Get-GitHubRepositoryListByUser.ps1 | 4 +- .../New-GitHubRepositoryFromTemplate.ps1 | 4 +- .../Repositories/New-GitHubRepositoryOrg.ps1 | 4 +- .../Repositories/New-GitHubRepositoryUser.ps1 | 4 +- .../private/Teams/Get-GitHubRESTTeam.ps1 | 4 +- .../Teams/Get-GitHubRESTTeamByName.ps1 | 4 +- .../Teams/Get-GitHubRESTTeamListByOrg.ps1 | 4 +- .../private/Teams/Get-GitHubRepoTeam.ps1 | 8 +- .../private/Teams/Get-GitHubTeamBySlug.ps1 | 4 +- .../private/Teams/Get-GitHubTeamListByOrg.ps1 | 4 +- .../Users/Blocking/Block-GitHubUserByUser.ps1 | 4 +- .../Blocking/Get-GitHubBlockedUserByUser.ps1 | 4 +- .../Blocking/Test-GitHubBlockedUserByUser.ps1 | 4 +- .../Blocking/Unblock-GitHubUserByUser.ps1 | 4 +- .../Users/Emails/Get-GitHubUserAllEmail.ps1 | 4 +- .../Emails/Get-GitHubUserPublicEmail.ps1 | 4 +- .../Get-GitHubUserFollowersOfUser.ps1 | 4 +- .../Followers/Get-GitHubUserFollowingMe.ps1 | 4 +- .../Followers/Get-GitHubUserFollowingUser.ps1 | 4 +- .../Followers/Get-GitHubUserMyFollowers.ps1 | 4 +- .../Followers/Test-GitHubUserFollowedByMe.ps1 | 4 +- .../Test-GitHubUserFollowedByUser.ps1 | 19 +-- .../GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 | 31 ++-- .../Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 | 30 ++-- .../GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 | 24 ++- .../private/Users/Get-GitHubAllUser.ps1 | 32 ++-- .../private/Users/Get-GitHubMyUser.ps1 | 24 ++- .../private/Users/Get-GitHubUserByName.ps1 | 22 +-- .../private/Users/Get-GitHubUserCard.ps1 | 32 ++-- .../Users/Keys/Get-GitHubUserKeyForUser.ps1 | 31 ++-- .../Users/Keys/Get-GitHubUserMyKey.ps1 | 30 ++-- .../Users/Keys/Get-GitHubUserMyKeyById.ps1 | 24 ++- .../Get-GitHubUserMySigningKey.ps1 | 30 ++-- .../Get-GitHubUserMySigningKeyById.ps1 | 24 ++- .../Get-GitHubUserSigningKeyForUser.ps1 | 31 ++-- .../Get-GitHubMyUserSocials.ps1 | 34 ++-- .../Get-GitHubUserSocialsByName.ps1 | 24 ++- .../Utilities/Hashtable/Join-Object.ps1 | 2 +- .../Get-GitHubWorkflowRun.ps1 | 85 +++++----- .../Remove-GitHubWorkflowRun.ps1 | 49 +++--- .../Restart-GitHubWorkflowRun.ps1} | 47 +++--- .../Stop-GitHubWorkflowRun.ps1 | 47 +++--- .../{ => Workflow}/Disable-GitHubWorkflow.ps1 | 41 +++-- .../{ => Workflow}/Enable-GitHubWorkflow.ps1 | 43 +++-- .../{ => Workflow}/Get-GitHubWorkflow.ps1 | 55 +++--- .../Get-GitHubWorkflowUsage.ps1 | 46 +++-- .../{ => Workflow}/Start-GitHubWorkflow.ps1 | 55 +++--- ...-GitHubAppInstallationRepositoryAccess.ps1 | 42 ++--- .../Get-GitHubAppAccessibleRepository.ps1 | 41 ++--- .../Get-GitHubAppInstallation.ps1 | 42 +++-- ...-GitHubAppInstallationRepositoryAccess.ps1 | 44 ++--- ...-GitHubAppInstallationRepositoryAccess.ps1 | 42 ++--- ...-GitHubAppInstallationRepositoryAccess.ps1 | 55 +++--- .../Get-GitHubApp.ps1 | 18 +- .../Get-GitHubAppInstallableOrganization.ps1 | 40 ++--- .../Get-GitHubAppJSONWebToken.ps1 | 0 .../Install-GitHubApp.ps1 | 37 ++-- .../New-GitHubAppInstallationAccessToken.ps1 | 30 ++-- .../Uninstall-GitHubApp.ps1 | 31 +--- .../Get-GitHubAppWebhookConfiguration.ps1 | 20 +-- .../Webhooks/Get-GitHubAppWebhookDelivery.ps1 | 30 ++-- .../Invoke-GitHubAppWebhookReDelivery.ps1 | 28 ++-- .../Update-GitHubAppWebhookConfiguration.ps1 | 37 ++-- .../public/Auth/Connect-GitHubAccount.ps1 | 14 +- .../public/Auth/Connect-GitHubApp.ps1 | 4 +- .../public/Auth/Context/Get-GitHubContext.ps1 | 4 +- .../public/Branches/Get-GitHubRepoBranch.ps1 | 37 ++-- .../public/Emojis/Get-GitHubEmoji.ps1 | 62 +++---- .../GraphQL/Invoke-GitHubGraphQLQuery.ps1 | 30 ++-- .../public/License/Get-GitHubLicense.ps1 | 35 ++-- .../public/Markdown/Get-GitHubMarkdown.ps1 | 34 ++-- .../public/Markdown/Get-GitHubMarkdownRaw.ps1 | 31 ++-- .../public/Meta/Get-GitHubApiVersion.ps1 | 20 +-- src/functions/public/Meta/Get-GitHubMeta.ps1 | 20 +-- .../public/Meta/Get-GitHubOctocat.ps1 | 30 ++-- src/functions/public/Meta/Get-GitHubRoot.ps1 | 20 +-- src/functions/public/Meta/Get-GitHubZen.ps1 | 20 +-- .../Organization/Get-GitHubOrganization.ps1 | 3 - .../Members/Get-GitHubOrganizationMember.ps1 | 36 ++-- ...et-GitHubOrganizationPendingInvitation.ps1 | 36 ++-- .../New-GitHubOrganizationInvitation.ps1 | 42 ++--- .../Remove-GitHubOrganizationInvitation.ps1 | 25 +-- .../Remove-GitHubOrganization.ps1 | 28 +--- .../Update-GitHubOrganization.ps1 | 88 +++++----- ...date-GitHubOrganizationSecurityFeature.ps1 | 36 ++-- .../public/Rate-Limit/Get-GitHubRateLimit.ps1 | 18 +- .../Assets/Add-GitHubReleaseAsset.ps1 | 108 ++++++------ .../Assets/Get-GitHubReleaseAsset.ps1 | 34 ++-- .../Assets/Remove-GitHubReleaseAsset.ps1 | 40 ++--- .../Assets/Set-GitHubReleaseAsset.ps1 | 52 +++--- .../Releases/Releases/Get-GitHubRelease.ps1 | 34 ++-- .../Releases/Releases/New-GitHubRelease.ps1 | 66 +++----- .../Releases/New-GitHubReleaseNote.ps1 | 52 +++--- .../Releases/Remove-GitHubRelease.ps1 | 40 ++--- .../Releases/Releases/Set-GitHubRelease.ps1 | 64 +++---- .../Get-GitHubRepositoryAutolink.ps1 | 34 ++-- .../New-GitHubRepositoryAutolink.ps1 | 48 ++---- .../Remove-GitHubRepositoryAutolink.ps1 | 43 ++--- .../Get-GitHubRepositoryCustomProperty.ps1 | 39 ++--- ...epositoryPrivateVulnerabilityReporting.ps1 | 41 ++--- .../Disable-GitHubRepositorySecurityFix.ps1 | 41 ++--- ...ble-GitHubRepositoryVulnerabilityAlert.ps1 | 41 ++--- ...epositoryPrivateVulnerabilityReporting.ps1 | 41 ++--- .../Enable-GitHubRepositorySecurityFix.ps1 | 41 ++--- ...ble-GitHubRepositoryVulnerabilityAlert.ps1 | 41 ++--- .../Repositories/Get-GitHubRepository.ps1 | 158 ++++++++---------- .../Get-GitHubRepositoryActivity.ps1 | 77 ++++----- .../Get-GitHubRepositoryCodeownersError.ps1 | 49 ++---- .../Get-GitHubRepositoryContributor.ps1 | 51 +++--- .../Repositories/Get-GitHubRepositoryFork.ps1 | 51 +++--- .../Get-GitHubRepositoryLanguage.ps1 | 39 ++--- .../Get-GitHubRepositorySecurityFix.ps1 | 39 ++--- .../Repositories/Get-GitHubRepositoryTag.ps1 | 47 ++---- .../Repositories/Get-GitHubRepositoryTeam.ps1 | 47 ++---- .../Get-GitHubRepositoryTopic.ps1 | 45 ++--- .../Repositories/Move-GitHubRepository.ps1 | 53 +++--- .../Repositories/Remove-GitHubRepository.ps1 | 41 ++--- .../Set-GitHubRepositoryTopic.ps1 | 49 ++---- .../Start-GitHubRepositoryEvent.ps1 | 49 ++---- ...est-GitHubRepositoryVulnerabilityAlert.ps1 | 35 +--- .../Repositories/Update-GitHubRepository.ps1 | 113 ++++++------- .../Get-GitHubRepositoryRuleSuite.ps1 | 60 +++---- .../Get-GitHubRepositoryRuleSuiteById.ps1 | 42 ++--- .../Get-GitHubRepositoryRuleSuiteList.ps1 | 55 +++--- .../Get-GitHubRepositoryTagProtection.ps1 | 39 ++--- .../New-GitHubRepositoryTagProtection.ps1 | 49 ++---- .../Remove-GitHubRepositoryTagProtection.ps1 | 41 ++--- src/functions/public/Teams/Get-GitHubTeam.ps1 | 4 +- src/functions/public/Teams/New-GitHubTeam.ps1 | 86 +++++----- .../public/Teams/Remove-GitHubTeam.ps1 | 31 ++-- .../public/Teams/Update-GitHubTeam.ps1 | 88 +++++----- .../Users/Emails/Add-GitHubUserEmail.ps1 | 30 ++-- .../Users/Emails/Remove-GitHubUserEmail.ps1 | 30 ++-- .../Update-GitHubUserEmailVisibility.ps1 | 28 ++-- .../Followers/Add-GitHubUserFollowing.ps1 | 18 +- .../Followers/Remove-GitHubUserFollowing.ps1 | 20 +-- .../Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 | 30 ++-- .../GPG-Keys/Remove-GitHubUserGpgKey.ps1 | 20 +-- .../public/Users/Keys/Add-GitHubUserKey.ps1 | 28 ++-- .../Users/Keys/Remove-GitHubUserKey.ps1 | 20 +-- .../Add-GitHubUserSigningKey.ps1 | 28 ++-- .../Remove-GitHubUserSigningKey.ps1 | 20 +-- .../Social-Accounts/Add-GitHubUserSocial.ps1 | 30 ++-- .../Remove-GitHubUserSocial.ps1 | 32 ++-- .../public/Users/Update-GitHubUser.ps1 | 44 +++-- tests/GitHub.Tests.ps1 | 12 +- tools/Guidelines.md | 23 +++ 190 files changed, 2202 insertions(+), 3235 deletions(-) rename src/functions/public/Actions/{ => Workflow Run}/Get-GitHubWorkflowRun.ps1 (74%) rename src/functions/public/Actions/{ => Workflow Run}/Remove-GitHubWorkflowRun.ps1 (64%) rename src/functions/public/Actions/{Start-GitHubWorkflowReRun.ps1 => Workflow Run/Restart-GitHubWorkflowRun.ps1} (61%) rename src/functions/public/Actions/{ => Workflow Run}/Stop-GitHubWorkflowRun.ps1 (60%) rename src/functions/public/Actions/{ => Workflow}/Disable-GitHubWorkflow.ps1 (65%) rename src/functions/public/Actions/{ => Workflow}/Enable-GitHubWorkflow.ps1 (59%) rename src/functions/public/Actions/{ => Workflow}/Get-GitHubWorkflow.ps1 (60%) rename src/functions/public/Actions/{ => Workflow}/Get-GitHubWorkflowUsage.ps1 (58%) rename src/functions/public/Actions/{ => Workflow}/Start-GitHubWorkflow.ps1 (68%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Add-GitHubAppInstallationRepositoryAccess.ps1 (67%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Get-GitHubAppAccessibleRepository.ps1 (65%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Get-GitHubAppInstallation.ps1 (65%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Get-GitHubAppInstallationRepositoryAccess.ps1 (67%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Remove-GitHubAppInstallationRepositoryAccess.ps1 (67%) rename src/functions/public/Apps/{GitHub Apps => GitHub App Installations}/Update-GitHubAppInstallationRepositoryAccess.ps1 (68%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Get-GitHubApp.ps1 (79%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Get-GitHubAppInstallableOrganization.ps1 (57%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Get-GitHubAppJSONWebToken.ps1 (100%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Install-GitHubApp.ps1 (69%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/New-GitHubAppInstallationAccessToken.ps1 (85%) rename src/functions/public/Apps/{GitHub Apps => GitHub App}/Uninstall-GitHubApp.ps1 (64%) diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 index 98a0fe01e..6597ed8aa 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 @@ -12,19 +12,19 @@ `created`, `event`, `head_sha`, `status`. .EXAMPLE - Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repo 'repo' + Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repository 'repo' Lists all workflow runs for a repository. .EXAMPLE - Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repo 'repo' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success' + Get-GitHubWorkflowRunByRepo -Owner 'owner' -Repository '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')] + [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'Event', Justification = 'A parameter that is used in the api call.')] @@ -35,7 +35,7 @@ # The name of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # Returns someone's workflow runs. Use the login for the user who created the push associated with the check suite or workflow run. [Parameter()] @@ -82,52 +82,38 @@ [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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + } + + process { + $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 } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Context = $Context + APIEndpoint = "/repos/$Owner/$Repository/actions/runs" + Method = 'GET' + Body = $body } - 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 $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.workflow_runs } } diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 index b76e45b85..ac827cd0b 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 @@ -13,12 +13,12 @@ `created`, `event`, `head_sha`, `status`. .EXAMPLE - Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repo 'Hello-World' -ID '42' + Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repository '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' + Get-GitHubWorkflowRunByWorkflow -Owner 'octocat' -Repository '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`. @@ -26,7 +26,7 @@ .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')] + [CmdletBinding()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'Event', Justification = 'A parameter that is used in the api call.')] @@ -37,7 +37,7 @@ # The name of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The ID of the workflow. You can also pass the workflow filename as a string. [Parameter(Mandatory)] @@ -89,52 +89,38 @@ [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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + } + + process { + $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 } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Context = $Context + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/runs" + Method = 'GET' + Body = $body } - 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 $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.workflow_runs } } diff --git a/src/functions/private/Actions/Import-GitHubEventData.ps1 b/src/functions/private/Actions/Import-GitHubEventData.ps1 index def1ed332..fa5cf33de 100644 --- a/src/functions/private/Actions/Import-GitHubEventData.ps1 +++ b/src/functions/private/Actions/Import-GitHubEventData.ps1 @@ -25,50 +25,46 @@ function Import-GitHubEventData { } process { - try { - $gitHubEventJson = Get-Content -Path $env:GITHUB_EVENT_PATH - $gitHubEvent = $gitHubEventJson | ConvertFrom-Json + $gitHubEventJson = Get-Content -Path $env:GITHUB_EVENT_PATH + $gitHubEvent = $gitHubEventJson | ConvertFrom-Json - $eventAction = $gitHubEvent.action - $eventSender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url - $eventEnterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url - $eventOrganization = $gitHubEvent.organization | Select-Object -Property login, id, node_id - $eventOwner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url - $eventRepository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch + $eventAction = $gitHubEvent.action + $eventSender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url + $eventEnterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url + $eventOrganization = $gitHubEvent.organization | Select-Object -Property login, id, node_id + $eventOwner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url + $eventRepository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch - $gitHubEvent = $gitHubEvent | Select-Object -ExcludeProperty action, sender, enterprise, organization, repository + $gitHubEvent = $gitHubEvent | Select-Object -ExcludeProperty action, sender, enterprise, organization, repository - $hashtable = @{} - $gitHubEvent.PSObject.Properties | ForEach-Object { - $name = $_.Name - $name = $name | ConvertTo-CasingStyle -To PascalCase - $hashtable[$name] = $_.Value - } - $gitHubEvent = [pscustomobject]$hashtable + $hashtable = @{} + $gitHubEvent.PSObject.Properties | ForEach-Object { + $name = $_.Name + $name = $name | ConvertTo-CasingStyle -To PascalCase + $hashtable[$name] = $_.Value + } + $gitHubEvent = [pscustomobject]$hashtable - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Type -Value $env:GITHUB_EVENT_NAME -Force - if ($eventAction) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Action -Value $eventAction -Force - } - if ($eventSender) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Sender -Value $eventSender -Force - } - if ($eventEnterprise) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Enterprise -Value $eventEnterprise -Force - } - if ($eventOrganization) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Organization -Value $eventOrganization -Force - } - if ($eventOwner) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Owner -Value $eventOwner -Force - } - if ($eventRepository) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Repository -Value $eventRepository -Force - } - $script:GitHub.Event = $gitHubEvent - } catch { - throw $_ + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Type -Value $env:GITHUB_EVENT_NAME -Force + if ($eventAction) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Action -Value $eventAction -Force + } + if ($eventSender) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Sender -Value $eventSender -Force + } + if ($eventEnterprise) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Enterprise -Value $eventEnterprise -Force + } + if ($eventOrganization) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Organization -Value $eventOrganization -Force + } + if ($eventOwner) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Owner -Value $eventOwner -Force + } + if ($eventRepository) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Repository -Value $eventRepository -Force } + $script:GitHub.Event = $gitHubEvent } end { diff --git a/src/functions/private/Actions/Import-GitHubRunnerData.ps1 b/src/functions/private/Actions/Import-GitHubRunnerData.ps1 index 82dbd59e0..3a8ae9542 100644 --- a/src/functions/private/Actions/Import-GitHubRunnerData.ps1 +++ b/src/functions/private/Actions/Import-GitHubRunnerData.ps1 @@ -23,21 +23,17 @@ } process { - try { - $script:GitHub.Runner = [pscustomobject]@{ - Name = $env:RUNNER_NAME - OS = $env:RUNNER_OS - Arch = $env:RUNNER_ARCH - Environment = $env:RUNNER_ENVIRONMENT - Temp = $env:RUNNER_TEMP - Perflog = $env:RUNNER_PERFLOG - ToolCache = $env:RUNNER_TOOL_CACHE - TrackingID = $env:RUNNER_TRACKING_ID - Workspace = $env:RUNNER_WORKSPACE - Processors = [System.Environment]::ProcessorCount - } - } catch { - throw $_ + $script:GitHub.Runner = [pscustomobject]@{ + Name = $env:RUNNER_NAME + OS = $env:RUNNER_OS + Arch = $env:RUNNER_ARCH + Environment = $env:RUNNER_ENVIRONMENT + Temp = $env:RUNNER_TEMP + Perflog = $env:RUNNER_PERFLOG + ToolCache = $env:RUNNER_TOOL_CACHE + TrackingID = $env:RUNNER_TRACKING_ID + Workspace = $env:RUNNER_WORKSPACE + Processors = [System.Environment]::ProcessorCount } } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 index 22ef0dec1..b421c91d1 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 @@ -25,9 +25,8 @@ [string] $AppSlug, # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 1b050149b..3e966b2d9 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -20,9 +20,8 @@ [CmdletBinding()] param( # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index ad85c6b0b..c6c9a67af 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -24,9 +24,8 @@ [CmdletBinding()] param( # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index 8349ddfeb..ad1c493dd 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -39,9 +39,8 @@ [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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index 958a09cbd..56ab2caf7 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -32,9 +32,8 @@ [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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 index 7849873ba..12f7e356c 100644 --- a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -37,9 +37,8 @@ [string[]] $Repositories, # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index 770d9d143..ae871c909 100644 --- a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -28,9 +28,8 @@ [string] $ID, # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index c1625f6ae..4244933f4 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -27,9 +27,8 @@ [string] $ID, # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 81423d7fa..233cabd8c 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -26,9 +26,8 @@ [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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 index c6a69b1f9..b9b532fe4 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 @@ -24,9 +24,8 @@ [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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 index bd1741389..4bfe1d32b 100644 --- a/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Assert-GitHubContext.ps1 @@ -1,4 +1,4 @@ -filter Assert-GitHubContext { +filter Assert-GitHubContext { <# .SYNOPSIS Check if the context meets the requirements for the command. diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index 2b65f3888..ab55514c0 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } +#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } function Set-GitHubContext { <# @@ -17,7 +17,7 @@ function Set-GitHubContext { AuthType = 'PAT' Enterprise = 'msx' Owner = 'octocat' - Repo = 'Hello-World' + Repository = 'Hello-World' } Set-GitHubContext -Context $context @@ -52,9 +52,9 @@ function Set-GitHubContext { # Run functions to get info on the temporary context. try { Write-Debug "Getting info on the context [$($contextObj['AuthType'])]." - switch -Regex ($($contextObj['AuthType'])) { + switch -Regex (($contextObj['AuthType'])) { 'PAT|UAT|IAT' { - $viewer = Get-GitHubViewer -Context $contextObj + $viewer = Get-GitHubViewer -Context [UserGitHubContext]$contextObj $viewer | Out-String -Stream | ForEach-Object { Write-Debug $_ } if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) { $contextObj['DisplayName'] = [string]$viewer.name @@ -79,7 +79,7 @@ function Set-GitHubContext { $contextObj['Type'] = 'Installation' if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) { try { - $app = Get-GitHubApp -AppSlug $contextObj['Username'] -Context $contextObj + $app = Get-GitHubApp -Name $contextObj['Username'] -Context [InstallationGitHubContext]($contextObj) $contextObj['DisplayName'] = [string]$app.name } catch { Write-Debug "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." @@ -92,11 +92,11 @@ function Set-GitHubContext { $enterprise = $gitHubEvent.enterprise.slug $organization = $gitHubEvent.organization.login $owner = $gitHubEvent.repository.owner.login - $repo = $gitHubEvent.repository.name + $Repository = $gitHubEvent.repository.name $gh_sender = $gitHubEvent.sender.login # sender is an automatic variable in Powershell Write-Debug "Enterprise: $enterprise" Write-Debug "Organization: $organization" - Write-Debug "Repository: $repo" + Write-Debug "Repository: $Repository" Write-Debug "Repository Owner: $owner" Write-Debug "Repository Owner Type: $installationType" Write-Debug "Sender: $gh_sender" @@ -106,8 +106,8 @@ function Set-GitHubContext { if ([string]::IsNullOrEmpty($contextObj['Owner'])) { $contextObj['Owner'] = [string]$owner } - if ([string]::IsNullOrEmpty($contextObj['Repo'])) { - $contextObj['Repo'] = [string]$repo + if ([string]::IsNullOrEmpty($contextObj['Repository'])) { + $contextObj['Repository'] = [string]$Repository } if ([string]::IsNullOrEmpty($contextObj['InstallationType'])) { $contextObj['InstallationType'] = [string]$installationType @@ -123,7 +123,7 @@ function Set-GitHubContext { } } 'App' { - $app = Get-GitHubApp -Context $contextObj + $app = Get-GitHubApp -Context [AppGitHubContext]($contextObj) $contextObj['Name'] = "$($contextObj['HostName'])/$($app.slug)" $contextObj['DisplayName'] = [string]$app.name $contextObj['Username'] = [string]$app.slug diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 index 609dee52f..a6d022531 100644 --- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 @@ -1,4 +1,4 @@ -function Test-GitHubAccessTokenRefreshRequired { +function Test-GitHubAccessTokenRefreshRequired { <# .SYNOPSIS Test if the GitHub access token should be refreshed. @@ -17,7 +17,7 @@ function Test-GitHubAccessTokenRefreshRequired { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index c3cd9a12d..a653ef76e 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -28,7 +28,7 @@ # 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(Mandatory)] - [object] $Context, + [GitHubContext] $Context, # Return the new access token. [Parameter()] diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index 22bbba823..27d493e75 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubGitignoreList { +filter Get-GitHubGitignoreList { <# .SYNOPSIS Get all gitignore templates @@ -22,7 +22,7 @@ filter Get-GitHubGitignoreList { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index 7455e5a69..775d556ca 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubLicenseByName { +filter Get-GitHubLicenseByName { <# .SYNOPSIS Get a license @@ -27,7 +27,7 @@ filter Get-GitHubLicenseByName { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index bef458d37..13fcd1839 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubLicenseList { +filter Get-GitHubLicenseList { <# .SYNOPSIS Get all commonly used licenses @@ -23,7 +23,7 @@ filter Get-GitHubLicenseList { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index f120c60ac..1d7a4512d 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryLicense { +filter Get-GitHubRepositoryLicense { <# .SYNOPSIS Get the license for a repository @@ -10,7 +10,7 @@ filter Get-GitHubRepositoryLicense { [custom media types](https://docs.github.com/rest/overview/media-types) for retrieving the raw license content or rendered license HTML. .EXAMPLE - Get-GitHubRepositoryLicense -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryLicense -Owner 'octocat' -Repository 'Hello-World' Get the license for the Hello-World repository from the octocat account. @@ -26,7 +26,7 @@ filter Get-GitHubRepositoryLicense { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The type of data to return. Can be either 'raw' or 'html'. [Parameter()] @@ -36,7 +36,7 @@ filter Get-GitHubRepositoryLicense { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -53,7 +53,7 @@ filter Get-GitHubRepositoryLicense { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/license" + APIEndpoint = "/repos/$Owner/$Repository/license" ContentType = $contentType Context = $Context } diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 6cc150aff..e1bafcbdf 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Block-GitHubUserByOrganization { +filter Block-GitHubUserByOrganization { <# .SYNOPSIS Block a user from an organization @@ -41,7 +41,7 @@ filter Block-GitHubUserByOrganization { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index eb4aa38d0..e5671dce4 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubBlockedUserByOrganization { +filter Get-GitHubBlockedUserByOrganization { <# .SYNOPSIS List users blocked by an organization @@ -32,7 +32,7 @@ filter Get-GitHubBlockedUserByOrganization { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index 793804ede..4c039d510 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubBlockedUserByOrganization { +filter Test-GitHubBlockedUserByOrganization { <# .SYNOPSIS Check if a user is blocked by an organization @@ -40,7 +40,7 @@ filter Test-GitHubBlockedUserByOrganization { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index 37cacea02..2aa2ed4e6 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -1,4 +1,4 @@ -filter Unblock-GitHubUserByOrganization { +filter Unblock-GitHubUserByOrganization { <# .SYNOPSIS Unblock a user from an organization @@ -41,7 +41,7 @@ filter Unblock-GitHubUserByOrganization { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index fc3494857..13788020a 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubAllOrganization { +filter Get-GitHubAllOrganization { <# .SYNOPSIS List organizations @@ -34,7 +34,7 @@ filter Get-GitHubAllOrganization { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index 9ff4fcef4..2e7de44bc 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubMyOrganization { +filter Get-GitHubMyOrganization { <# .SYNOPSIS List organizations for the authenticated user @@ -33,7 +33,7 @@ filter Get-GitHubMyOrganization { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index 8532ba696..b89e67ed8 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubOrganizationByName { +filter Get-GitHubOrganizationByName { <# .SYNOPSIS Get an organization @@ -39,7 +39,7 @@ filter Get-GitHubOrganizationByName { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index 47a5dc85e..a60448efc 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserOrganization { +filter Get-GitHubUserOrganization { <# .SYNOPSIS List organizations for a user @@ -35,7 +35,7 @@ filter Get-GitHubUserOrganization { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index 6cab42f09..ba44d8793 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAssetByID { +filter Get-GitHubReleaseAssetByID { <# .SYNOPSIS Get a release asset @@ -10,7 +10,7 @@ filter Get-GitHubReleaseAssetByID { possible. API clients should handle both a `200` or `302` response. .EXAMPLE - Get-GitHubReleaseAssetByID -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseAssetByID -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release asset with the ID '1234567' for the repository 'octocat/hello-world'. @@ -26,7 +26,7 @@ filter Get-GitHubReleaseAssetByID { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the asset. [Parameter(Mandatory)] @@ -36,7 +36,7 @@ filter Get-GitHubReleaseAssetByID { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -48,7 +48,7 @@ filter Get-GitHubReleaseAssetByID { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" Context = $Context } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 27f0858ca..c31fd7efa 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAssetByReleaseID { +filter Get-GitHubReleaseAssetByReleaseID { <# .SYNOPSIS List release assets @@ -7,7 +7,7 @@ filter Get-GitHubReleaseAssetByReleaseID { List release assets .EXAMPLE - Get-GitHubReleaseAssetByReleaseID -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseAssetByReleaseID -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release assets for the release with the ID '1234567' for the repository 'octocat/hello-world'. @@ -23,7 +23,7 @@ filter Get-GitHubReleaseAssetByReleaseID { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the release. [Parameter( @@ -41,7 +41,7 @@ filter Get-GitHubReleaseAssetByReleaseID { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -57,7 +57,7 @@ filter Get-GitHubReleaseAssetByReleaseID { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets" + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID/assets" Body = $body Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index e974d58f2..c13b6de84 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAll { +filter Get-GitHubReleaseAll { <# .SYNOPSIS List releases @@ -9,7 +9,7 @@ filter Get-GitHubReleaseAll { Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. .EXAMPLE - Get-GitHubReleaseAll -Owner 'octocat' -Repo 'hello-world' + Get-GitHubReleaseAll -Owner 'octocat' -Repository 'hello-world' Gets all the releases for the repository 'hello-world' owned by 'octocat'. @@ -25,7 +25,7 @@ filter Get-GitHubReleaseAll { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The number of results per page (max 100). [Parameter(ParameterSetName = 'AllUsers')] @@ -35,7 +35,7 @@ filter Get-GitHubReleaseAll { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -51,7 +51,7 @@ filter Get-GitHubReleaseAll { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases" + APIEndpoint = "/repos/$Owner/$Repository/releases" Body = $body Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 4acdfef66..153908c37 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseByID { +filter Get-GitHubReleaseByID { <# .SYNOPSIS Get a release @@ -8,7 +8,7 @@ filter Get-GitHubReleaseByID { This key is a [hypermedia resource](https://docs.github.com/rest/overview/resources-in-the-rest-api#hypermedia). .EXAMPLE - Get-GitHubReleaseById -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseById -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release with the ID '1234567' for the repository 'hello-world' owned by 'octocat'. @@ -24,7 +24,7 @@ filter Get-GitHubReleaseByID { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the release. [Parameter(Mandatory)] @@ -34,7 +34,7 @@ filter Get-GitHubReleaseByID { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -46,7 +46,7 @@ filter Get-GitHubReleaseByID { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index 944f744f1..87cf0c065 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseByTagName { +filter Get-GitHubReleaseByTagName { <# .SYNOPSIS Get a release by tag name @@ -7,7 +7,7 @@ filter Get-GitHubReleaseByTagName { Get a published release with the specified tag. .EXAMPLE - Get-GitHubReleaseByTagName -Owner 'octocat' -Repo 'hello-world' -Tag 'v1.0.0' + Get-GitHubReleaseByTagName -Owner 'octocat' -Repository 'hello-world' -Tag 'v1.0.0' Gets the release with the tag 'v1.0.0' for the repository 'hello-world' owned by 'octocat'. @@ -23,7 +23,7 @@ filter Get-GitHubReleaseByTagName { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The name of the tag to get a release from. [Parameter(Mandatory)] @@ -33,7 +33,7 @@ filter Get-GitHubReleaseByTagName { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -45,7 +45,7 @@ filter Get-GitHubReleaseByTagName { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag" + APIEndpoint = "/repos/$Owner/$Repository/releases/tags/$Tag" Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index a8aa34f47..2634dd5cd 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseLatest { +filter Get-GitHubReleaseLatest { <# .SYNOPSIS Get the latest release @@ -9,7 +9,7 @@ filter Get-GitHubReleaseLatest { The `created_at` attribute is the date of the commit used for the release, and not the date when the release was drafted or published. .EXAMPLE - Get-GitHubReleaseLatest -Owner 'octocat' -Repo 'hello-world' + Get-GitHubReleaseLatest -Owner 'octocat' -Repository 'hello-world' Gets the latest releases for the repository 'hello-world' owned by 'octocat'. @@ -25,12 +25,12 @@ filter Get-GitHubReleaseLatest { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -42,7 +42,7 @@ filter Get-GitHubReleaseLatest { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/releases/latest" + APIEndpoint = "/repos/$Owner/$Repository/releases/latest" Context = $Context } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index 6498a8d03..a7469f229 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryAutolinkById { +filter Get-GitHubRepositoryAutolinkById { <# .SYNOPSIS Get an autolink reference of a repository @@ -9,7 +9,7 @@ filter Get-GitHubRepositoryAutolinkById { Information about autolinks are only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryAutolinkById -Owner 'octocat' -Repo 'Hello-World' -ID 1 + Get-GitHubRepositoryAutolinkById -Owner 'octocat' -Repository 'Hello-World' -ID 1 Gets the autolink with the ID 1 for the repository 'Hello-World' owned by 'octocat'. @@ -26,7 +26,7 @@ filter Get-GitHubRepositoryAutolinkById { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the autolink. [Parameter(Mandatory)] @@ -37,7 +37,7 @@ filter Get-GitHubRepositoryAutolinkById { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -49,7 +49,7 @@ filter Get-GitHubRepositoryAutolinkById { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/autolinks/$ID" + APIEndpoint = "/repos/$Owner/$Repository/autolinks/$ID" Context = $Context } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index bb7e75a02..4bca16a8c 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryAutolinkList { +filter Get-GitHubRepositoryAutolinkList { <# .SYNOPSIS List all autolinks of a repository @@ -9,7 +9,7 @@ filter Get-GitHubRepositoryAutolinkList { Information about autolinks are only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryAutolinkList -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryAutolinkList -Owner 'octocat' -Repository 'Hello-World' Gets all autolinks for the repository 'Hello-World' owned by 'octocat'. @@ -25,12 +25,12 @@ filter Get-GitHubRepositoryAutolinkList { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -42,7 +42,7 @@ filter Get-GitHubRepositoryAutolinkList { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/autolinks" + APIEndpoint = "/repos/$Owner/$Repository/autolinks" Context = $Context } diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index 237e5c086..4ba5974b0 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -1,4 +1,4 @@ -filter New-GitHubRepositoryAsFork { +filter New-GitHubRepositoryAsFork { <# .SYNOPSIS Create a fork @@ -46,7 +46,7 @@ filter New-GitHubRepositoryAsFork { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The organization or person who will own the new repository. # To create a new repository in an organization, the authenticated user must be a member of the specified organization. @@ -65,7 +65,7 @@ filter New-GitHubRepositoryAsFork { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -83,12 +83,12 @@ filter New-GitHubRepositoryAsFork { $inputObject = @{ Method = 'Post' - APIEndpoint = "/repos/$Owner/$Repo/forks" + APIEndpoint = "/repos/$Owner/$Repository/forks" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repo]", 'Create')) { + if ($PSCmdlet.ShouldProcess("Repository [$Organization/$Name] as fork of [$Owner/$Repository]", 'Create')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index e2623b638..12c81202e 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubMyRepositories { +filter Get-GitHubMyRepositories { <# .SYNOPSIS List repositories for the authenticated user @@ -110,7 +110,7 @@ filter Get-GitHubMyRepositories { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index db9a3ab3d..22aec464c 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryByName { +filter Get-GitHubRepositoryByName { <# .SYNOPSIS Get a repository @@ -11,7 +11,7 @@ filter Get-GitHubRepositoryByName { For more information, see "[Managing security managers in your organization](https://docs.github.com/organizations/managing-peoples-access-to-your-organization-with-roles/managing-security-managers-in-your-organization)." .EXAMPLE - Get-GitHubRepositoryByName -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryByName -Owner 'octocat' -Repository 'Hello-World' Gets the repository 'Hello-World' for the organization 'octocat'. @@ -28,12 +28,12 @@ filter Get-GitHubRepositoryByName { # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -45,7 +45,7 @@ filter Get-GitHubRepositoryByName { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo" + APIEndpoint = "/repos/$Owner/$Repository" Context = $Context } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index 1fbea0082..04a904b5e 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryListByID { +filter Get-GitHubRepositoryListByID { <# .SYNOPSIS List public repositories @@ -30,7 +30,7 @@ filter Get-GitHubRepositoryListByID { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index e40db9b3a..0c1ea9773 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryListByOrg { +filter Get-GitHubRepositoryListByOrg { <# .SYNOPSIS List organization repositories @@ -59,7 +59,7 @@ filter Get-GitHubRepositoryListByOrg { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index f6ac46d76..6f3930ef6 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryListByUser { +filter Get-GitHubRepositoryListByUser { <# .SYNOPSIS List repositories for a user @@ -61,7 +61,7 @@ filter Get-GitHubRepositoryListByUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index 2182c21b6..a00eae03e 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -1,4 +1,4 @@ -filter New-GitHubRepositoryFromTemplate { +filter New-GitHubRepositoryFromTemplate { <# .SYNOPSIS Create a repository using a template @@ -75,7 +75,7 @@ filter New-GitHubRepositoryFromTemplate { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 5082c3812..1304ffca0 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } +#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } filter New-GitHubRepositoryOrg { <# @@ -184,7 +184,7 @@ filter New-GitHubRepositoryOrg { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) dynamicparam { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index 9e46edd1f..377b12622 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } +#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' } filter New-GitHubRepositoryUser { <# @@ -178,7 +178,7 @@ filter New-GitHubRepositoryUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) dynamicparam { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index b3ea3dcb5..1d5650e2c 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubRESTTeam { +function Get-GitHubRESTTeam { <# .SYNOPSIS List teams from an org or get a team by name @@ -41,7 +41,7 @@ function Get-GitHubRESTTeam { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index 12035b15b..0a2e1b0a2 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubRESTTeamByName { +function Get-GitHubRESTTeamByName { <# .SYNOPSIS Get a team by name @@ -25,7 +25,7 @@ function Get-GitHubRESTTeamByName { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index 0bd846db4..bfbdfa6bd 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubRESTTeamListByOrg { +function Get-GitHubRESTTeamListByOrg { <# .SYNOPSIS List teams @@ -22,7 +22,7 @@ function Get-GitHubRESTTeamListByOrg { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index a616d5c64..600ebd71f 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepoTeam { +filter Get-GitHubRepoTeam { <# .NOTES [List repository teams](https://docs.github.com/rest/reference/repos#get-a-repository) @@ -9,12 +9,12 @@ filter Get-GitHubRepoTeam { [string] $Owner, [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -26,7 +26,7 @@ filter Get-GitHubRepoTeam { process { $inputObject = @{ Method = 'Get' - APIEndpoint = "/repos/$Owner/$Repo/teams" + APIEndpoint = "/repos/$Owner/$Repository/teams" Context = $Context } diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 index c2ceaea44..aa982f873 100644 --- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeamBySlug { +function Get-GitHubTeamBySlug { <# .SYNOPSIS Get a team by name @@ -26,7 +26,7 @@ function Get-GitHubTeamBySlug { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 index ac51a9466..68800806b 100644 --- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeamListByOrg { +function Get-GitHubTeamListByOrg { <# .SYNOPSIS List teams @@ -23,7 +23,7 @@ function Get-GitHubTeamListByOrg { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index 86f770813..9c917a354 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Block-GitHubUserByUser { +filter Block-GitHubUserByUser { <# .SYNOPSIS Block a user @@ -30,7 +30,7 @@ filter Block-GitHubUserByUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index d9949ced7..72e0cfe8c 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubBlockedUserByUser { +filter Get-GitHubBlockedUserByUser { <# .SYNOPSIS List users blocked by the authenticated user @@ -25,7 +25,7 @@ filter Get-GitHubBlockedUserByUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index 70df6df0e..0122933d7 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubBlockedUserByUser { +filter Test-GitHubBlockedUserByUser { <# .SYNOPSIS Check if a user is blocked by the authenticated user @@ -37,7 +37,7 @@ filter Test-GitHubBlockedUserByUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index c2030759f..a6faaff90 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -1,4 +1,4 @@ -filter Unblock-GitHubUserByUser { +filter Unblock-GitHubUserByUser { <# .SYNOPSIS Unblock a user @@ -30,7 +30,7 @@ filter Unblock-GitHubUserByUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index b3e313786..ff42b473a 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserAllEmail { +filter Get-GitHubUserAllEmail { <# .SYNOPSIS List email addresses for the authenticated user @@ -27,7 +27,7 @@ filter Get-GitHubUserAllEmail { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index 745d0e8da..678c218fa 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserPublicEmail { +filter Get-GitHubUserPublicEmail { <# .SYNOPSIS List public email addresses for the authenticated user @@ -29,7 +29,7 @@ filter Get-GitHubUserPublicEmail { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index 2be3f433b..ecd946e7c 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserFollowersOfUser { +filter Get-GitHubUserFollowersOfUser { <# .SYNOPSIS List followers of a user @@ -35,7 +35,7 @@ filter Get-GitHubUserFollowersOfUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index 8e3d6d047..397c7cf5f 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserFollowingMe { +filter Get-GitHubUserFollowingMe { <# .SYNOPSIS List the people the authenticated user follows @@ -26,7 +26,7 @@ filter Get-GitHubUserFollowingMe { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index 3801b5dd5..1dd8afb31 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserFollowingUser { +filter Get-GitHubUserFollowingUser { <# .SYNOPSIS List the people a user follows @@ -35,7 +35,7 @@ filter Get-GitHubUserFollowingUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index 21b5f7548..112c6ce7c 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserMyFollowers { +filter Get-GitHubUserMyFollowers { <# .SYNOPSIS List followers of the authenticated user @@ -30,7 +30,7 @@ filter Get-GitHubUserMyFollowers { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index fe34676dd..83960bdd6 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubUserFollowedByMe { +filter Test-GitHubUserFollowedByMe { <# .SYNOPSIS Check if a person is followed by the authenticated user @@ -30,7 +30,7 @@ filter Test-GitHubUserFollowedByMe { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index 317ca6cbd..f577993f2 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -1,4 +1,4 @@ -filter Test-GitHubUserFollowedByUser { +filter Test-GitHubUserFollowedByUser { <# .SYNOPSIS Check if a user follows another user @@ -35,7 +35,7 @@ filter Test-GitHubUserFollowedByUser { # 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(Mandatory)] - [object] $Context + [GitHubContext] $Context ) begin { @@ -46,21 +46,12 @@ filter Test-GitHubUserFollowedByUser { process { $inputObject = @{ - Context = $Context + Method = 'Get' APIEndpoint = "/users/$Username/following/$Follows" - Method = 'GET' + Context = $Context } - try { - $null = (Invoke-GitHubAPI @inputObject) - return $true - } catch { - if ($_.Exception.Response.StatusCode.Value__ -eq 404) { - return $false - } else { - throw $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 index 61dc38abe..c13a4241c 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 @@ -23,6 +23,7 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # The number of results per page (max 100). @@ -32,8 +33,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -43,23 +44,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/gpg_keys" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/gpg_keys" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 index 93655405f..ad4d735c4 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 @@ -27,8 +27,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/gpg_keys' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/gpg_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 index a878d3461..cd66be651 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 @@ -29,8 +29,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -40,18 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/gpg_keys/$ID" - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/gpg_keys/$ID" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 5da582bfc..08c162cf6 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -33,8 +33,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -44,24 +44,20 @@ } process { - try { - $body = @{ - since = $Since - per_page = $PerPage - } + $body = @{ + since = $Since + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/users' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/users' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1 index 4e9bc820f..93cc1a7f4 100644 --- a/src/functions/private/Users/Get-GitHubMyUser.ps1 +++ b/src/functions/private/Users/Get-GitHubMyUser.ps1 @@ -22,8 +22,8 @@ param( # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -33,18 +33,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/user' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1 index 182689dde..3a521812e 100644 --- a/src/functions/private/Users/Get-GitHubUserByName.ps1 +++ b/src/functions/private/Users/Get-GitHubUserByName.ps1 @@ -40,8 +40,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -51,18 +51,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 index 2fbeea5ad..4bc77143e 100644 --- a/src/functions/private/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/private/Users/Get-GitHubUserCard.ps1 @@ -41,8 +41,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -52,24 +52,20 @@ } process { - try { - $body = @{ - subject_type = $SubjectType - subject_id = $SubjectID - } + $body = @{ + subject_type = $SubjectType + subject_id = $SubjectID + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/hovercard" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/hovercard" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 index 0663da987..0dd50d01e 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 @@ -23,6 +23,7 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # The number of results per page (max 100). @@ -32,8 +33,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -43,23 +44,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/keys" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/keys" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 index c1e2ba98d..5d3d92fcc 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 @@ -27,8 +27,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/keys' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 index 5044d6a28..fe526f254 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 @@ -29,8 +29,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -40,18 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/keys/$ID" - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/keys/$ID" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 243aff987..a82601dd5 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 @@ -27,8 +27,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/ssh_signing_keys' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/ssh_signing_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 5354871b0..3a3337488 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 @@ -30,8 +30,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -41,18 +41,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/ssh_signing_keys/$ID" - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/user/ssh_signing_keys/$ID" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 b9229c5ec..5e2d1af49 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 @@ -23,6 +23,7 @@ Mandatory, ValueFromPipelineByPropertyName )] + [Alias('login')] [string] $Username, # The number of results per page (max 100). @@ -32,8 +33,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -43,23 +44,19 @@ } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/ssh_signing_keys" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/ssh_signing_keys" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 index 3e5095cda..9b5effa17 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 @@ -25,8 +25,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -36,23 +36,19 @@ } 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 $_ + $body = @{ + per_page = $PerPage + } + + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/user/social_accounts' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 index caf55da7c..2182c1eae 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 @@ -28,8 +28,8 @@ # 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 + [Parameter(Mandatory)] + [GitHubContext] $Context ) begin { @@ -39,18 +39,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/users/$Username/social_accounts" - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/users/$Username/social_accounts" + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 index 275d12647..0bd102559 100644 --- a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 +++ b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 @@ -1,4 +1,4 @@ -filter Join-Object { +filter Join-Object { <# .SYNOPSIS Merges two or more objects into a single object diff --git a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 similarity index 74% rename from src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 rename to src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 index 9635676f7..55b252dce 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 @@ -12,22 +12,22 @@ `event`, `head_sha`, `status`. .EXAMPLE - Get-GitHubWorkflowRun -Owner 'owner' -Repo 'repo' + Get-GitHubWorkflowRun -Owner 'owner' -Repository 'repo' Lists all workflow runs for a repository. .EXAMPLE - Get-GitHubWorkflowRun -Owner 'owner' -Repo 'repo' -Actor 'octocat' -Branch 'main' -Event 'push' -Status 'success' + Get-GitHubWorkflowRun -Owner 'owner' -Repository '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' + Get-GitHubWorkflowRun -Owner 'octocat' -Repository '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' + Get-GitHubWorkflowRun -Owner 'octocat' -Repository '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`. @@ -36,18 +36,26 @@ [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 = '__AllParameterSets')] + [CmdletBinding()] [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)] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository. The name is not case sensitive. - [Parameter(Mandatory)] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The ID of the workflow. You can also pass the workflow filename as a string. [Parameter( @@ -119,50 +127,37 @@ 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 { - $params = @{ - Owner = $Owner - Repo = $Repo - Actor = $Actor - Branch = $Branch - Event = $Event - Status = $Status - Created = $Created - ExcludePullRequests = $ExcludePullRequests - CheckSuiteID = $CheckSuiteID - HeadSHA = $HeadSHA - PerPage = $PerPage - } + $params = @{ + Owner = $Owner + Repository = $Repository + Actor = $Actor + Branch = $Branch + Event = $Event + Status = $Status + Created = $Created + ExcludePullRequests = $ExcludePullRequests + CheckSuiteID = $CheckSuiteID + HeadSHA = $HeadSHA + PerPage = $PerPage + } - switch ($PSCmdlet.ParameterSetName) { - 'ByID' { - $params['ID'] = $ID - Get-GitHubWorkflowRunByWorkflow @params - } + switch ($PSCmdlet.ParameterSetName) { + 'ByID' { + $params['ID'] = $ID + Get-GitHubWorkflowRunByWorkflow @params + } - 'ByName' { - $params['ID'] = (Get-GitHubWorkflow -Owner $Owner -Repo $Repo -Name $Name).id - Get-GitHubWorkflowRunByWorkflow @params - } + 'ByName' { + $params['ID'] = (Get-GitHubWorkflow -Owner $Owner -Repository $Repository -Name $Name).id + Get-GitHubWorkflowRunByWorkflow @params + } - '__AllParameterSets' { - Get-GitHubWorkflowRunByRepo @params - } + default { + Get-GitHubWorkflowRunByRepo @params } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 similarity index 64% rename from src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 rename to src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 index 6aaf7c2b4..74bf22dbb 100644 --- a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 @@ -9,7 +9,7 @@ this endpoint. .EXAMPLE - Remove-GitHubWorkflowRun -Owner 'octocat' -Repo 'Hello-World' -ID 123456789 + Remove-GitHubWorkflowRun -Owner 'octocat' -Repository 'Hello-World' -ID 123456789 Deletes the workflow run with the ID 123456789 from the 'Hello-World' repository owned by 'octocat' @@ -19,20 +19,28 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The unique identifier of the workflow run. [Parameter( Mandatory, ValueFromPipelineByPropertyName )] - [Alias('ID', 'run_id')] - [string] $RunID, + [Alias('run_id', 'RunID')] + [string] $ID, # 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. @@ -45,32 +53,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "repos/$Owner/$Repo/actions/runs/$RunID" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "repos/$Owner/$Repository/actions/runs/$ID" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("workflow run with ID [$RunID] in [$Owner/$Repo]", 'Delete')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Delete workflow run')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 similarity index 61% rename from src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 rename to src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 index da3647fdb..887a45891 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 @@ -1,4 +1,4 @@ -filter Start-GitHubWorkflowReRun { +filter Restart-GitHubWorkflowRun { <# .SYNOPSIS Re-run a workflow @@ -7,7 +7,7 @@ Re-runs your workflow run using its `run_id`. You can also specify a branch or tag name to re-run a workflow run from a branch .EXAMPLE - Start-GitHubWorkflowReRun -Owner 'octocat' -Repo 'Hello-World' -ID 123456789 + Start-GitHubWorkflowReRun -Owner 'octocat' -Repository 'Hello-World' -ID 123456789 .NOTES [Re-run a workflow](https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-workflow) @@ -15,12 +15,20 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The unique identifier of the workflow run. [Alias('workflow_id')] @@ -41,32 +49,19 @@ 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 { - $inputObject = @{ - Context = $Context - Method = 'POST' - APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/rerun" - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/rerun" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Re-run')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repository]", 'Re-run')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 similarity index 60% rename from src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 rename to src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 index cb924bdb5..454affeba 100644 --- a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 @@ -7,7 +7,7 @@ Cancels a workflow run using its `run_id`. You can use this endpoint to cancel a workflow run that is in progress or waiting .EXAMPLE - Stop-GitHubWorkflowRun -Owner 'octocat' -Repo 'Hello-World' -ID 123456789 + Stop-GitHubWorkflowRun -Owner 'octocat' -Repository 'Hello-World' -ID 123456789 Cancels the workflow run with the ID 123456789 from the 'Hello-World' repository owned by 'octocat' @@ -17,17 +17,25 @@ [CmdletBinding(SupportsShouldProcess)] [alias('Cancel-GitHubWorkflowRun')] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, - [Alias('workflow_id')] [Parameter( Mandatory, ValueFromPipelineByPropertyName )] + [Alias('workflow_id', 'WorkflowID')] [string] $ID, # The context to run the command in. Used to get the details for the API call. @@ -41,32 +49,19 @@ 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 { - $inputObject = @{ - Context = $Context - Method = 'POST' - APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/cancel" - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/cancel" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("workflow run with ID [$ID] in [$Owner/$Repo]", 'Cancel/Stop')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Cancel/Stop workflow run')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 similarity index 65% rename from src/functions/public/Actions/Disable-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 index 45e40bf45..420a807f4 100644 --- a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 @@ -3,15 +3,23 @@ .NOTES [Disable a workflow](https://docs.github.com/en/rest/actions/workflows#disable-a-workflow) #> - [CmdletBinding()] + [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The ID of the workflow. You can also pass the workflow filename as a string. [Parameter( @@ -31,28 +39,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/disable" - Method = 'PUT' - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/disable" + Context = $Context + } - $null = Invoke-GitHubAPI @inputObject - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Disable workflow')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 similarity index 59% rename from src/functions/public/Actions/Enable-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 index 4170d0f2b..3ba7036ed 100644 --- a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 @@ -3,13 +3,21 @@ .NOTES [Enable a workflow](https://docs.github.com/en/rest/actions/workflows#enable-a-workflow) #> - [CmdletBinding()] + [CmdletBinding(SupportsShouldProcess)] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, [Parameter( Mandatory, @@ -28,28 +36,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/enable" - Method = 'PUT' - } - - $null = Invoke-GitHubAPI @inputObject - } catch { - throw $_ + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/enable" + Context = $Context + } + + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Enable workflow')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 similarity index 60% rename from src/functions/public/Actions/Get-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 index 49f98113a..883933483 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 @@ -9,25 +9,33 @@ GitHub Apps must have the actions:read permission to use this endpoint. .EXAMPLE - Get-GitHubWorkflow -Owner 'octocat' -Repo 'hello-world' + Get-GitHubWorkflow -Owner 'octocat' -Repository 'hello-world' Gets all workflows in the 'octocat/hello-world' repository. .EXAMPLE - Get-GitHubWorkflow -Owner 'octocat' -Repo 'hello-world' -Name 'hello-world.yml' + Get-GitHubWorkflow -Owner 'octocat' -Repository 'hello-world' -Name 'hello-world.yml' Gets the 'hello-world.yml' workflow in the 'octocat/hello-world' repository. .NOTES [List repository workflows](https://docs.github.com/rest/actions/workflows?apiVersion=2022-11-28#list-repository-workflows) #> - [CmdletBinding(DefaultParameterSetName = 'ByName')] + [CmdletBinding()] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -45,35 +53,22 @@ 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.workflows - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 similarity index 58% rename from src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 rename to src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 index 22179722e..3b27d7839 100644 --- a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 @@ -12,15 +12,21 @@ .NOTES [Get workflow usage](https://docs.github.com/en/rest/actions/workflows#get-workflow-usage) #> - [CmdletBinding( - DefaultParameterSetName = 'ByName' - )] + [CmdletBinding()] param( - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, [Parameter( Mandatory, @@ -39,31 +45,17 @@ 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 { - - $inputObject = @{ - Context = $Context - Method = 'GET' - APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/timing" - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/timing" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.billable - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 similarity index 68% rename from src/functions/public/Actions/Start-GitHubWorkflow.ps1 rename to src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 index 5d1bd4020..81f1dce53 100644 --- a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 @@ -20,15 +20,23 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] + [string] $Repository, # The ID of the workflow. - [Alias('workflow_id')] + [Alias('workflow_id', 'WorkflowID')] [Parameter( Mandatory, ValueFromPipelineByPropertyName @@ -57,38 +65,25 @@ 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 = @{ - 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 = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/dispatches" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("workflow with ID [$ID] in [$Owner/$Repo]", 'Start')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Start workflow')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 similarity index 67% rename from src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 index 499989e9a..5417dad11 100644 --- a/src/functions/public/Apps/GitHub Apps/Add-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 @@ -57,39 +57,27 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=write + #enterprise_organization_installations=write } process { - try { - $body = @{ - repositories = $Repositories - } + $body = @{ + repositories = $Repositories + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/add" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/add" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Enterprise/$Organization", 'Add repo access to installation')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - Write-Debug "Error: $_" } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 similarity index 65% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 rename to src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 index 01e4bb70b..43710de83 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppAccessibleRepository.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 @@ -50,39 +50,24 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + # Enterprise organization installations (read) } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - Write-Debug "Error: $_" + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 similarity index 65% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 rename to src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 index e493a4f37..2d0a881fd 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 @@ -8,7 +8,7 @@ If the app is installed on an enterprise, the installations for the enterprise are returned. If the app is installed on an organization, the installations for the organization are returned. #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -54,31 +54,27 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'Enterprise' { - $params = @{ - Enterprise = $Enterprise - Organization = $Organization - PerPage = $PerPage - Context = $Context - } - Get-GitHubEnterpriseOrganizationAppInstallation @params + switch ($PSCmdlet.ParameterSetName) { + 'Enterprise' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + PerPage = $PerPage + Context = $Context } - 'Organization' { - $params = @{ - Organization = $Organization - PerPage = $PerPage - Context = $Context - } - Get-GitHubOrganizationAppInstallation @params - } - '__AllParameterSets' { - Get-GitHubAppInstallationForAuthenticatedApp -Context $Context + Get-GitHubEnterpriseOrganizationAppInstallation @params + } + 'Organization' { + $params = @{ + Organization = $Organization + PerPage = $PerPage + Context = $Context } + Get-GitHubOrganizationAppInstallation @params + } + default { + Get-GitHubAppInstallationForAuthenticatedApp -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 similarity index 67% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 index 52f12fded..277b0fb3f 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 @@ -19,7 +19,7 @@ Get the repositories accessible to the GitHub App installation with the ID '12345678' on the organization 'PSModule' in the enterprise 'msx'. #> - [CmdletBinding(SupportsShouldProcess)] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -59,39 +59,25 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=read + #enterprise_organization_installations=read } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - Write-Debug "Error: $_" + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 similarity index 67% rename from src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 index eb5eaea0c..56841d851 100644 --- a/src/functions/public/Apps/GitHub Apps/Remove-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 @@ -57,39 +57,27 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=write + #enterprise_organization_installations=write } process { - try { - $body = @{ - repositories = $Repositories - } + $body = @{ + repositories = $Repositories + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/remove" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/remove" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Enterprise/$Organization - $Repositories", 'Remove repository access')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - Write-Debug "Error: $_" } } diff --git a/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 similarity index 68% rename from src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 rename to src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 index 8aaf15497..583083d22 100644 --- a/src/functions/public/Apps/GitHub Apps/Update-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 @@ -28,11 +28,16 @@ [CmdletBinding(SupportsShouldProcess)] param( # The enterprise slug or ID. - [Parameter(ValueFromPipelineByPropertyName)] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName + )] [string] $Enterprise, # The organization name. The name is not case sensitive. - [Parameter(ValueFromPipelineByPropertyName)] + [Parameter( + Mandatory, + ValueFromPipelineByPropertyName)] [string] $Organization, # The unique identifier of the installation. @@ -65,41 +70,29 @@ $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 : [$($Context.Enterprise)]" - - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization : [$($Context.Organization)]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installation_repositories=write + #enterprise_organization_installations=write } process { - try { - $body = @{ - repository_selection = $RepositorySelection - repositories = $Repositories - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + repository_selection = $RepositorySelection + repositories = $Repositories + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('Target', 'Operation')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Enterprise/$Organization", 'Update repository access')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - Write-Debug "Error: $_" } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 similarity index 79% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 rename to src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 index 0e91cdf47..16a1d51c4 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 @@ -21,7 +21,7 @@ [Get the authenticated app | GitHub Docs](https://docs.github.com/rest/apps/apps#get-the-authenticated-app) #> [OutputType([pscustomobject])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The AppSlug is just the URL-friendly name of a GitHub App. # You can find this on the settings page for your GitHub App (e.g., ). @@ -30,8 +30,8 @@ Mandatory, ParameterSetName = 'BySlug' )] - [Alias('Name')] - [string] $AppSlug, + [Alias('AppSlug')] + [string] $Name, # 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. @@ -43,23 +43,13 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context - - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner - } - 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 + Get-GitHubAppByName -AppSlug $Name -Context $Context } default { Get-GitHubAuthenticatedApp -Context $Context diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 similarity index 57% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 rename to src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 index 69d1d6e32..8cc6baf15 100644 --- a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 @@ -6,8 +6,9 @@ .DESCRIPTION List of organizations owned by the enterprise on which the authenticated GitHub App installation may install other GitHub Apps. - The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/enterprise_organization_installations - (read) permission. + .NOTES + Permissions required: + - enterprise_organization_installations: read .EXAMPLE Get-GitHubAppInstallableOrganization -Enterprise 'msx' @@ -15,7 +16,7 @@ [CmdletBinding()] param( # The enterprise slug or ID. - [Parameter()] + [Parameter(Mandatory)] [string] $Enterprise, # The number of results per page (max 100). @@ -33,31 +34,24 @@ $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]" + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + # enterprise_organization_installations=read } process { - try { - $body = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubAppJSONWebToken.ps1 similarity index 100% rename from src/functions/public/Apps/GitHub Apps/Get-GitHubAppJSONWebToken.ps1 rename to src/functions/public/Apps/GitHub App/Get-GitHubAppJSONWebToken.ps1 diff --git a/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 similarity index 69% rename from src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 rename to src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 index 93f5e5f53..6ff054ae7 100644 --- a/src/functions/public/Apps/GitHub Apps/Install-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 @@ -23,7 +23,7 @@ - the repository selection 'all' on the organization 'org' in the enterprise 'msx'. #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -66,34 +66,23 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context - Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + Assert-GitHubContext -Context $Context -AuthType IAT, UAT + #enterprise_organization_installations=write } process { - if ([string]::IsNullOrEmpty($Enterprise)) { - $Enterprise = $Context.Enterprise - } - Write-Debug "Enterprise: [$Enterprise]" - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization: [$Organization]" - try { - switch ($PSCmdlet.ParameterSetName) { - 'EnterpriseOrganization' { - $params = @{ - Enterprise = $Enterprise - Organization = $Organization - ClientID = $ClientID - RepositorySelection = $RepositorySelection - Repositories = $Repositories - Context = $Context - } - Install-GitHubAppOnEnterpriseOrganization @params + switch ($PSCmdlet.ParameterSetName) { + 'EnterpriseOrganization' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + ClientID = $ClientID + RepositorySelection = $RepositorySelection + Repositories = $Repositories + Context = $Context } + Install-GitHubAppOnEnterpriseOrganization @params } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 similarity index 85% rename from src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 rename to src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 index f7e545a93..4ceac55bc 100644 --- a/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1 +++ b/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 @@ -73,31 +73,23 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/app/installations/$ID/access_tokens" - Method = 'Post' - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/app/installations/$ID/access_tokens" + Context = $Context + } - 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 - } + 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/GitHub Apps/Uninstall-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 similarity index 64% rename from src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 rename to src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 index fd487b598..48bc964f1 100644 --- a/src/functions/public/Apps/GitHub Apps/Uninstall-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 @@ -11,7 +11,7 @@ Uninstall the GitHub App with the installation ID '123456' from the organization 'org' in the enterprise 'msx'. #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The enterprise slug or ID. [Parameter( @@ -47,32 +47,19 @@ $stackPath = Get-PSCallStackPath Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context - Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT } process { - if ([string]::IsNullOrEmpty($Enterprise)) { - $Enterprise = $Context.Enterprise - } - Write-Debug "Enterprise: [$Enterprise]" - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization - } - Write-Debug "Organization: [$Organization]" - try { - switch ($PSCmdlet.ParameterSetName) { - 'EnterpriseOrganization' { - $params = @{ - Enterprise = $Enterprise - Organization = $Organization - ID = $ID - Context = $Context - } - Uninstall-GitHubAppOnEnterpriseOrganization @params + switch ($PSCmdlet.ParameterSetName) { + 'EnterpriseOrganization' { + $params = @{ + Enterprise = $Enterprise + Organization = $Organization + ID = $ID + Context = $Context } + Uninstall-GitHubAppOnEnterpriseOrganization @params } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 index 36a02d756..32e48b5ab 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 @@ -34,18 +34,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/hook/config' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/app/hook/config' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 index 0208f92c3..01c078b6d 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 @@ -31,7 +31,7 @@ Mandatory, ParameterSetName = 'ByID' )] - [Alias('DeliveryID', 'delivery_id')] + [Alias('delivery_id', 'DeliveryID')] [string] $ID, # Only the ones to redeliver. @@ -64,23 +64,19 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'ByID' { - Write-Debug "ByID: [$ID]" - Get-GitHubAppWebhookDeliveryByID -ID $ID -Context $Context - } - 'Redelivery' { - Write-Debug "Redelivery: [$NeedingRedelivery]" - Get-GitHubAppWebhookDeliveryToRedeliver -Context $Context -PerPage $PerPage -TimeSpan $TimeSpan - } - 'ByList' { - Write-Debug 'ByList' - Get-GitHubAppWebhookDeliveryByList -Context $Context -PerPage $PerPage - } + switch ($PSCmdlet.ParameterSetName) { + 'ByID' { + Write-Debug "ByID: [$ID]" + Get-GitHubAppWebhookDeliveryByID -ID $ID -Context $Context + } + 'Redelivery' { + Write-Debug "Redelivery: [$NeedingRedelivery]" + Get-GitHubAppWebhookDeliveryToRedeliver -Context $Context -PerPage $PerPage -TimeSpan $TimeSpan + } + default { + Write-Debug 'ByList' + Get-GitHubAppWebhookDeliveryByList -Context $Context -PerPage $PerPage } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 index 7808e2af3..88ddd4988 100644 --- a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 @@ -26,8 +26,12 @@ )] param( # The ID of the delivery. - [Parameter(Mandatory)] - [Alias('DeliveryID', 'delivery_id')] + [Parameter( + Mandatory, + ValueFromPipeline, + ValueFromPipelineByPropertyName + )] + [Alias('delivery_id', 'DeliveryID')] [string] $ID, # The context to run the command in. Used to get the details for the API call. @@ -44,20 +48,16 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/app/hook/deliveries/$ID/attempts" - Method = 'post' - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/app/hook/deliveries/$ID/attempts" + Context = $Context + } - if ($PSCmdlet.ShouldProcess('webhook delivery', 'Redeliver')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("[$ID]", 'Redeliver event')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 index 734027fd6..574dfe353 100644 --- a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 @@ -37,6 +37,7 @@ # Determines whether the SSL certificate of the host for URL will be verified when delivering payloads. # We strongly recommend not setting this as you are subject to man-in-the-middle and other attacks. + [Parameter()] [switch] $InsecureSSL, # The context to run the command in. Used to get the details for the API call. @@ -53,29 +54,25 @@ } process { - try { - $body = @{ - url = $URL - content_type = $ContentType - secret = $Secret - insecure_ssl = $PSBoundParameters.ContainsKey($InsecureSSL) ? ($InsecureSSL ? 1 : 0) : $null - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + url = $URL + content_type = $ContentType + secret = $Secret + insecure_ssl = $PSBoundParameters.ContainsKey($InsecureSSL) ? ($InsecureSSL ? 1 : 0) : $null + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/hook/config' - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = '/app/hook/config' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('webhook configuration', 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess('webhook configuration', 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index 92ca09f6f..99ce6bd02 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -43,13 +43,7 @@ .NOTES [Authenticating to the REST API](https://docs.github.com/rest/overview/other-authentication-methods#authenticating-for-saml-sso) #> - [Alias('Connect-GHAccount')] [Alias('Connect-GitHub')] - [Alias('Connect-GH')] - [Alias('Login-GitHubAccount')] - [Alias('Login-GHAccount')] - [Alias('Login-GitHub')] - [Alias('Login-GH')] [OutputType([void])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] @@ -116,13 +110,11 @@ # Set the default owner to use in commands. [Parameter()] [Alias('Organization')] - [Alias('Org')] [string] $Owner, # Set the default repository to use in commands. [Parameter()] - [Alias('Repository')] - [string] $Repo, + [string] $Repository, # The host to connect to. Can use $env:GITHUB_SERVER_URL to set the host, as the protocol is removed automatically. # Example: github.com, github.enterprise.com, msx.ghe.com @@ -134,8 +126,6 @@ # Suppresses the output of the function. [Parameter()] [Alias('Quiet')] - [Alias('q')] - [Alias('s')] [switch] $Silent, # Make the connected context NOT the default context. @@ -191,7 +181,7 @@ AuthType = [string]$authType Enterprise = [string]$Enterprise Owner = [string]$Owner - Repo = [string]$Repo + Repository = [string]$Repository } Write-Verbose ($context | Format-Table | Out-String) diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 0596085f1..242ecc6dc 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -38,7 +38,7 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'The tokens are recieved as clear text. Mitigating exposure by removing variables and performing garbage collection.')] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The user account to connect to. [Parameter(ParameterSetName = 'Filtered')] @@ -62,8 +62,6 @@ # Suppresses the output of the function. [Parameter()] [Alias('Quiet')] - [Alias('q')] - [Alias('s')] [switch] $Silent, # Set as the default context. diff --git a/src/functions/public/Auth/Context/Get-GitHubContext.ps1 b/src/functions/public/Auth/Context/Get-GitHubContext.ps1 index fb4615d1a..ea5817fbf 100644 --- a/src/functions/public/Auth/Context/Get-GitHubContext.ps1 +++ b/src/functions/public/Auth/Context/Get-GitHubContext.ps1 @@ -18,7 +18,7 @@ function Get-GitHubContext { Justification = 'Encapsulated in a function. Never leaves as a plain text.' )] [OutputType([GitHubContext])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The name of the context. [Parameter( @@ -54,7 +54,7 @@ function Get-GitHubContext { $ID = "$($script:GitHub.Config.ID)/*" Write-Verbose "Getting available contexts for [$ID]" } - '__AllParameterSets' { + default { Write-Verbose 'Getting default context.' $ID = "$($script:GitHub.Config.ID)/$($script:GitHub.Config.DefaultContext)" if ([string]::IsNullOrEmpty($ID)) { diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 index 6617cd0dd..512a00564 100644 --- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 +++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 @@ -7,7 +7,7 @@ Lists all branches from a repository .EXAMPLE - Get-GitHubRepoBranch -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepoBranch -Owner 'octocat' -Repository 'Hello-World' Gets all the branches from the 'Hello-World' repository owned by 'octocat' @@ -17,12 +17,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -35,30 +37,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/branches" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/branches" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 index e8e61bbee..04006591b 100644 --- a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 +++ b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 @@ -20,13 +20,10 @@ .NOTES [Get emojis](https://docs.github.com/rest/reference/emojis#get-emojis) #> - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The path to the directory where the emojis will be downloaded. - [Parameter( - Mandatory, - ParameterSetName = 'Download' - )] + [Parameter()] [string] $Destination, # The context to run the command in. Used to get the details for the API call. @@ -43,39 +40,34 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/emojis' - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/emojis' + Context = $Context + } - $response = Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response + $response = Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response - if ($PSCmdlet.ParameterSetName -eq 'Download') { - $failedEmojis = @() - if (-not (Test-Path -Path $Destination)) { - $null = New-Item -Path $Destination -ItemType Directory -Force - } - $failedEmojis = $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel { - $emoji = $_ - Write-Verbose "Downloading [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" - try { - Invoke-WebRequest -Uri $emoji.Value -OutFile "$using:Destination/$($emoji.Name).png" -RetryIntervalSec 1 -MaximumRetryCount 5 - } catch { - $emoji - Write-Warning "Could not download [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" - } - } - if ($failedEmojis.Count -gt 0) { - Write-Warning 'Failed to download the following emojis:' - $failedEmojis | Out-String -Stream | ForEach-Object { Write-Warning $_ } - } - } else { - $response + if (-not $Destination) { + $response + } + + $failedEmojis = @() + if (-not (Test-Path -Path $Destination)) { + $null = New-Item -Path $Destination -ItemType Directory -Force + } + $failedEmojis = $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel { + $emoji = $_ + Write-Verbose "Downloading [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" + try { + Invoke-WebRequest -Uri $emoji.Value -OutFile "$using:Destination/$($emoji.Name).png" -RetryIntervalSec 1 -MaximumRetryCount 5 + } catch { + Write-Warning "Could not download [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" } - } catch { - throw $_ + } + if ($failedEmojis.Count -gt 0) { + Write-Warning 'Failed to download the following emojis:' + $failedEmojis | Out-String -Stream | ForEach-Object { Write-Warning $_ } } } diff --git a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 index a34a49d2d..e3c13aee4 100644 --- a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 +++ b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 @@ -36,22 +36,20 @@ } process { - 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 $_ + $body = @{ + 'query' = $Query + 'variables' = $Variables + } + + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/graphql' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/License/Get-GitHubLicense.ps1 b/src/functions/public/License/Get-GitHubLicense.ps1 index 8ec620b6a..ebcb95f1c 100644 --- a/src/functions/public/License/Get-GitHubLicense.ps1 +++ b/src/functions/public/License/Get-GitHubLicense.ps1 @@ -19,7 +19,7 @@ Get the mit license template .EXAMPLE - Get-GitHubLicense -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubLicense -Owner 'octocat' -Repository 'Hello-World' Get the license for the Hello-World repository from the octocat account. @@ -39,7 +39,7 @@ # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(ParameterSetName = 'Repository')] - [string] $Repo, + [string] $Repository, # The license keyword, license name, or license SPDX ID. For example, mit or mpl-2.0. [Parameter(ParameterSetName = 'Name')] @@ -56,32 +56,19 @@ 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 { - switch ($PSCmdlet.ParameterSetName) { - 'List' { - Get-GitHubLicenseList -Context $Context - } - 'Name' { - Get-GitHubLicenseByName -Name $Name -Context $Context - } - 'Repository' { - Get-GitHubRepositoryLicense -Owner $Owner -Repo $Repo -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + 'List' { + Get-GitHubLicenseList -Context $Context + } + 'Name' { + Get-GitHubLicenseByName -Name $Name -Context $Context + } + 'Repository' { + Get-GitHubRepositoryLicense -Owner $Owner -Repository $Repository -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index 5c8633833..5fbb8d5cd 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -31,8 +31,8 @@ [ValidateSet('markdown', 'gfm')] [string] $Mode = 'markdown', - # 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. + # The repository context to use when creating references in `gfm` mode. For example, setting `context` to `octo-org/octo-Repository` will + # change the text `#42` into an HTML link to issue 42 in the `octo-org/octo-Repository` repository. [Parameter()] [string] $RepoContext, @@ -50,25 +50,21 @@ } process { - try { - $body = @{ - context = $RepoContext - mode = $Mode - text = $Text - } + $body = @{ + context = $RepoContext + mode = $Mode + text = $Text + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/markdown' - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/markdown' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 index cbdf5c1a6..2b95365c8 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 @@ -37,23 +37,20 @@ } process { - try { - $body = @{ - text = $Text - } - $inputObject = @{ - Context = $Context - APIEndpoint = '/markdown/raw' - ContentType = 'text/plain' - Method = 'POST' - Body = $body - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $body = @{ + text = $Text + } + + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/markdown/raw' + ContentType = 'text/plain' + Body = $body + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 index 6b97d9e2f..fed1c2fce 100644 --- a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 +++ b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 @@ -31,18 +31,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - ApiEndpoint = '/versions' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + ApiEndpoint = '/versions' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubMeta.ps1 b/src/functions/public/Meta/Get-GitHubMeta.ps1 index 1aa4ece02..77861c59b 100644 --- a/src/functions/public/Meta/Get-GitHubMeta.ps1 +++ b/src/functions/public/Meta/Get-GitHubMeta.ps1 @@ -39,18 +39,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - ApiEndpoint = '/meta' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + ApiEndpoint = '/meta' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubOctocat.ps1 b/src/functions/public/Meta/Get-GitHubOctocat.ps1 index 9ea7534f3..975c95ac8 100644 --- a/src/functions/public/Meta/Get-GitHubOctocat.ps1 +++ b/src/functions/public/Meta/Get-GitHubOctocat.ps1 @@ -24,9 +24,7 @@ param( # The words to show in Octocat's speech bubble [Parameter()] - [Alias('Say')] - [Alias('Saying')] - [string] $S, + [string] $Saying, # 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. @@ -42,23 +40,19 @@ } process { - try { - $body = @{ - s = $S - } + $body = @{ + s = $Saying + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/octocat' - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/octocat' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubRoot.ps1 b/src/functions/public/Meta/Get-GitHubRoot.ps1 index 566100b1f..bb21e6a0a 100644 --- a/src/functions/public/Meta/Get-GitHubRoot.ps1 +++ b/src/functions/public/Meta/Get-GitHubRoot.ps1 @@ -30,18 +30,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Meta/Get-GitHubZen.ps1 b/src/functions/public/Meta/Get-GitHubZen.ps1 index 63cb00157..1acd7c953 100644 --- a/src/functions/public/Meta/Get-GitHubZen.ps1 +++ b/src/functions/public/Meta/Get-GitHubZen.ps1 @@ -30,18 +30,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/zen' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/zen' + Context = $Context + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index 962f71944..2a7c20dfd 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -42,9 +42,6 @@ ParameterSetName = 'NamedOrg', ValueFromPipelineByPropertyName )] - [Alias('login')] - [Alias('org')] - [Alias('owner')] [string] $Organization, # The handle for the GitHub user account. diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 index 05f0f1c51..e82ea1a19 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 @@ -15,7 +15,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # Filter members returned in the list. @@ -46,33 +45,24 @@ 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]" } process { - try { - $body = @{ - filter = $Filter - role = $Role - per_page = $PerPage - } + $body = @{ + filter = $Filter + role = $Role + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - Body = $body - Method = 'Get' - APIEndpoint = "/orgs/$Organization/members" - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/members" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 index 6b44e355a..cae4a29cf 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 @@ -26,7 +26,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # Filter invitations by their member role. @@ -55,33 +54,24 @@ 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]" } process { - try { - $body = @{ - role = $Role - invitation_source = $InvitationSource - per_page = $PerPage - } + $body = @{ + role = $Role + invitation_source = $InvitationSource + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - Body = $body - Method = 'Get' - APIEndpoint = "/orgs/$Organization/invitations" - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/orgs/$Organization/invitations" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 index 65b05a70e..4606230aa 100644 --- a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 @@ -29,7 +29,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # GitHub user ID for the person you are inviting. @@ -74,37 +73,28 @@ 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]" } process { - try { - $body = @{ - invitee_id = $PSBoundParameters.ContainsKey('InviteeID') ? $InviteeID : $null - email = $Email - role = $Role - team_ids = $TeamIDs - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + invitee_id = $PSBoundParameters.ContainsKey('InviteeID') ? $InviteeID : $null + email = $Email + role = $Role + team_ids = $TeamIDs + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - Body = $body - Method = 'post' - APIEndpoint = "/orgs/$Organization/invitations" - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Organization/invitations" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$InviteeID$Email to organization $Organization", 'Invite')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$InviteeID$Email to organization $Organization", 'Invite')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 index 183ebdf38..73fd9158f 100644 --- a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 @@ -22,7 +22,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('Org')] [string] $Organization, # The unique identifier of the invitation. @@ -44,24 +43,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/invitations/$ID" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/orgs/$Organization/invitations/$ID" + Context = $Context + } - try { - if ($PSCmdlet.ShouldProcess('GitHub Organization invitation', 'Remove')) { - $null = (Invoke-GitHubAPI @inputObject) - } - return $true - } catch { - Write-Error $_.Exception.Response - throw $_ - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess('GitHub Organization invitation', 'Remove')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 index 1bab1df3c..b98b5bf0c 100644 --- a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 @@ -26,9 +26,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] - [Alias('login')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. @@ -42,28 +39,19 @@ 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]" } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/orgs/$Organization" + Context = $Context + } - 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 $_ } } diff --git a/src/functions/public/Organization/Update-GitHubOrganization.ps1 b/src/functions/public/Organization/Update-GitHubOrganization.ps1 index b35e250f1..30f972cf0 100644 --- a/src/functions/public/Organization/Update-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganization.ps1 @@ -14,9 +14,9 @@ .EXAMPLE $param = @{ - Organization = 'GitHub' - MembersCanCreatePublicRepositories = $true - MembersCanCreatePrivateRepositories = $true + Organization = 'GitHub' + MembersCanCreatePublicRepositories = $true + MembersCanCreatePrivateRepositories = $true MembersCanCreateInternalRepositories = $true } Update-GitHubOrganization @param @@ -40,9 +40,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] - [Alias('login')] [string] $Organization, # Billing email address. This address is not publicized. @@ -176,56 +173,47 @@ 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]" } process { - try { - $body = @{ - name = $Name - billing_email = $BillingEmail - blog = $Blog - company = $Company - description = $Description - email = $Email - location = $Location - twitter_username = $TwitterUsername - has_organization_projects = $PSBoundParameters.ContainsKey('HasOrganizationProjects') ? $HasOrganizationProjects : $null - has_repository_projects = $PSBoundParameters.ContainsKey('HasRepositoryProjects') ? $HasRepositoryProjects : $null - default_repository_permission = $PSBoundParameters.ContainsKey('DefaultRepositoryPermission') ? $DefaultRepositoryPermission : $null - members_can_create_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateRepositories') ? $MembersCanCreateRepositories : $null - members_can_create_internal_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateInternalRepositories') ? $MembersCanCreateInternalRepositories : $null - members_can_create_private_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePrivateRepositories') ? $MembersCanCreatePrivateRepositories : $null - members_can_create_public_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePublicRepositories') ? $MembersCanCreatePublicRepositories : $null - members_can_create_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePages') ? $MembersCanCreatePages : $null - members_can_create_public_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePublicPages') ? $MembersCanCreatePublicPages : $null - members_can_create_private_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePrivatePages') ? $MembersCanCreatePrivatePages : $null - members_can_fork_private_repositories = $PSBoundParameters.ContainsKey('MembersCanForkPrivateRepositories') ? $MembersCanForkPrivateRepositories : $null - web_commit_signoff_required = $PSBoundParameters.ContainsKey('WebCommitSignoffRequired') ? $WebCommitSignoffRequired : $null - secret_scanning_push_protection_enabled_for_new_repositories = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionEnabledForNewRepositories') ? $SecretScanningPushProtectionEnabledForNewRepositories : $null - secret_scanning_push_protection_custom_link_enabled = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLinkEnabled') ? $SecretScanningPushProtectionCustomLinkEnabled : $null - secret_scanning_push_protection_custom_link = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLink') ? $SecretScanningPushProtectionCustomLink : $null - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + name = $Name + billing_email = $BillingEmail + blog = $Blog + company = $Company + description = $Description + email = $Email + location = $Location + twitter_username = $TwitterUsername + has_organization_projects = $PSBoundParameters.ContainsKey('HasOrganizationProjects') ? $HasOrganizationProjects : $null + has_repository_projects = $PSBoundParameters.ContainsKey('HasRepositoryProjects') ? $HasRepositoryProjects : $null + default_repository_permission = $PSBoundParameters.ContainsKey('DefaultRepositoryPermission') ? $DefaultRepositoryPermission : $null + members_can_create_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateRepositories') ? $MembersCanCreateRepositories : $null + members_can_create_internal_repositories = $PSBoundParameters.ContainsKey('MembersCanCreateInternalRepositories') ? $MembersCanCreateInternalRepositories : $null + members_can_create_private_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePrivateRepositories') ? $MembersCanCreatePrivateRepositories : $null + members_can_create_public_repositories = $PSBoundParameters.ContainsKey('MembersCanCreatePublicRepositories') ? $MembersCanCreatePublicRepositories : $null + members_can_create_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePages') ? $MembersCanCreatePages : $null + members_can_create_public_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePublicPages') ? $MembersCanCreatePublicPages : $null + members_can_create_private_pages = $PSBoundParameters.ContainsKey('MembersCanCreatePrivatePages') ? $MembersCanCreatePrivatePages : $null + members_can_fork_private_repositories = $PSBoundParameters.ContainsKey('MembersCanForkPrivateRepositories') ? $MembersCanForkPrivateRepositories : $null + web_commit_signoff_required = $PSBoundParameters.ContainsKey('WebCommitSignoffRequired') ? $WebCommitSignoffRequired : $null + secret_scanning_push_protection_enabled_for_new_repositories = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionEnabledForNewRepositories') ? $SecretScanningPushProtectionEnabledForNewRepositories : $null + secret_scanning_push_protection_custom_link_enabled = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLinkEnabled') ? $SecretScanningPushProtectionCustomLinkEnabled : $null + secret_scanning_push_protection_custom_link = $PSBoundParameters.ContainsKey('SecretScanningPushProtectionCustomLink') ? $SecretScanningPushProtectionCustomLink : $null + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/orgs/$Organization" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 index 44bd8682e..802fb86c3 100644 --- a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 @@ -27,9 +27,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] - [Alias('owner')] - [Alias('login')] [string] $Organization, # The security feature to enable or disable. @@ -79,33 +76,24 @@ 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]" } process { - try { - $body = @{ - query_suite = $QuerySuite - } + $body = @{ + query_suite = $QuerySuite + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement" - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("security feature [$SecurityProduct] on organization [$Organization]", 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("security feature [$SecurityProduct] on organization [$Organization]", 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 index 4fbb270c2..bdba61482 100644 --- a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 +++ b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 @@ -48,18 +48,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/rate_limit' - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = '/rate_limit' + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.Resources - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.Resources } } diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 index c488874d8..7e7a5efa1 100644 --- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 @@ -37,7 +37,7 @@ the old file before you can re-upload the new asset. .EXAMPLE - Add-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '7654321' -FilePath 'C:\Users\octocat\Downloads\hello-world.zip' + Add-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '7654321' -FilePath 'C:\Users\octocat\Downloads\hello-world.zip' Gets the release assets for the release with the ID '1234567' for the repository 'octocat/hello-world'. @@ -47,12 +47,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the release. [Parameter(Mandatory)] @@ -73,7 +75,7 @@ # The path to the asset file. [Parameter(Mandatory)] - [alias('fullname')] + [alias('FullName')] [string] $FilePath, # The context to run the command in. Used to get the details for the API call. @@ -87,70 +89,56 @@ 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 { - # If name is not provided, use the name of the file - if (!$Name) { - $Name = (Get-Item $FilePath).Name - } + # 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 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' } - } + # 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)" + $release = Get-GitHubRelease -Owner $Owner -Repository $Repository -ID $ID + $uploadURI = $release.upload_url -replace '{\?name,label}', "?name=$($Name)&label=$($Label)" - $inputObject = @{ - URI = $uploadURI - Method = 'POST' - ContentType = $ContentType - UploadFilePath = $FilePath - } + $inputObject = @{ + Method = 'Post' + URI = $uploadURI + ContentType = $ContentType + UploadFilePath = $FilePath + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 index 227f7da3d..627d64498 100644 --- a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 @@ -8,12 +8,12 @@ If a release ID is provided, all assets for the release are returned. .EXAMPLE - Get-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release asset with the ID '1234567' for the repository 'octocat/hello-world'. .EXAMPLE - Get-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ReleaseID '7654321' + Get-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ReleaseID '7654321' Gets the release assets for the release with the ID '7654321' for the repository 'octocat/hello-world'. @@ -23,12 +23,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the asset. [Parameter( @@ -57,28 +59,16 @@ 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 { - if ($ReleaseID) { - Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repo $Repo -ReleaseID $ReleaseID -Context $Context + switch ($PSCmdlet.ParameterSetName) { + 'ReleaseID' { + Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repository $Repository -ReleaseID $ReleaseID -Context $Context } - if ($ID) { - Get-GitHubReleaseAssetByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context + 'ID' { + Get-GitHubReleaseAssetByID -Owner $Owner -Repository $Repository -ID $ID -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 index 9caa5feed..295eab381 100644 --- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 @@ -7,7 +7,7 @@ Delete a release asset .EXAMPLE - Remove-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Remove-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Deletes the release asset with the ID '1234567' for the repository 'octocat/hello-world'. @@ -17,12 +17,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the asset. [Parameter(Mandatory)] @@ -40,33 +42,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" + Context = $Context + } - 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/$Repository]", 'Delete')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 index 52ad07ce7..7041a7721 100644 --- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 @@ -7,7 +7,7 @@ Users with push access to the repository can edit a release asset. .EXAMPLE - Set-GitHubReleaseAsset -Owner 'octocat' -Repo 'hello-world' -ID '1234567' -Name 'new_asset_name' -Label 'new_asset_label' + Set-GitHubReleaseAsset -Owner 'octocat' -Repository 'hello-world' -ID '1234567' -Name 'new_asset_name' -Label 'new_asset_label' Updates the release asset with the ID '1234567' for the repository 'octocat/hello-world' with the new name 'new_asset_name' and label 'new_asset_label'. @@ -18,12 +18,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. [Parameter()] - [string] $Repo, + [string] $Repository, # The unique identifier of the asset. [Parameter(Mandatory)] @@ -54,41 +56,27 @@ 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 = @{ - name = $Name - label = $Label - state = $State - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $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 - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repo]", 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("assets for release with ID [$ID] in [$Owner/$Repository]", 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 index 7b228b075..15d784595 100644 --- a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 @@ -9,22 +9,22 @@ Information about published releases are available to everyone. Only users with push access will receive listings for draft releases. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' Gets the releases for the repository 'hello-world' owned by 'octocat'. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -Latest + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -Latest Gets the latest releases for the repository 'hello-world' owned by 'octocat'. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -Tag 'v1.0.0' + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -Tag 'v1.0.0' Gets the release with the tag 'v1.0.0' for the repository 'hello-world' owned by 'octocat'. .EXAMPLE - Get-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Get-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Gets the release with the ID '1234567' for the repository 'hello-world' owned by 'octocat'. @@ -36,12 +36,14 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'Latest', Justification = 'Required for parameter set')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter(ParameterSetName = 'All')] @@ -82,32 +84,22 @@ 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 { switch ($PSCmdlet.ParameterSetName) { 'All' { - Get-GitHubReleaseAll -Owner $Owner -Repo $Repo -PerPage $PerPage -Context $Context + Get-GitHubReleaseAll -Owner $Owner -Repository $Repository -PerPage $PerPage -Context $Context } 'Latest' { - Get-GitHubReleaseLatest -Owner $Owner -Repo $Repo -Context $Context + Get-GitHubReleaseLatest -Owner $Owner -Repository $Repository -Context $Context } 'Tag' { - Get-GitHubReleaseByTagName -Owner $Owner -Repo $Repo -Tag $Tag -Context $Context + Get-GitHubReleaseByTagName -Owner $Owner -Repository $Repository -Tag $Tag -Context $Context } 'ID' { - Get-GitHubReleaseByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context + Get-GitHubReleaseByID -Owner $Owner -Repository $Repository -ID $ID -Context $Context } } } catch { diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 index 7b73687c1..ab2f2d755 100644 --- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 @@ -11,7 +11,7 @@ and "[Dealing with secondary rate limits](https://docs.github.com/rest/guides/best-practices-for-integrators#dealing-with-secondary-rate-limits)" for details. .EXAMPLE - New-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -TagName 'v1.0.0' -TargetCommitish 'main' -Body 'Release notes' + New-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -TagName 'v1.0.0' -TargetCommitish 'main' -Body 'Release notes' Creates a release for the repository 'octocat/hello-world' with the tag 'v1.0.0' and the target commitish 'main'. @@ -23,12 +23,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the tag. [Parameter(Mandatory)] @@ -87,47 +89,33 @@ 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 { - $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 + $body = @{ + 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 + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases" - Method = 'POST' - Body = $requestBody - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/releases" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create a release')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repository", 'Create a release')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 index 7b7c90a8c..7a0fa45f4 100644 --- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 @@ -57,12 +57,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The tag name for the release. This can be an existing tag or a new one. [Parameter(Mandatory)] @@ -101,41 +103,27 @@ 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 { - $requestBody = @{ - tag_name = $TagName - target_commitish = $TargetCommitish - previous_tag_name = $PreviousTagName - configuration_file_path = $ConfigurationFilePath - } - $requestBody | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + tag_name = $TagName + target_commitish = $TargetCommitish + previous_tag_name = $PreviousTagName + configuration_file_path = $ConfigurationFilePath + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - APIEndpoint = "/repos/$Owner/$Repo/releases/generate-notes" - Method = 'POST' - Body = $requestBody - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/releases/generate-notes" + Body = $body + } - if ($PSCmdlet.ShouldProcess("$Owner/$Repo", 'Create release notes')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("$Owner/$Repository", 'Create release notes')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 index 6539d0dc3..80542040e 100644 --- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 @@ -7,7 +7,7 @@ Users with push access to the repository can delete a release. .EXAMPLE - Remove-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -ID '1234567' + Remove-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -ID '1234567' Deletes the release with the ID '1234567' for the repository 'octocat/hello-world'. @@ -18,12 +18,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the release. [Parameter( @@ -43,33 +45,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" + Context = $Context + } - 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/$Repository]", 'Delete')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 index d2517ae57..5108990a5 100644 --- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 @@ -7,7 +7,7 @@ Users with push access to the repository can edit a release. .EXAMPLE - Set-GitHubRelease -Owner 'octocat' -Repo 'hello-world' -ID '1234567' -Body 'Release notes' + Set-GitHubRelease -Owner 'octocat' -Repository 'hello-world' -ID '1234567' -Body 'Release notes' Updates the release with the ID '1234567' for the repository 'octocat/hello-world' with the body 'Release notes'. @@ -19,12 +19,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the release. [Parameter(Mandatory)] @@ -85,46 +87,32 @@ 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 { - $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 + $body = @{ + tag_name = $TagName + target_commitish = $TargetCommitish + name = $Name + body = $Body + discussion_category_name = $DiscussionCategoryName + make_latest = $MakeLatest + draft = $Draft + prerelease = $Prerelease + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/releases/$ID" - Method = 'PATCH' - Body = $requestBody - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repo]", 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("release with ID [$ID] in [$Owner/$Repository]", 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 index 8f97fa861..b4c77ab70 100644 --- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 @@ -9,12 +9,12 @@ Information about autolinks are only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' Gets all autolinks for the repository 'Hello-World' owned by 'octocat'. .EXAMPLE - Get-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' -ID 1 + Get-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' -ID 1 Gets the autolink with the ID 1 for the repository 'Hello-World' owned by 'octocat'. @@ -22,25 +22,25 @@ [Get all autolinks of a repository](https://docs.github.com/rest/repos/autolinks#list-all-autolinks-of-a-repository) #> [Alias('Get-GitHubRepositoryAutolinks')] - [CmdletBinding(DefaultParameterSetName = 'Default')] + [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the autolink. [Parameter( Mandatory, ParameterSetName = 'ById' )] - [Alias('autolink_id')] - [Alias('ID')] - [int] $AutolinkId, + [Alias('autolink_id', 'AutolinkID')] + [int] $ID, # 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. @@ -53,26 +53,16 @@ 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 { switch ($PSCmdlet.ParameterSetName) { 'ById' { - Get-GitHubRepositoryAutolinkById -Owner $Owner -Repo $Repo -ID $AutolinkId -Context $Context + Get-GitHubRepositoryAutolinkById -Owner $Owner -Repository $Repository -ID $ID -Context $Context } default { - Get-GitHubRepositoryAutolinkList -Owner $Owner -Repo $Repo -Context $Context + Get-GitHubRepositoryAutolinkList -Owner $Owner -Repository $Repository -Context $Context } } } catch { diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 index 82e09218f..daffe6beb 100644 --- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 @@ -7,7 +7,7 @@ Users with admin access to the repository can create an autolink. .EXAMPLE - New-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' -KeyPrefix 'GH-' -UrlTemplate 'https://www.example.com/issue/' + New-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' -KeyPrefix 'GH-' -UrlTemplate 'https://www.example.com/issue/' Creates an autolink for the repository 'Hello-World' owned by 'octocat' that links to when the prefix 'GH-' is found in an issue, pull request, or commit. @@ -20,11 +20,13 @@ param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # This prefix appended by certain characters will generate a link any time it is found in an issue, pull request, or commit. [Parameter(Mandatory)] @@ -53,40 +55,26 @@ 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 = @{ - key_prefix = $KeyPrefix - url_template = $UrlTemplate - is_alphanumeric = $IsAlphanumeric - } + $body = @{ + key_prefix = $KeyPrefix + url_template = $UrlTemplate + is_alphanumeric = $IsAlphanumeric + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks" - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/autolinks" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repo]", 'Create')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Autolink for repository [$Owner/$Repository]", 'Create')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 index 9e3070a34..c662e7337 100644 --- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 @@ -9,7 +9,7 @@ Information about autolinks are only available to repository administrators. .EXAMPLE - Remove-GitHubRepositoryAutolink -Owner 'octocat' -Repo 'Hello-World' -AutolinkId 1 + Remove-GitHubRepositoryAutolink -Owner 'octocat' -Repository 'Hello-World' -AutolinkId 1 Deletes the autolink with ID 1 for the repository 'Hello-World' owned by 'octocat'. @@ -21,17 +21,18 @@ param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # The unique identifier of the autolink. [Parameter(Mandatory)] - [Alias('autolink_id')] - [Alias('ID')] - [int] $AutolinkId, + [Alias('autolink_id', 'AutolinkID')] + [int] $ID, # 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. @@ -44,34 +45,20 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId" - Method = 'DELETE' - Body = $body - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository/autolinks/$ID" + Body = $body + Context = $Context + } - 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 [$ID] for repository [$Owner/$Repository]", 'Delete')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 index 0e30677db..2bad4715d 100644 --- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 +++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 @@ -8,7 +8,7 @@ Users with read access to the repository can use this endpoint. .EXAMPLE - Get-GitHubRepositoryCustomProperty -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRepositoryCustomProperty -Owner 'octocat' -Repository 'hello-world' Gets all custom property values that are set for the 'hello-world' repository. @@ -21,13 +21,14 @@ [OutputType([pscustomobject])] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -40,31 +41,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/properties/values" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/properties/values" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index ce87b3528..f92a7fafd 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -9,7 +9,7 @@ "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)". .EXAMPLE - Disable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repo 'GitHub' + Disable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repository 'GitHub' Disables private vulnerability reporting for the PSModule/GitHub repository. @@ -20,13 +20,14 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository/private-vulnerability-reporting" + Context = $Context + } - 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/$Repository]", 'Disable')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 index c390ff1b8..a3c0a256d 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 @@ -9,7 +9,7 @@ "[Configuring automated security fixes](https://docs.github.com/articles/configuring-automated-security-fixes)". .EXAMPLE - Disable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repo 'GitHub' + Disable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repository 'GitHub' Disables automated security fixes for the repository. @@ -20,13 +20,14 @@ [Alias('Disable-GitHubRepositorySecurityFixes')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Disable')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repository]", 'Disable')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 index bc9690d9e..ba694aef5 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -9,7 +9,7 @@ "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". .EXAMPLE - Disable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repo 'hello-world' + Disable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repository 'hello-world' Disables vulnerability alerts for the 'octocat/hello-world' repository. @@ -20,13 +20,14 @@ [Alias('Disable-GitHubRepositoryVulnerabilityAlerts')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Disable')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repository]", 'Disable')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index 2236d79fc..45ed9ac0a 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -9,7 +9,7 @@ "[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)." .EXAMPLE - Enable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repo 'GitHub' + Enable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repository 'GitHub' Enables private vulnerability reporting for the PSModule/GitHub repository. @@ -20,13 +20,14 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting" - Method = 'PUT' - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repository/private-vulnerability-reporting" + Context = $Context + } - 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/$Repository]", 'Enable')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 index 47d8cf67e..1617d42a4 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 @@ -9,7 +9,7 @@ "[Configuring automated security fixes](https://docs.github.com/articles/configuring-automated-security-fixes)". .EXAMPLE - Enable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repo 'GitHub' + Enable-GitHubRepositorySecurityFix -Owner 'PSModule' -Repository 'GitHub' Enables automated security fixes for the repository. @@ -20,13 +20,14 @@ [Alias('Enable-GitHubRepositorySecurityFixes')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -39,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'PUT' - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repo]", 'Enable')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Security Fixes for [$Owner/$Repository]", 'Enable')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 index 7709b0937..c820d34e6 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -10,7 +10,7 @@ "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". .EXAMPLE - Enable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repo 'hello-world' + Enable-GitHubRepositoryVulnerabilityAlert -Owner 'octocat' -Repository 'hello-world' Enables vulnerability alerts for the 'octocat/hello-world' repository. @@ -21,13 +21,14 @@ [Alias('Enable-GitHubRepositoryVulnerabilityAlerts')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -40,33 +41,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" - Method = 'PUT' - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repo]", 'Enable')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Vulnerability Alerts for [$Owner/$Repository]", 'Enable')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 index 5fbd22311..487ffa468 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 @@ -37,7 +37,7 @@ filter Get-GitHubRepository { Gets the repositories with an ID equals and greater than 123456789. .EXAMPLE - Get-GitHubRepository -Owner 'github' -Repo 'octocat' + Get-GitHubRepository -Owner 'github' -Repository 'octocat' Gets the specified repository. @@ -89,7 +89,7 @@ filter Get-GitHubRepository { Mandatory, ParameterSetName = 'ByName' )] - [string] $Repo, + [string] $Repository, # The handle for the GitHub user account. [Parameter( @@ -166,100 +166,86 @@ filter Get-GitHubRepository { 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 { - $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 + $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 } - '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 + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubMyRepositories @params + } + 'MyRepos_Aff-Vis' { + $params = @{ + Context = $Context + Visibility = $Visibility + Affiliation = $Affiliation + Sort = $Sort + Direction = $Direction + PerPage = $PerPage + Since = $Since + Before = $Before } - 'ByName' { - $params = @{ - Context = $Context - Owner = $Owner - Repo = $Repo - } - $params | Remove-HashtableEntry -NullOrEmptyValues - Write-Verbose ($params | Format-List | Out-String) - Get-GitHubRepositoryByName @params + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubMyRepositories @params + } + 'ByName' { + $params = @{ + Context = $Context + Owner = $Owner + Repository = $Repository } - 'ListByID' { - $params = @{ - Context = $Context - Since = $SinceID - } - $params | Remove-HashtableEntry -NullOrEmptyValues - Write-Verbose ($params | Format-List | Out-String) - Get-GitHubRepositoryListByID @params + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubRepositoryByName @params + } + 'ListByID' { + $params = @{ + Context = $Context + Since = $SinceID } - '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 + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubRepositoryListByID @params + } + 'ListByOrg' { + $params = @{ + Context = $Context + Owner = $Owner + 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 + $params | Remove-HashtableEntry -NullOrEmptyValues + Write-Verbose ($params | Format-List | Out-String) + Get-GitHubRepositoryListByOrg @params + } + '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 } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index 839b4be6f..7c7e346e0 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -11,25 +11,25 @@ see "[Viewing activity and data for your repository](https://docs.github.com/repositories/viewing-activity-and-data-for-your-repository)." .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Direction 'asc' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Direction 'asc' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -PerPage 100 + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -PerPage 100 .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Before '2021-01-01T00:00:00Z' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Before '2021-01-01T00:00:00Z' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -After '2021-01-01T00:00:00Z' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -After '2021-01-01T00:00:00Z' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Ref 'refs/heads/main' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Ref 'refs/heads/main' .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -Actor 'octocat' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -Actor 'octocat' .EXAMPLE $params = @{ @@ -43,7 +43,7 @@ Gets the activity for the past 24 hours and selects the actor, activity type, ref, and timestamp. .EXAMPLE - Get-GitHubRepositoryActivity -Owner 'PSModule' -Repo 'GitHub' -ActivityType 'push','force_push' + Get-GitHubRepositoryActivity -Owner 'PSModule' -Repository 'GitHub' -ActivityType 'push','force_push' .NOTES [List repository activities](https://docs.github.com/rest/repos/repos#list-repository-activities) @@ -51,13 +51,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The direction to sort the results by. [Parameter()] @@ -112,44 +113,30 @@ Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + } - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + process { + $body = @{ + direction = $Direction + per_page = $PerPage + before = $Before + after = $After + ref = $Ref + actor = $Actor + time_period = $TimePeriod + activity_type = $ActivityType } - Write-Debug "Owner: [$Owner]" + $body | Remove-HashtableEntry -NullOrEmptyValues - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/activity" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 index cbc4ebbaa..14fd9511b 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 @@ -10,7 +10,7 @@ see "[About code owners](https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners)." .EXAMPLE - Get-GitHubRepositoryCodeownersError -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryCodeownersError -Owner 'PSModule' -Repository 'GitHub' Gets the CODEOWNERS errors for the repository. @@ -21,13 +21,14 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # A branch, tag or commit name used to determine which version of the CODEOWNERS file to use. # Default: the repository's default branch (e.g. main) @@ -45,37 +46,23 @@ 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 = @{ - ref = $Ref - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + ref = $Ref + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/codeowners/errors" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 index f7562b5f6..47dbaae2a 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 @@ -12,7 +12,7 @@ in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information. .EXAMPLE - Get-GitHubRepositoryContributor -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryContributor -Owner 'PSModule' -Repository 'GitHub' Gets all contributors to the GitHub repository. @@ -22,13 +22,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # Wether to include anonymous contributors in results. [Parameter()] @@ -50,38 +51,24 @@ 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 = @{ - anon = $Anon - per_page = $PerPage - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + anon = $Anon + per_page = $PerPage + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/contributors" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/contributors" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 index 3986c856e..0335d6158 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 @@ -7,7 +7,7 @@ List forks of a named repository. .EXAMPLE - Get-GitHubRepositoryFork -Owner 'octocat' -Repo 'Hello-World' + Get-GitHubRepositoryFork -Owner 'octocat' -Repository 'Hello-World' List forks of the 'Hello-World' repository owned by 'octocat'. @@ -17,13 +17,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The direction to sort the results by. [Parameter()] @@ -46,38 +47,24 @@ 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 = @{ - sort = $Sort - per_page = $PerPage - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + sort = $Sort + per_page = $PerPage + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/forks" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/forks" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 index cbecbb6ff..715221bb3 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 @@ -8,7 +8,7 @@ bytes of code written in that language. .EXAMPLE - Get-GitHubRepositoryLanguage -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRepositoryLanguage -Owner 'octocat' -Repository 'hello-world' Gets the languages for the 'hello-world' repository owned by 'octocat'. @@ -19,13 +19,14 @@ [Alias('Get-GitHubRepositoryLanguages')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -38,31 +39,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/languages" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/languages" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 index c109b2f9d..cf84e7180 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 @@ -9,7 +9,7 @@ "[Configuring automated security fixes](https://docs.github.com/articles/configuring-automated-security-fixes)". .EXAMPLE - Get-GitHubRepositorySecurityFix -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositorySecurityFix -Owner 'PSModule' -Repository 'GitHub' Gets the automated security fixes status for the GitHub repository. @@ -21,13 +21,14 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -40,31 +41,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 index 0d5c31fbc..1be5b3066 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 @@ -7,7 +7,7 @@ List repository tags .EXAMPLE - Get-GitHubRepositoryTag -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryTag -Owner 'PSModule' -Repository 'GitHub' Gets all tags of the GitHub repository. @@ -18,13 +18,14 @@ [Alias('Get-GitHubRepositoryTags')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -42,36 +43,22 @@ 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/tags" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 index b17f5777c..301e3c881 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 @@ -15,7 +15,7 @@ This endpoint is not compatible with fine-grained personal access tokens. .EXAMPLE - Get-GitHubRepositoryTeam -Owner 'PSModule' -Repo 'GitHub' + Get-GitHubRepositoryTeam -Owner 'PSModule' -Repository 'GitHub' Lists the teams that have access to the specified repository and that are also visible to the authenticated user. @@ -26,13 +26,14 @@ [Alias('Get-GitHubRepositoryTeams')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -50,36 +51,22 @@ Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + } - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + process { + $body = @{ + per_page = $PerPage } - Write-Debug "Owner: [$Owner]" - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/teams" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 index 83e414d77..cd92be828 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 @@ -14,13 +14,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -38,36 +39,22 @@ 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 = @{ - per_page = $PerPage - } + $body = @{ + per_page = $PerPage + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/topics" - Method = 'GET' - Body = $body - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/topics" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response.names - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.names } } diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 index 038962e12..9a975465d 100644 --- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 @@ -12,7 +12,7 @@ a fine-grained personal access token cannot be used because they are only granted access to a single account. .EXAMPLE - Move-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' -NewOwner 'GitHub' -NewName 'PowerShell' + Move-GitHubRepository -Owner 'PSModule' -Repository 'GitHub' -NewOwner 'GitHub' -NewName 'PowerShell' Moves the GitHub repository to the PSModule organization and renames it to GitHub. @@ -22,13 +22,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The username or organization name the repository will be transferred to. [Parameter(Mandatory)] @@ -56,39 +57,25 @@ 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 = @{ - new_owner = $NewOwner - new_name = $NewName - team_ids = $TeamIds - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $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 - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/transfer" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 index da62375ad..0f363939e 100644 --- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 @@ -10,25 +10,24 @@ repositories, you will get a `403 Forbidden` response. .EXAMPLE - Remove-GitHubRepository -Owner 'PSModule' -Repo 'Hello-World' + Remove-GitHubRepository -Owner 'PSModule' -Repository 'Hello-World' Deletes the repository `Hello-World` in the `PSModule` organization. .NOTES [Delete a repository](https://docs.github.com/rest/repos/repos#delete-a-repository) #> - #TODO: Set high impact - [CmdletBinding(SupportsShouldProcess)] + [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] - [Alias('login')] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. [Parameter(Mandatory)] - [string] $Repo, + [string] $Repository, # 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. @@ -41,33 +40,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repo]", 'Delete')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repository]", 'Delete')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 index 8bd672d00..ea243e9b6 100644 --- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 @@ -7,7 +7,7 @@ Replace all repository topics .EXAMPLE - Set-GitHubRepositoryTopic -Owner 'octocat' -Repo 'hello-world' -Names 'octocat', 'octo', 'octocat/hello-world' + Set-GitHubRepositoryTopic -Owner 'octocat' -Repository 'hello-world' -Names 'octocat', 'octo', 'octocat/hello-world' Replaces all topics for the repository 'octocat/hello-world' with the topics 'octocat', 'octo', 'octocat/hello-world'. @@ -17,13 +17,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The number of results per page (max 100). [Parameter()] @@ -41,38 +42,24 @@ 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 = @{ - names = $Names | ForEach-Object { $_.ToLower() } - } + $body = @{ + names = $Names | ForEach-Object { $_.ToLower() } + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/topics" - Method = 'PUT' - Body = $body - } + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/repos/$Owner/$Repository/topics" + Body = $body + Context = $Context + } - 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/$Repository]", 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response.names } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 index 59694f66f..490d53d10 100644 --- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 +++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 @@ -43,13 +43,14 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # A custom webhook event name. Must be 100 characters or fewer. [Parameter(Mandatory)] @@ -73,38 +74,24 @@ 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 = @{ - event_type = $EventType - client_payload = $ClientPayload - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + event_type = $EventType + client_payload = $ClientPayload + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/dispatches" - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/dispatches" + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 index ee3d67b7b..12f361893 100644 --- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 @@ -10,7 +10,7 @@ "[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". .EXAMPLE - Test-GitHubRepositoryVulnerabilityAlert -Owner 'PSModule' -Repo 'GitHub' + Test-GitHubRepositoryVulnerabilityAlert -Owner 'PSModule' -Repository 'GitHub' Checks if vulnerability alerts are enabled for the PSModule/GitHub repository. @@ -22,13 +22,14 @@ [Alias('Test-GitHubRepositoryVulnerabilityAlerts')] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -41,34 +42,16 @@ 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 { $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" 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 $_ - } - } + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 index 614c19f3c..4c708d204 100644 --- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 @@ -14,7 +14,7 @@ $params = @{ Owner = 'octocat' Repo = 'Hello-World' - name = 'Hello-World-Repo + name = 'Hello-World-Repository description = 'This is your first repository' homepage = 'https://github.com' } @@ -26,13 +26,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the repository. [Parameter()] @@ -182,70 +183,56 @@ 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 = @{ - 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 - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $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 + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo" - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/repos/$Owner/$Repository" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repo]", 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Repository [$Owner/$Repository]", 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 index ec1dddde2..f9a14ed0e 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 @@ -22,7 +22,7 @@ Gets a list of rule suites for the main branch of the hello-world repository owned by octocat. .EXAMPLE - Get-GitHubRepositoryRuleSuite -Owner 'octocat' -Repo 'hello-world' -RuleSuiteId 123456789 + Get-GitHubRepositoryRuleSuite -Owner 'octocat' -Repository 'hello-world' -RuleSuiteId 123456789 Gets information about a suite of rule evaluations with ID 123456789 from within the octocat/hello-world repository. @@ -32,7 +32,7 @@ #> [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] - [CmdletBinding(DefaultParameterSetName = 'Default')] + [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. [Parameter()] @@ -40,8 +40,8 @@ [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the ref. Cannot contain wildcard characters. # When specified, only rule evaluations triggered for this ref will be returned. @@ -87,46 +87,32 @@ 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 { - $params = @{ - Context = $Context - Owner = $Owner - Repo = $Repo - } + $params = @{ + Context = $Context + Owner = $Owner + Repository = $Repository + } - switch ($PSCmdlet.ParameterSetName) { - 'Default' { - $params += @{ - Ref = $Ref - TimePeriod = $TimePeriod - ActorName = $ActorName - RuleSuiteResult = $RuleSuiteResult - PerPage = $PerPage - } - Get-GitHubRepositoryRuleSuiteList @params + switch ($PSCmdlet.ParameterSetName) { + 'ById' { + $params += @{ + RuleSuiteId = $RuleSuiteId } - 'ById' { - $params += @{ - RuleSuiteId = $RuleSuiteId - } - Get-GitHubRepositoryRuleSuiteById @params + Get-GitHubRepositoryRuleSuiteById @params + } + default { + $params += @{ + Ref = $Ref + TimePeriod = $TimePeriod + ActorName = $ActorName + RuleSuiteResult = $RuleSuiteResult + PerPage = $PerPage } + Get-GitHubRepositoryRuleSuiteList @params } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 index a4b1dc3b6..d7233a5e9 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 @@ -8,7 +8,7 @@ For more information, see "[Managing rulesets for a repository](https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository#viewing-insights-for-rulesets)." .EXAMPLE - Get-GitHubRepositoryRuleSuiteById -Owner 'octocat' -Repo 'hello-world' -RuleSuiteId 123456789 + Get-GitHubRepositoryRuleSuiteById -Owner 'octocat' -Repository 'hello-world' -RuleSuiteId 123456789 Gets information about a suite of rule evaluations with ID 123456789 from within the octocat/hello-world repository. @@ -20,17 +20,19 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the rule suite result. To get this ID, you can use GET /repos/ { owner }/ { repo }/rulesets/rule-suites for repositories and GET /orgs/ { org }/rulesets/rule-suites for organizations. [Parameter(Mandatory)] - [int] $RuleSuiteId, + [Alias('RuleSuiteId')] + [int] $ID, # 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. @@ -43,31 +45,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/rulesets/rule-suites/$ID" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 index cb18ef6f4..15f040993 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 @@ -28,13 +28,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The name of the ref. Cannot contain wildcard characters. # When specified, only rule evaluations triggered for this ref will be returned. @@ -73,41 +74,27 @@ Write-Debug "[$stackPath] - Start" $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT + } - if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner + process { + $body = @{ + ref = $Ref + time_period = $TimePeriod + actor_name = $ActorName + rule_suite_result = $RuleSuiteResult + per_page = $PerPage } - Write-Debug "Owner: [$Owner]" + $body | Remove-HashtableEntry -NullOrEmptyValues - if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/rulesets/rule-suites" + Body = $body + Context = $Context } - Write-Debug "Repo: [$Repo]" - } - 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 } } diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 index 69f68deb4..50759e4a2 100644 --- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 @@ -9,7 +9,7 @@ This information is only available to repository administrators. .EXAMPLE - Get-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' + Get-GitHubRepositoryTagProtection -Owner 'octocat' -Repository 'hello-world' Gets the tag protection states of the 'hello-world' repository. @@ -20,13 +20,14 @@ [CmdletBinding()] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # 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. @@ -39,31 +40,17 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags/protection" - Method = 'GET' - } + $inputObject = @{ + Method = 'Get' + APIEndpoint = "/repos/$Owner/$Repository/tags/protection" + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 index 66612fc1c..41910a68c 100644 --- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 @@ -8,7 +8,7 @@ This endpoint is only available to repository administrators. .EXAMPLE - New-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -Pattern 'v1.*' + New-GitHubRepositoryTagProtection -Owner 'octocat' -Repository 'hello-world' -Pattern 'v1.*' Creates a tag protection state for the 'hello-world' repository with the pattern 'v1.*'. @@ -19,13 +19,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # An optional glob pattern to match against when enforcing tag protection. [Parameter(Mandatory)] @@ -42,38 +43,24 @@ 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 = @{ - pattern = $Pattern - } + $body = @{ + pattern = $Pattern + } - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags/protection" - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/repos/$Owner/$Repository/tags/protection" + Body = $body + Context = $Context + } - 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/$Repository]", 'Create')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 index 54aab7946..952adfed1 100644 --- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 @@ -8,7 +8,7 @@ This endpoint is only available to repository administrators. .EXAMPLE - Remove-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -TagProtectionId 1 + Remove-GitHubRepositoryTagProtection -Owner 'octocat' -Repository 'hello-world' -TagProtectionId 1 Deletes the tag protection state with the ID 1 for the 'hello-world' repository. @@ -19,13 +19,14 @@ [CmdletBinding(SupportsShouldProcess)] param( # The account owner of the repository. The name is not case sensitive. - [Parameter()] - [Alias('org')] + [Parameter(Mandatory)] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. - [Parameter()] - [string] $Repo, + [Parameter(Mandatory)] + [string] $Repository, # The unique identifier of the tag protection. [Parameter(Mandatory)] @@ -42,33 +43,19 @@ 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 { - $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/repos/$Owner/$Repository/tags/protection/$TagProtectionId" + Context = $Context + } - 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/$Repository]", 'Delete')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Teams/Get-GitHubTeam.ps1 b/src/functions/public/Teams/Get-GitHubTeam.ps1 index 54862c043..eaaec36b0 100644 --- a/src/functions/public/Teams/Get-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Get-GitHubTeam.ps1 @@ -19,7 +19,7 @@ Gets the team with the slug 'my-team-name' in the `github` organization. #> [OutputType([GitHubTeam])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding()] param( # The slug of the team name. [Parameter( @@ -63,7 +63,7 @@ 'BySlug' { Get-GitHubTeamBySlug @params -Slug $Slug } - '__AllParameterSets' { + default { Get-GitHubTeamListByOrg @params } } diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1 index b7163c226..74a9d2297 100644 --- a/src/functions/public/Teams/New-GitHubTeam.ps1 +++ b/src/functions/public/Teams/New-GitHubTeam.ps1 @@ -36,8 +36,7 @@ # The organization name. The name is not case sensitive. # If not provided, the organization from the context is used. - [Parameter()] - [Alias('Org')] + [Parameter(Mandatory)] [string] $Organization, # The description of the team. @@ -91,61 +90,52 @@ $Context = Resolve-GitHubContext -Context $Context Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT - if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Owner - } - Write-Debug "Organization: [$Organization]" - if (-not $Visible -and $ParentTeamID -gt 0) { throw 'A nested team cannot be secret (invisible).' } } process { - try { - $body = @{ - name = $Name - description = $Description - maintainers = $Maintainers - repo_names = $RepoNames - privacy = $Visible ? 'closed' : 'secret' - notification_setting = $Notifications ? 'notifications_enabled' : 'notifications_disabled' - permission = $Permission - parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + name = $Name + description = $Description + maintainers = $Maintainers + repo_names = $RepoNames + privacy = $Visible ? 'closed' : 'secret' + notification_setting = $Notifications ? 'notifications_enabled' : 'notifications_disabled' + 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 - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = "/orgs/$Organization/teams" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("'$Name' in '$Organization'", 'Create team')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - $team = $_.Response - [GitHubTeam]( - @{ - Name = $team.name - Slug = $team.slug - NodeID = $team.node_id - CombinedSlug = $Organization + '/' + $team.slug - DatabaseId = $team.id - Description = $team.description - Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false - Visible = $team.privacy -eq 'closed' ? $true : $false - ParentTeam = $team.parent.slug - Organization = $team.organization.login - ChildTeams = @() - CreatedAt = $team.created_at - UpdatedAt = $team.updated_at - } - ) - } + if ($PSCmdlet.ShouldProcess("'$Name' in '$Organization'", 'Create team')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + $team = $_.Response + [GitHubTeam]( + @{ + Name = $team.name + Slug = $team.slug + NodeID = $team.node_id + CombinedSlug = $Organization + '/' + $team.slug + DatabaseId = $team.id + Description = $team.description + Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false + Visible = $team.privacy -eq 'closed' ? $true : $false + ParentTeam = $team.parent.slug + Organization = $team.organization.login + ChildTeams = @() + CreatedAt = $team.created_at + UpdatedAt = $team.updated_at + } + ) } - } catch { - throw $_ } } diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1 index 066df8804..71889c919 100644 --- a/src/functions/public/Teams/Remove-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1 @@ -21,15 +21,15 @@ Mandatory, ValueFromPipelineByPropertyName )] - [Alias('team_slug')] - [string] $Slug, + [Alias('team_slug', 'Slug')] + [string] $Name, # The organization name. The name is not case sensitive. # If not provided, the organization from the context is used. [Parameter( + Mandatory, ValueFromPipelineByPropertyName )] - [Alias('Org')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. @@ -43,28 +43,19 @@ 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]" } process { - try { - $inputObject = @{ - Context = $Context - Method = 'Delete' - APIEndpoint = "/orgs/$Organization/teams/$Slug" - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/orgs/$Organization/teams/$Name" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$Organization/$Slug", '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 $_ } } diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1 index 21b6b4f2f..98ab729c3 100644 --- a/src/functions/public/Teams/Update-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Update-GitHubTeam.ps1 @@ -30,19 +30,18 @@ param( # The slug of the team name. [Parameter(Mandatory)] - [Alias('team_slug')] - [string] $Slug, + [Alias('team_slug', 'Slug')] + [string] $Name, # The organization name. The name is not case sensitive. # If you do not provide this parameter, the command will use the organization from the context. - [Parameter()] - [Alias('Org')] + [Parameter(Mandatory)] [string] $Organization, # The new team name. [Parameter()] [Alias()] - [string] $Name, + [string] $NewName, # The description of the team. [Parameter()] @@ -86,57 +85,48 @@ 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]" } process { - try { - $body = @{ - name = $Name - description = $Description - privacy = $PSBoundParameters.ContainsKey('Visible') ? ($Visible ? 'closed' : 'secret') : $null - notification_setting = $PSBoundParameters.ContainsKey('Notifications') ? + $body = @{ + name = $NewName + description = $Description + privacy = $PSBoundParameters.ContainsKey('Visible') ? ($Visible ? 'closed' : 'secret') : $null + notification_setting = $PSBoundParameters.ContainsKey('Notifications') ? ($Notifications ? 'notifications_enabled' : 'notifications_disabled') : $null - permission = $Permission - parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID - } - $body | Remove-HashtableEntry -NullOrEmptyValues + permission = $Permission + parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = "/orgs/$Organization/teams/$Slug" - Method = 'Patch' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = "/orgs/$Organization/teams/$Name" + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("$Organization/$Slug", 'Update')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - $team = $_.Response - [GitHubTeam]( - @{ - Name = $team.name - Slug = $team.slug - NodeID = $team.node_id - CombinedSlug = $Organization + '/' + $team.slug - DatabaseId = $team.id - Description = $team.description - Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false - Visible = $team.privacy -eq 'closed' ? $true : $false - ParentTeam = $team.parent.slug - Organization = $team.organization.login - ChildTeams = @() - CreatedAt = $team.created_at - UpdatedAt = $team.updated_at - } - ) - } + if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + $team = $_.Response + [GitHubTeam]( + @{ + Name = $team.name + Slug = $team.slug + NodeID = $team.node_id + CombinedSlug = $Organization + '/' + $team.slug + DatabaseId = $team.id + Description = $team.description + Notifications = $team.notification_setting -eq 'notifications_enabled' ? $true : $false + Visible = $team.privacy -eq 'closed' ? $true : $false + ParentTeam = $team.parent.slug + Organization = $team.organization.login + ChildTeams = @() + CreatedAt = $team.created_at + UpdatedAt = $team.updated_at + } + ) } - } catch { - throw $_ } } diff --git a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 index 3a2587561..7d4527afd 100644 --- a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 @@ -7,7 +7,7 @@ This endpoint is accessible with the `user` scope. .EXAMPLE - Add-GitHubUserEmail -Emails 'octocat@github.com','firstname.lastname@work.com' + Add-GitHubUserEmail -Email 'octocat@github.com','firstname.lastname@work.com' Adds the email addresses `octocat@github.com` and `firstname.lastname@work.com` to the authenticated user's account. @@ -26,7 +26,7 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [string[]] $Emails, + [string[]] $Email, # 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. @@ -42,23 +42,19 @@ } process { - try { - $body = @{ - emails = $Emails - } + $body = @{ + emails = $Email + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/emails' - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/emails' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 index 643e053af..2ace0b7de 100644 --- a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 @@ -24,7 +24,7 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [string[]] $Emails, + [string[]] $Email, # 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. @@ -40,25 +40,21 @@ } process { - try { - $body = @{ - emails = $Emails - } + $body = @{ + emails = $Email + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/emails' - Method = 'DELETE' - Body = $body - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = '/user/emails' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Email addresses [$($Emails -join ', ')]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Email addresses [$($Email -join ', ')]", 'Delete')) { + $null = Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 index 8436e6067..947dbe9a2 100644 --- a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 +++ b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 @@ -46,25 +46,21 @@ } process { - try { - $body = @{ - visibility = $Visibility - } + $body = @{ + visibility = $Visibility + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/email/visibility' - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = '/user/email/visibility' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Email visibility [$Visibility]", 'Set')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess("Email visibility [$Visibility]", 'Set')) { + $null = Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 index 7ff3a5afc..3f4c0a79a 100644 --- a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 @@ -42,19 +42,13 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/following/$Username" - Method = 'PUT' - } - - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Method = 'Put' + APIEndpoint = "/user/following/$Username" + Context = $Context } + + Invoke-GitHubAPI @inputObject } end { diff --git a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 index c337a6e36..57512912d 100644 --- a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 @@ -40,20 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/following/$Username" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/following/$Username" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("User [$Username]", 'Unfollow')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("User [$Username]", 'Unfollow')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 index 230fff1fe..8b8503b82 100644 --- a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 @@ -24,7 +24,7 @@ #> [OutputType([pscustomobject])] [CmdletBinding()] - param( + param ( # A descriptive name for the new key. [Parameter( Mandatory, @@ -55,24 +55,20 @@ } process { - try { - $body = @{ - name = $Name - armored_public_key = $ArmoredPublicKey - } + $body = @{ + name = $Name + armored_public_key = $ArmoredPublicKey + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/gpg_keys' - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/gpg_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 index 5f1449afd..3398b9745 100644 --- a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 @@ -40,20 +40,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/gpg_keys/$ID" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/gpg_keys/$ID" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 index 914060868..a676dda90 100644 --- a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 @@ -49,24 +49,20 @@ } process { - try { - $body = @{ - title = $Title - key = $Key - } + $body = @{ + title = $Title + key = $Key + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/keys' - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 index 917b3bc99..535b76464 100644 --- a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 @@ -41,20 +41,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/keys/$ID" - Method = 'DELETE' - } + $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 $_ + if ($PSCmdlet.ShouldProcess("Key with ID [$ID]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } 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 7484e2f7d..ff451fadf 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 @@ -51,24 +51,20 @@ } process { - try { - $body = @{ - title = $Title - key = $Key - } + $body = @{ + title = $Title + key = $Key + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/ssh_signing_keys' - Method = 'POST' - Body = $body - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/ssh_signing_keys' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } 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 41704ce8f..dcda75f2e 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 @@ -42,20 +42,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/user/ssh_signing_keys/$ID" - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = "/user/ssh_signing_keys/$ID" + Context = $Context + } - if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 index 363aad47d..c28aeb43f 100644 --- a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 @@ -21,8 +21,8 @@ param( # Full URLs for the social media profiles to add. [Parameter(Mandatory)] - [Alias('account_urls')] - [string[]] $AccountUrls, + [Alias('account_urls', 'social_accounts', 'AccountUrls')] + [string[]] $URL, # 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. @@ -38,23 +38,19 @@ } process { - try { - $body = @{ - account_urls = $AccountUrls - } + $body = @{ + account_urls = $URL + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/social_accounts' - Body = $body - Method = 'POST' - } + $inputObject = @{ + Method = 'Post' + APIEndpoint = '/user/social_accounts' + Body = $body + Context = $Context + } - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 index dcc0e3816..334537a91 100644 --- a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 @@ -22,8 +22,8 @@ param( # Full URLs for the social media profiles to add. [Parameter(Mandatory)] - [Alias('account_urls')] - [string[]] $AccountUrls, + [Alias('account_urls', 'social_accounts', 'AccountUrls')] + [string[]] $URL, # 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. @@ -39,25 +39,19 @@ } process { - try { - $body = @{ - account_urls = $AccountUrls - } + $body = @{ + account_urls = $URL + } - $inputObject = @{ - Context = $Context - APIEndpoint = '/user/social_accounts' - Body = $body - Method = 'DELETE' - } + $inputObject = @{ + Method = 'Delete' + APIEndpoint = '/user/social_accounts' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess("Social accounts [$($AccountUrls -join ', ')]", 'Delete')) { - $null = Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess("Social accounts [$($URL -join ', ')]", 'Delete')) { + Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Update-GitHubUser.ps1 b/src/functions/public/Users/Update-GitHubUser.ps1 index 6d8a4ed33..da8e4afa1 100644 --- a/src/functions/public/Users/Update-GitHubUser.ps1 +++ b/src/functions/public/Users/Update-GitHubUser.ps1 @@ -75,33 +75,29 @@ } process { - try { - $body = @{ - name = $Name - email = $Email - blog = $Blog - twitter_username = $TwitterUsername - company = $Company - location = $Location - hireable = $Hireable - bio = $Bio - } - $body | Remove-HashtableEntry -NullOrEmptyValues + $body = @{ + name = $Name + email = $Email + blog = $Blog + twitter_username = $TwitterUsername + company = $Company + location = $Location + hireable = $Hireable + bio = $Bio + } + $body | Remove-HashtableEntry -NullOrEmptyValues - $inputObject = @{ - Context = $Context - APIEndpoint = '/user' - Method = 'PATCH' - Body = $body - } + $inputObject = @{ + Method = 'Patch' + APIEndpoint = '/user' + Body = $body + Context = $Context + } - if ($PSCmdlet.ShouldProcess('authenticated user', 'Set')) { - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } + if ($PSCmdlet.ShouldProcess('authenticated user', 'Set')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } - } catch { - throw $_ } } diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 5ece25162..54f287d12 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -440,7 +440,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (USER_FG_PAT)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { @@ -462,7 +462,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets a specific repository (USER_FG_PAT)' { - { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubRepository -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets all repositories from a organization (USER_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw @@ -597,7 +597,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (ORG_FG_PAT)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { @@ -619,7 +619,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Get-GitHubRepository -Visibility 'public' -Affiliation 'owner' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets a specific repository (ORG_FG_PAT)' { - { Get-GitHubRepository -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubRepository -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } It 'Get-GitHubRepository - Gets all repositories from a organization (ORG_FG_PAT)' { { Get-GitHubRepository -Owner 'PSModule' } | Should -Not -Throw @@ -777,7 +777,7 @@ Describe 'As a user - Classic PAT token (PAT)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (PAT)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { @@ -956,7 +956,7 @@ Describe 'As GitHub Actions (GHA)' { { Get-GitHubLicense -Name 'mit' } | Should -Not -Throw } It 'Get-GitHubLicense - Gets a license from a repository (GHA)' { - { Get-GitHubLicense -Owner 'PSModule' -Repo 'GitHub' } | Should -Not -Throw + { Get-GitHubLicense -Owner 'PSModule' -Repository 'GitHub' } | Should -Not -Throw } } Context 'Emoji' { diff --git a/tools/Guidelines.md b/tools/Guidelines.md index 1fe2e5e46..ecf19dade 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -96,3 +96,26 @@ function documentation they can search based on the official documentation. - One class pr type of resource - Properties are PascalCased (as expected by PowerShell users) +``` +if ([string]::IsNullOrEmpty($Enterprise)) { + $Enterprise = $Context.Enterprise +} +Write-Debug "Enterprise: [$Enterprise]" + +if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization +} +Write-Debug "Organization: [$Organization]" + +if ([string]::IsNullOrEmpty($Owner)) { + $Owner = $Context.Owner +} +Write-Debug "Owner: [$Owner]" + +if ([string]::IsNullOrEmpty($Repo)) { + $Repo = $Context.Repo +} +Write-Debug "Repo: [$Repo]" + +# What about "Name", "Login", "Username" +``` From f066cabd771463d1a09c27e1680bf1ab8a2b4669 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 20:03:02 +0100 Subject: [PATCH 53/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Fix=20context?= =?UTF-8?q?=20type=20casting=20in=20Set-GitHubContext=20function=20and=20u?= =?UTF-8?q?pdate=20documentation=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/private/Auth/Context/Set-GitHubContext.ps1 | 2 +- tools/Guidelines.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index ab55514c0..3a30c6f87 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -54,7 +54,7 @@ function Set-GitHubContext { Write-Debug "Getting info on the context [$($contextObj['AuthType'])]." switch -Regex (($contextObj['AuthType'])) { 'PAT|UAT|IAT' { - $viewer = Get-GitHubViewer -Context [UserGitHubContext]$contextObj + $viewer = Get-GitHubViewer -Context [UserGitHubContext]($contextObj) $viewer | Out-String -Stream | ForEach-Object { Write-Debug $_ } if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) { $contextObj['DisplayName'] = [string]$viewer.name diff --git a/tools/Guidelines.md b/tools/Guidelines.md index ecf19dade..0314c821d 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -96,7 +96,7 @@ function documentation they can search based on the official documentation. - One class pr type of resource - Properties are PascalCased (as expected by PowerShell users) -``` +```pwsh if ([string]::IsNullOrEmpty($Enterprise)) { $Enterprise = $Context.Enterprise } From fc6b201b9fb6bfff3494c0f43b0f1bf3b1a40698 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 20:29:35 +0100 Subject: [PATCH 54/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Set-Gi?= =?UTF-8?q?tHubContext=20to=20handle=20IAT=20authentication=20type=20and?= =?UTF-8?q?=20improve=20context=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Auth/Context/Set-GitHubContext.ps1 | 6 +- tools/Guidelines.md | 73 +++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index 3a30c6f87..6868442c4 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -54,7 +54,11 @@ function Set-GitHubContext { Write-Debug "Getting info on the context [$($contextObj['AuthType'])]." switch -Regex (($contextObj['AuthType'])) { 'PAT|UAT|IAT' { - $viewer = Get-GitHubViewer -Context [UserGitHubContext]($contextObj) + if ($_ -eq 'IAT') { + $viewer = Get-GitHubViewer -Context [InstallationGitHubContext]($contextObj) + } else { + $viewer = Get-GitHubViewer -Context [UserGitHubContext]($contextObj) + } $viewer | Out-String -Stream | ForEach-Object { Write-Debug $_ } if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) { $contextObj['DisplayName'] = [string]$viewer.name diff --git a/tools/Guidelines.md b/tools/Guidelines.md index 0314c821d..04abc6746 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -119,3 +119,76 @@ Write-Debug "Repo: [$Repo]" # What about "Name", "Login", "Username" ``` + + +## TO DO + +In private, make Context Mandatory + +if ([string]::IsNullOrEmpty($Repo)) { + $Repo = $Context.Repo + } +Write-Debug "Repo: [$Repo]" +if (-not $Repo) { throw } + +Remove [org] alias on $organization parameter + +Rename $Repo to $Repository + +Add Alias Organization and User for $Owner prarm +Aliases, one pr line or one pr definition? + +Document: API Method is written in Sentencase/PascalCase, Post, Delete, Put, Get, etc. + +SupportsShouldProcess must not be on Get- functions + +Context Enterprise, Owner, Organization, ID, Repo Are mandatory in private functions + + +Parameters always have a [Parameter()] attribute +Parameters always define type, then a space to the value [string] $String +ID should be the main parameter name +Parameters, snake_case -> PascalCase + +Dont use DefaultParameterSet = '__AllParameterSets' + +Class every return to have an agreed interface +Remove API spefic properties + +Username alias is login + +All powershell keywords = lowercase + +Brace style: One True Bracing Style (OTBS) +https://en.wikipedia.org/wiki/Indentation_style + +Private functions do not take pipeline params +Private functions have no aliases, on functions or params + +We do really not have to have 100% API coverage... like Hovercards.. ? +convert all filter types to function type (we have begin, process, end) + +Parameter attribute order: +1. Parameter()] +Function attribute order: +y. [CmdletBinding()] +z. param() + + +Output to pipeline, select or foreach? +Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + +Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response + + +Rename APIEndpoint to Endpoint (maybe keep APIEndpoint as alias) + + +Remove if([string]IsNullOrEmpty()) + + +Add a file where we store endponits we do not wish to cover. Update the coverage report with ⚠️ + +Parameter name design: Assume there is an object that is processed. Not RepositoryID for a function that has repository in it. The value/name at hand is related to the object being processed. Object oriented naming. From d5a21b965c58208660368e816bb05e4c7313747c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 22:08:34 +0100 Subject: [PATCH 55/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Change=20`$Cont?= =?UTF-8?q?ext`=20parameter=20type=20from=20`GitHubContext`=20to=20`object?= =?UTF-8?q?`=20in=20multiple=20functions=20for=20improved=20flexibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../private/Actions/Get-GitHubWorkflowRunByRepo.ps1 | 2 +- .../Actions/Get-GitHubWorkflowRunByWorkflow.ps1 | 2 +- .../private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 | 2 +- .../Get-GitHubAppInstallationForAuthenticatedApp.ps1 | 2 +- .../Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 | 2 +- ...Get-GitHubEnterpriseOrganizationAppInstallation.ps1 | 2 +- .../Get-GitHubOrganizationAppInstallation.ps1 | 2 +- .../Install-GitHubAppOnEnterpriseOrganization.ps1 | 2 +- .../Uninstall-GitHubAppOnEnterpriseOrganization.ps1 | 2 +- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 | 2 +- .../Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 | 2 +- .../Get-GitHubAppWebhookDeliveryToRedeliver.ps1 | 2 +- .../private/Auth/Context/Set-GitHubContext.ps1 | 10 +++------- .../Test-GitHubAccessTokenRefreshRequired.ps1 | 2 +- .../Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 2 +- .../private/Gitignore/Get-GitHubGitignoreByName.ps1 | 2 +- .../private/Gitignore/Get-GitHubGitignoreList.ps1 | 2 +- .../private/License/Get-GitHubLicenseByName.ps1 | 2 +- .../private/License/Get-GitHubLicenseList.ps1 | 2 +- .../private/License/Get-GitHubRepositoryLicense.ps1 | 2 +- .../Blocking/Block-GitHubUserByOrganization.ps1 | 2 +- .../Blocking/Get-GitHubBlockedUserByOrganization.ps1 | 2 +- .../Blocking/Test-GitHubBlockedUserByOrganization.ps1 | 2 +- .../Blocking/Unblock-GitHubUserByOrganization.ps1 | 2 +- .../private/Organization/Get-GitHubAllOrganization.ps1 | 2 +- .../private/Organization/Get-GitHubMyOrganization.ps1 | 2 +- .../Organization/Get-GitHubOrganizationByName.ps1 | 2 +- .../Organization/Get-GitHubUserOrganization.ps1 | 2 +- .../Releases/Assets/Get-GitHubReleaseAssetByID.ps1 | 2 +- .../Assets/Get-GitHubReleaseAssetByReleaseID.ps1 | 2 +- .../private/Releases/Releases/Get-GitHubReleaseAll.ps1 | 2 +- .../Releases/Releases/Get-GitHubReleaseByID.ps1 | 2 +- .../Releases/Releases/Get-GitHubReleaseByTagName.ps1 | 2 +- .../Releases/Releases/Get-GitHubReleaseLatest.ps1 | 2 +- .../Autolinks/Get-GitHubRepositoryAutolinkById.ps1 | 2 +- .../Autolinks/Get-GitHubRepositoryAutolinkList.ps1 | 2 +- .../Repositories/Fork/New-GitHubRepositoryAsFork.ps1 | 2 +- .../Repositories/Get-GitHubMyRepositories.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryByName.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryListByID.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryListByOrg.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryListByUser.ps1 | 2 +- .../Repositories/New-GitHubRepositoryFromTemplate.ps1 | 2 +- .../Repositories/New-GitHubRepositoryOrg.ps1 | 2 +- .../Repositories/New-GitHubRepositoryUser.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRESTTeam.ps1 | 2 +- .../private/Teams/Get-GitHubRESTTeamByName.ps1 | 2 +- .../private/Teams/Get-GitHubRESTTeamListByOrg.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRepoTeam.ps1 | 2 +- src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 | 2 +- .../private/Teams/Get-GitHubTeamListByOrg.ps1 | 2 +- .../private/Users/Blocking/Block-GitHubUserByUser.ps1 | 2 +- .../Users/Blocking/Get-GitHubBlockedUserByUser.ps1 | 2 +- .../Users/Blocking/Test-GitHubBlockedUserByUser.ps1 | 2 +- .../Users/Blocking/Unblock-GitHubUserByUser.ps1 | 2 +- .../private/Users/Emails/Get-GitHubUserAllEmail.ps1 | 2 +- .../private/Users/Emails/Get-GitHubUserPublicEmail.ps1 | 2 +- .../Users/Followers/Get-GitHubUserFollowersOfUser.ps1 | 2 +- .../Users/Followers/Get-GitHubUserFollowingMe.ps1 | 2 +- .../Users/Followers/Get-GitHubUserFollowingUser.ps1 | 2 +- .../Users/Followers/Get-GitHubUserMyFollowers.ps1 | 2 +- .../Users/Followers/Test-GitHubUserFollowedByMe.ps1 | 2 +- .../Users/Followers/Test-GitHubUserFollowedByUser.ps1 | 2 +- .../Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 | 2 +- .../private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 | 2 +- .../Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 | 2 +- src/functions/private/Users/Get-GitHubAllUser.ps1 | 2 +- src/functions/private/Users/Get-GitHubMyUser.ps1 | 2 +- src/functions/private/Users/Get-GitHubUserByName.ps1 | 2 +- src/functions/private/Users/Get-GitHubUserCard.ps1 | 2 +- .../private/Users/Keys/Get-GitHubUserKeyForUser.ps1 | 2 +- .../private/Users/Keys/Get-GitHubUserMyKey.ps1 | 2 +- .../private/Users/Keys/Get-GitHubUserMyKeyById.ps1 | 2 +- .../SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 | 2 +- .../Get-GitHubUserMySigningKeyById.ps1 | 2 +- .../Get-GitHubUserSigningKeyForUser.ps1 | 2 +- .../Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 | 2 +- .../Social-Accounts/Get-GitHubUserSocialsByName.ps1 | 2 +- 78 files changed, 80 insertions(+), 84 deletions(-) diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 index 6597ed8aa..013824138 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 @@ -83,7 +83,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 index ac827cd0b..d1dbde61b 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByWorkflow.ps1 @@ -90,7 +90,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 index b421c91d1..1b3edac54 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 @@ -26,7 +26,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 3e966b2d9..6b701d68b 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -21,7 +21,7 @@ param( # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index c6c9a67af..780b0aada 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -25,7 +25,7 @@ param( # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index ad1c493dd..9458c8e2a 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -40,7 +40,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index 56ab2caf7..99dc2eea5 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -33,7 +33,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 index 12f7e356c..97ba02be6 100644 --- a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -38,7 +38,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index ae871c909..9a54a1eda 100644 --- a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -29,7 +29,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index 4244933f4..754242cea 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -28,7 +28,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 233cabd8c..2e1b05468 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -27,7 +27,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 index b9b532fe4..0b084c8ef 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryToRedeliver.ps1 @@ -25,7 +25,7 @@ # The context to run the command in. Used to get the details for the API call. [Parameter(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 index 6868442c4..60c829d4e 100644 --- a/src/functions/private/Auth/Context/Set-GitHubContext.ps1 +++ b/src/functions/private/Auth/Context/Set-GitHubContext.ps1 @@ -54,11 +54,7 @@ function Set-GitHubContext { Write-Debug "Getting info on the context [$($contextObj['AuthType'])]." switch -Regex (($contextObj['AuthType'])) { 'PAT|UAT|IAT' { - if ($_ -eq 'IAT') { - $viewer = Get-GitHubViewer -Context [InstallationGitHubContext]($contextObj) - } else { - $viewer = Get-GitHubViewer -Context [UserGitHubContext]($contextObj) - } + $viewer = Get-GitHubViewer -Context $contextObj $viewer | Out-String -Stream | ForEach-Object { Write-Debug $_ } if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) { $contextObj['DisplayName'] = [string]$viewer.name @@ -83,7 +79,7 @@ function Set-GitHubContext { $contextObj['Type'] = 'Installation' if ([string]::IsNullOrEmpty($contextObj['DisplayName'])) { try { - $app = Get-GitHubApp -Name $contextObj['Username'] -Context [InstallationGitHubContext]($contextObj) + $app = Get-GitHubApp -Name $contextObj['Username'] -Context $contextObj $contextObj['DisplayName'] = [string]$app.name } catch { Write-Debug "Failed to get the GitHub App with the slug: [$($contextObj['Username'])]." @@ -127,7 +123,7 @@ function Set-GitHubContext { } } 'App' { - $app = Get-GitHubApp -Context [AppGitHubContext]($contextObj) + $app = Get-GitHubApp -Context $contextObj $contextObj['Name'] = "$($contextObj['HostName'])/$($app.slug)" $contextObj['DisplayName'] = [string]$app.name $contextObj['Username'] = [string]$app.slug diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 index a6d022531..844398da7 100644 --- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 @@ -17,7 +17,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index a653ef76e..c3cd9a12d 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -28,7 +28,7 @@ # 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(Mandatory)] - [GitHubContext] $Context, + [object] $Context, # Return the new access token. [Parameter()] diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 index 1ce3f5f87..dc69d7627 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 @@ -24,7 +24,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index 27d493e75..b3230fd97 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -22,7 +22,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index 775d556ca..5c6b1b2a1 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -27,7 +27,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index 13fcd1839..1ada0eb20 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -23,7 +23,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index 1d7a4512d..91fab62a6 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -36,7 +36,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index e1bafcbdf..61107ab29 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -41,7 +41,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index e5671dce4..61470b46b 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -32,7 +32,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index 4c039d510..ffe2fc25b 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -40,7 +40,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index 2aa2ed4e6..988d824d9 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -41,7 +41,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index 13788020a..43b410332 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -34,7 +34,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index 2e7de44bc..6a7817b36 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -33,7 +33,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index b89e67ed8..40fc84ff1 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -39,7 +39,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index a60448efc..e51be1fda 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -35,7 +35,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index ba44d8793..ffd56af31 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -36,7 +36,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index c31fd7efa..c5b49372c 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -41,7 +41,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index c13b6de84..0407168c1 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -35,7 +35,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index 153908c37..a7ca3a32e 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -34,7 +34,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index 87cf0c065..ea447b8e0 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -33,7 +33,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index 2634dd5cd..478e8128d 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index a7469f229..da8d73721 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -37,7 +37,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index 4bca16a8c..0fed912df 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index 4ba5974b0..35bba9061 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -65,7 +65,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index 12c81202e..f1e964561 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -110,7 +110,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index 22aec464c..21c551c6c 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -33,7 +33,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index 04a904b5e..6effb2de6 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index 0c1ea9773..4e5add734 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -59,7 +59,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index 6f3930ef6..a8aa65066 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -61,7 +61,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index a00eae03e..bd0088220 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -75,7 +75,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 1304ffca0..40517dcab 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -184,7 +184,7 @@ filter New-GitHubRepositoryOrg { # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) dynamicparam { diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index 377b12622..7f200a2e7 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -178,7 +178,7 @@ filter New-GitHubRepositoryUser { # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) dynamicparam { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 index 1d5650e2c..807c25e3b 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeam.ps1 @@ -41,7 +41,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index 0a2e1b0a2..8edf2fdae 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -25,7 +25,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index bfbdfa6bd..5874a45ff 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -22,7 +22,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index 600ebd71f..44c4044c7 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -14,7 +14,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 index aa982f873..e54fe23c3 100644 --- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 @@ -26,7 +26,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 index 68800806b..54dc49035 100644 --- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 @@ -23,7 +23,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index 9c917a354..69b67ab2d 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index 72e0cfe8c..b2f2c2dab 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -25,7 +25,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index 0122933d7..55abe7880 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -37,7 +37,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index a6faaff90..2106321e5 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index ff42b473a..ce5a12a5e 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -27,7 +27,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index 678c218fa..8d30f8aa8 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -29,7 +29,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index ecd946e7c..c5421bb81 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -35,7 +35,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index 397c7cf5f..2b1e3648d 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -26,7 +26,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index 1dd8afb31..2f6a50199 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -35,7 +35,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index 112c6ce7c..2020f97d9 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index 83960bdd6..1c13e72cc 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index f577993f2..096ecfc0b 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -35,7 +35,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 index c13a4241c..5de1341f4 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 @@ -34,7 +34,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 index ad4d735c4..2ba32a3d6 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 @@ -28,7 +28,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 index cd66be651..762a06eb5 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 08c162cf6..90c9a84fa 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -34,7 +34,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1 index 93cc1a7f4..ac651d081 100644 --- a/src/functions/private/Users/Get-GitHubMyUser.ps1 +++ b/src/functions/private/Users/Get-GitHubMyUser.ps1 @@ -23,7 +23,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1 index 3a521812e..3aaa54162 100644 --- a/src/functions/private/Users/Get-GitHubUserByName.ps1 +++ b/src/functions/private/Users/Get-GitHubUserByName.ps1 @@ -41,7 +41,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 index 4bc77143e..e5804dd57 100644 --- a/src/functions/private/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/private/Users/Get-GitHubUserCard.ps1 @@ -42,7 +42,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 index 0dd50d01e..dca33a90e 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 @@ -34,7 +34,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 index 5d3d92fcc..f062bdba7 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 @@ -28,7 +28,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 index fe526f254..f905f5a95 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 @@ -30,7 +30,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { 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 a82601dd5..17b29af8f 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 @@ -28,7 +28,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { 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 3a3337488..029be0952 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 @@ -31,7 +31,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { 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 5e2d1af49..49f29c23f 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 @@ -34,7 +34,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 index 9b5effa17..b26950bcd 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 @@ -26,7 +26,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 index 2182c1eae..dcfa7a5ce 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 @@ -29,7 +29,7 @@ # 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(Mandatory)] - [GitHubContext] $Context + [object] $Context ) begin { From 34ac1ee7e16ca0c5d15d3e1b52b851b222120214 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 22:23:33 +0100 Subject: [PATCH 56/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Correct=20forma?= =?UTF-8?q?tting=20and=20style=20guidelines=20in=20Guidelines.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/Guidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/Guidelines.md b/tools/Guidelines.md index 04abc6746..24eeba15b 100644 --- a/tools/Guidelines.md +++ b/tools/Guidelines.md @@ -157,10 +157,10 @@ Remove API spefic properties Username alias is login -All powershell keywords = lowercase +All PowerShell keywords = lowercase Brace style: One True Bracing Style (OTBS) -https://en.wikipedia.org/wiki/Indentation_style + Private functions do not take pipeline params Private functions have no aliases, on functions or params From 73cc3409e99178fcded3270cfc56dea64b5b2313 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 22:40:11 +0100 Subject: [PATCH 57/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20Repo?= =?UTF-8?q?=20parameter=20to=20Repository=20for=20clarity=20in=20GitHubCon?= =?UTF-8?q?text.ps1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/Context/GitHubContext.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classes/public/Context/GitHubContext.ps1 b/src/classes/public/Context/GitHubContext.ps1 index 8d54ac1b9..cc930e252 100644 --- a/src/classes/public/Context/GitHubContext.ps1 +++ b/src/classes/public/Context/GitHubContext.ps1 @@ -53,8 +53,8 @@ # The default value for the Owner parameter. [string] $Owner - # The default value for the Repo parameter. - [string] $Repo + # The default value for the Repository parameter. + [string] $Repository # The default value for the HTTP protocol version. [string] $HttpVersion From b5ed26d09921b4e28b98c13a6d3c99ad0f82b674 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 4 Feb 2025 23:14:05 +0100 Subject: [PATCH 58/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Cmdlet?= =?UTF-8?q?Binding=20in=20Get-GitHubContext=20and=20simplify=20aliases=20i?= =?UTF-8?q?n=20Disconnect-GitHubAccount=20for=20improved=20clarity=20and?= =?UTF-8?q?=20usability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/Auth/Context/Get-GitHubContext.ps1 | 2 +- .../public/Auth/Disconnect-GitHubAccount.ps1 | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/functions/public/Auth/Context/Get-GitHubContext.ps1 b/src/functions/public/Auth/Context/Get-GitHubContext.ps1 index ea5817fbf..675e562e9 100644 --- a/src/functions/public/Auth/Context/Get-GitHubContext.ps1 +++ b/src/functions/public/Auth/Context/Get-GitHubContext.ps1 @@ -18,7 +18,7 @@ function Get-GitHubContext { Justification = 'Encapsulated in a function. Never leaves as a plain text.' )] [OutputType([GitHubContext])] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The name of the context. [Parameter( diff --git a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 index d1c60a388..bbc702de2 100644 --- a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 @@ -16,19 +16,7 @@ Disconnects from GitHub and removes the context 'github.com/Octocat'. #> - [Alias( - 'Disconnect-GHAccount', - 'Disconnect-GitHub', - 'Disconnect-GH', - 'Logout-GitHubAccount', - 'Logout-GHAccount', - 'Logout-GitHub', - 'Logout-GH', - 'Logoff-GitHubAccount', - 'Logoff-GHAccount', - 'Logoff-GitHub', - 'Logoff-GH' - )] + [Alias('Disconnect-GitHub')] [OutputType([void])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] [CmdletBinding()] @@ -36,8 +24,6 @@ # Suppresses the output of the function. [Parameter()] [Alias('Quiet')] - [Alias('q')] - [Alias('s')] [switch] $Silent, # The context to run the command with. From 5985748b5da8b75dc59b8a2455890bb49853e4e3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 00:09:52 +0100 Subject: [PATCH 59/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Get-Gi?= =?UTF-8?q?tHubApp=20to=20use=20'Name'=20parameter=20instead=20of=20'AppSl?= =?UTF-8?q?ug'=20for=20improved=20clarity=20and=20set=20default=20paramete?= =?UTF-8?q?r=20set=20for=20CmdletBinding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 index 16a1d51c4..560050122 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 @@ -12,7 +12,7 @@ Get the authenticated app. .EXAMPLE - Get-GitHubApp -AppSlug 'github-actions' + Get-GitHubApp -Name 'github-actions' Get the GitHub App with the slug 'github-actions'. @@ -21,7 +21,7 @@ [Get the authenticated app | GitHub Docs](https://docs.github.com/rest/apps/apps#get-the-authenticated-app) #> [OutputType([pscustomobject])] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The AppSlug is just the URL-friendly name of a GitHub App. # You can find this on the settings page for your GitHub App (e.g., ). From 80891ba6614c36e415525c96ab5499b3843ad7a4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 01:00:03 +0100 Subject: [PATCH 60/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Cmdlet?= =?UTF-8?q?Binding=20in=20multiple=20functions=20to=20set=20default=20para?= =?UTF-8?q?meter=20set=20for=20improved=20consistency=20and=20usability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Get-GitHubReleaseAssetByReleaseID.ps1 | 4 +-- .../Releases/Get-GitHubReleaseAll.ps1 | 4 +-- .../Workflow Run/Get-GitHubWorkflowRun.ps1 | 4 +-- .../Get-GitHubAppInstallation.ps1 | 4 +-- .../Apps/GitHub App/Install-GitHubApp.ps1 | 4 +-- .../Apps/GitHub App/Uninstall-GitHubApp.ps1 | 4 +-- .../public/Auth/Connect-GitHubApp.ps1 | 4 +-- .../Assets/Get-GitHubReleaseAsset.ps1 | 4 +-- .../Get-GitHubRepositoryAutolink.ps1 | 4 +-- .../Get-GitHubRepositoryActivity.ps1 | 4 +-- .../Get-GitHubRepositoryRuleSuite.ps1 | 4 +-- src/functions/public/Teams/Get-GitHubTeam.ps1 | 27 +++++++++---------- .../Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 | 22 +++++++-------- .../public/Users/Keys/Get-GitHubUserKey.ps1 | 22 +++++++-------- .../Get-GitHubUserSigningKey.ps1 | 22 +++++++-------- 15 files changed, 64 insertions(+), 73 deletions(-) diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index c5b49372c..11a5ad5fc 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAssetByReleaseID { +filter Get-GitHubReleaseAssetByReleaseID { <# .SYNOPSIS List release assets @@ -15,7 +15,7 @@ https://docs.github.com/rest/releases/assets#list-release-assets #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index 0407168c1..194379757 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAll { +filter Get-GitHubReleaseAll { <# .SYNOPSIS List releases @@ -17,7 +17,7 @@ https://docs.github.com/rest/releases/releases#list-releases #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] diff --git a/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 index 55b252dce..db2ec08a2 100644 --- a/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubWorkflowRun { +filter Get-GitHubWorkflowRun { <# .SYNOPSIS List workflow runs for a repository or a workflow @@ -36,7 +36,7 @@ [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()] + [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.')] diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 index 2d0a881fd..f95ff1b71 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubAppInstallation { +function Get-GitHubAppInstallation { <# .SYNOPSIS List installations for the authenticated app, on organization or enterprise organization. @@ -8,7 +8,7 @@ If the app is installed on an enterprise, the installations for the enterprise are returned. If the app is installed on an organization, the installations for the organization are returned. #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The enterprise slug or ID. [Parameter( diff --git a/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 index 6ff054ae7..8c9089b9b 100644 --- a/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 @@ -1,4 +1,4 @@ -function Install-GitHubApp { +function Install-GitHubApp { <# .SYNOPSIS Install an app @@ -23,7 +23,7 @@ - the repository selection 'all' on the organization 'org' in the enterprise 'msx'. #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The enterprise slug or ID. [Parameter( diff --git a/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 index 48bc964f1..18f286e66 100644 --- a/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 @@ -1,4 +1,4 @@ -function Uninstall-GitHubApp { +function Uninstall-GitHubApp { <# .SYNOPSIS Uninstall a GitHub App. @@ -11,7 +11,7 @@ Uninstall the GitHub App with the installation ID '123456' from the organization 'org' in the enterprise 'msx'. #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The enterprise slug or ID. [Parameter( diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index 242ecc6dc..aca42c9ec 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -1,4 +1,4 @@ -function Connect-GitHubApp { +function Connect-GitHubApp { <# .SYNOPSIS Connects to GitHub as a installation using a GitHub App. @@ -38,7 +38,7 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'The tokens are recieved as clear text. Mitigating exposure by removing variables and performing garbage collection.')] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The user account to connect to. [Parameter(ParameterSetName = 'Filtered')] diff --git a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 index 627d64498..c8f3b4a1c 100644 --- a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAsset { +filter Get-GitHubReleaseAsset { <# .SYNOPSIS List release assets based on a release ID or asset ID @@ -20,7 +20,7 @@ .NOTES [Get a release asset](https://docs.github.com/rest/releases/assets#get-a-release-asset) #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 index b4c77ab70..92d6cf7f6 100644 --- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryAutolink { +filter Get-GitHubRepositoryAutolink { <# .SYNOPSIS List all autolinks of a repository @@ -22,7 +22,7 @@ [Get all autolinks of a repository](https://docs.github.com/rest/repos/autolinks#list-all-autolinks-of-a-repository) #> [Alias('Get-GitHubRepositoryAutolinks')] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index 7c7e346e0..bb822c968 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryActivity { +filter Get-GitHubRepositoryActivity { <# .SYNOPSIS List repository activities @@ -48,7 +48,7 @@ .NOTES [List repository activities](https://docs.github.com/rest/repos/repos#list-repository-activities) #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 index f9a14ed0e..f5371f821 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryRuleSuite { +filter Get-GitHubRepositoryRuleSuite { <# .SYNOPSIS List repository rule suites or a rule suite by ID. @@ -32,7 +32,7 @@ #> [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The account owner of the repository. The name is not case sensitive. [Parameter()] diff --git a/src/functions/public/Teams/Get-GitHubTeam.ps1 b/src/functions/public/Teams/Get-GitHubTeam.ps1 index eaaec36b0..8fa46f9e8 100644 --- a/src/functions/public/Teams/Get-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Get-GitHubTeam.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeam { +function Get-GitHubTeam { <# .SYNOPSIS List teams from an org or get a team by name @@ -19,7 +19,7 @@ Gets the team with the slug 'my-team-name' in the `github` organization. #> [OutputType([GitHubTeam])] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The slug of the team name. [Parameter( @@ -54,21 +54,17 @@ } process { - try { - $params = @{ - Organization = $Organization - Context = $Context + $params = @{ + Organization = $Organization + Context = $Context + } + switch ($PSCmdlet.ParameterSetName) { + 'BySlug' { + Get-GitHubTeamBySlug @params -Slug $Slug } - switch ($PSCmdlet.ParameterSetName) { - 'BySlug' { - Get-GitHubTeamBySlug @params -Slug $Slug - } - default { - Get-GitHubTeamListByOrg @params - } + default { + Get-GitHubTeamListByOrg @params } - } catch { - throw $_ } } @@ -78,3 +74,4 @@ } #SkipTest:FunctionTest:Will add a test for this function in a future PR + diff --git a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 index 6ae2abc8c..84053f5de 100644 --- a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserGpgKey { +filter Get-GitHubUserGpgKey { <# .SYNOPSIS List GPG keys for a given user or the authenticated user @@ -25,7 +25,7 @@ [List GPG keys for the authenticated user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user) #> [OutputType([pscustomobject])] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The handle for the GitHub user account. [Parameter( @@ -62,18 +62,16 @@ } process { - try { - if ($Username) { + switch ($PSCmdlet.ParameterSetName) { + '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 $_ + 'Me' { + Get-GitHubUserMyGpgKeyById -ID $ID -Context $Context + } + default { + Get-GitHubUserMyGpgKey -PerPage $PerPage -Context $Context + } } } diff --git a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 index f339c742b..bf3d452eb 100644 --- a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserKey { +filter Get-GitHubUserKey { <# .SYNOPSIS List public SSH keys for a given user or the authenticated user. @@ -28,7 +28,7 @@ [List GPG keys for the authenticated user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user) #> [OutputType([pscustomobject])] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The handle for the GitHub user account. [Parameter( @@ -65,18 +65,16 @@ } process { - try { - if ($Username) { + switch ($PSCmdlet.ParameterSetName) { + '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 $_ + 'Me' { + Get-GitHubUserMyKeyById -ID $ID -Context $Context + } + default { + Get-GitHubUserMyKey -PerPage $PerPage -Context $Context + } } } 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 3d3418627..0b74c35fe 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserSigningKey { +filter Get-GitHubUserSigningKey { <# .SYNOPSIS List SSH signing keys for a given user or the authenticated user. @@ -28,7 +28,7 @@ #> [OutputType([pscustomobject])] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')] - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The handle for the GitHub user account. [Parameter( @@ -65,18 +65,16 @@ } process { - try { - if ($Username) { + switch ($PSCmdlet.ParameterSetName) { + '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 $_ + 'Me' { + Get-GitHubUserMySigningKeyById -ID $ID -Context $Context + } + default { + Get-GitHubUserMySigningKey -PerPage $PerPage -Context $Context + } } } From 6b3ca28b107583d5012f6d3ba41d8201301c0bfd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 01:10:14 +0100 Subject: [PATCH 61/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20module=20?= =?UTF-8?q?requirement=20for=20'Context'=20in=20Update-GitHubUserAccessTok?= =?UTF-8?q?en=20and=20fix=20formatting=20issues=20in=20multiple=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 | 1 + .../Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 | 2 +- .../private/Releases/Releases/Get-GitHubReleaseAll.ps1 | 2 +- .../public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 | 2 +- .../GitHub App Installations/Get-GitHubAppInstallation.ps1 | 2 +- src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 | 2 +- src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 | 2 +- src/functions/public/Auth/Connect-GitHubApp.ps1 | 2 +- .../public/Releases/Assets/Get-GitHubReleaseAsset.ps1 | 2 +- .../Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 | 2 +- .../Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 | 2 +- src/functions/public/Teams/Get-GitHubTeam.ps1 | 3 +-- src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 | 2 +- src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 | 2 +- .../public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index c3cd9a12d..347c54bdf 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -101,3 +101,4 @@ Write-Debug "[$stackPath] - End" } } +#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '6.0.0' } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 11a5ad5fc..4c3e63257 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAssetByReleaseID { +filter Get-GitHubReleaseAssetByReleaseID { <# .SYNOPSIS List release assets diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index 194379757..834416933 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAll { +filter Get-GitHubReleaseAll { <# .SYNOPSIS List releases diff --git a/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 index db2ec08a2..53885a2c5 100644 --- a/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Get-GitHubWorkflowRun.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubWorkflowRun { +filter Get-GitHubWorkflowRun { <# .SYNOPSIS List workflow runs for a repository or a workflow diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 index f95ff1b71..645e4b3d0 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallation.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubAppInstallation { +function Get-GitHubAppInstallation { <# .SYNOPSIS List installations for the authenticated app, on organization or enterprise organization. diff --git a/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 index 8c9089b9b..5eae6b157 100644 --- a/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Install-GitHubApp.ps1 @@ -1,4 +1,4 @@ -function Install-GitHubApp { +function Install-GitHubApp { <# .SYNOPSIS Install an app diff --git a/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 index 18f286e66..7d2124e74 100644 --- a/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Uninstall-GitHubApp.ps1 @@ -1,4 +1,4 @@ -function Uninstall-GitHubApp { +function Uninstall-GitHubApp { <# .SYNOPSIS Uninstall a GitHub App. diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index aca42c9ec..c0a89cf53 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -1,4 +1,4 @@ -function Connect-GitHubApp { +function Connect-GitHubApp { <# .SYNOPSIS Connects to GitHub as a installation using a GitHub App. diff --git a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 index c8f3b4a1c..5106d462b 100644 --- a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubReleaseAsset { +filter Get-GitHubReleaseAsset { <# .SYNOPSIS List release assets based on a release ID or asset ID diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 index 92d6cf7f6..fde361916 100644 --- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryAutolink { +filter Get-GitHubRepositoryAutolink { <# .SYNOPSIS List all autolinks of a repository diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index bb822c968..3c325fe1d 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryActivity { +filter Get-GitHubRepositoryActivity { <# .SYNOPSIS List repository activities diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 index f5371f821..a3a7214cb 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubRepositoryRuleSuite { +filter Get-GitHubRepositoryRuleSuite { <# .SYNOPSIS List repository rule suites or a rule suite by ID. diff --git a/src/functions/public/Teams/Get-GitHubTeam.ps1 b/src/functions/public/Teams/Get-GitHubTeam.ps1 index 8fa46f9e8..b8a87dca8 100644 --- a/src/functions/public/Teams/Get-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Get-GitHubTeam.ps1 @@ -1,4 +1,4 @@ -function Get-GitHubTeam { +function Get-GitHubTeam { <# .SYNOPSIS List teams from an org or get a team by name @@ -74,4 +74,3 @@ function Get-GitHubTeam { } #SkipTest:FunctionTest:Will add a test for this function in a future PR - diff --git a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 index 84053f5de..8887e7599 100644 --- a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserGpgKey { +filter Get-GitHubUserGpgKey { <# .SYNOPSIS List GPG keys for a given user or the authenticated user diff --git a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 index bf3d452eb..cb0d4e6cd 100644 --- a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserKey { +filter Get-GitHubUserKey { <# .SYNOPSIS List public SSH keys for a given user or the authenticated user. 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 0b74c35fe..afb7d54db 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 @@ -1,4 +1,4 @@ -filter Get-GitHubUserSigningKey { +filter Get-GitHubUserSigningKey { <# .SYNOPSIS List SSH signing keys for a given user or the authenticated user. From 7e973bb537b879b739675620e5b92dc0eafe4225 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 01:58:21 +0100 Subject: [PATCH 62/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20'Desti?= =?UTF-8?q?nation'=20parameter=20to=20'Path'=20in=20Get-GitHubEmoji=20for?= =?UTF-8?q?=20clarity=20and=20update=20related=20examples=20and=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/Emojis/Get-GitHubEmoji.ps1 | 54 ++++++++++--------- tests/GitHub.Tests.ps1 | 18 +++---- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 index 04006591b..4c6146a96 100644 --- a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 +++ b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 @@ -5,7 +5,7 @@ .DESCRIPTION Lists all the emojis available to use on GitHub. - If you pass the `Destination` parameter, the emojis will be downloaded to the specified destination. + If you pass the `Path` parameter, the emojis will be downloaded to the specified destination. .EXAMPLE Get-GitHubEmoji @@ -13,18 +13,21 @@ Gets all the emojis available to use on GitHub. .EXAMPLE - Get-GitHubEmoji -Destination 'C:\Users\user\Documents\GitHub\Emojis' + Get-GitHubEmoji -Path 'C:\Users\user\Documents\GitHub\Emojis' Downloads all the emojis available to use on GitHub to the specified destination. .NOTES [Get emojis](https://docs.github.com/rest/reference/emojis#get-emojis) #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The path to the directory where the emojis will be downloaded. - [Parameter()] - [string] $Destination, + [Parameter( + Mandatory, + ParameterSetName = 'Download' + )] + [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. @@ -48,26 +51,29 @@ $response = Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response - if (-not $Destination) { - $response - } - - $failedEmojis = @() - if (-not (Test-Path -Path $Destination)) { - $null = New-Item -Path $Destination -ItemType Directory -Force - } - $failedEmojis = $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel { - $emoji = $_ - Write-Verbose "Downloading [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" - try { - Invoke-WebRequest -Uri $emoji.Value -OutFile "$using:Destination/$($emoji.Name).png" -RetryIntervalSec 1 -MaximumRetryCount 5 - } catch { - Write-Warning "Could not download [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Destination/$($emoji.Name).png]" + switch ($PSCmdlet.ParameterSetName) { + 'Download' { + $failedEmojis = @() + if (-not (Test-Path -Path $Path)) { + $null = New-Item -Path $Path -ItemType Directory -Force + } + $failedEmojis = $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel { + $emoji = $_ + Write-Verbose "Downloading [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Path/$($emoji.Name).png]" + try { + Invoke-WebRequest -Uri $emoji.Value -OutFile "$using:Path/$($emoji.Name).png" -RetryIntervalSec 1 -MaximumRetryCount 5 + } catch { + Write-Warning "Could not download [$($emoji.Name).png] from [$($emoji.Value)] -> [$using:Path/$($emoji.Name).png]" + } + } + if ($failedEmojis.Count -gt 0) { + Write-Warning 'Failed to download the following emojis:' + $failedEmojis | Out-String -Stream | ForEach-Object { Write-Warning $_ } + } + } + default { + $response } - } - if ($failedEmojis.Count -gt 0) { - Write-Warning 'Failed to download the following emojis:' - $failedEmojis | Out-String -Stream | ForEach-Object { Write-Warning $_ } } } diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 54f287d12..930321c45 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -502,7 +502,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) $user = Get-GitHubUser { Update-GitHubUser -Name 'Octocat' } | Should -Not -Throw { Update-GitHubUser -Blog 'https://psmodule.io' } | Should -Not -Throw - { Update-GitHubUser -TwitterUsername $guid } | Should -Not -Throw + { Update-GitHubUser -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubUser -Company 'PSModule' } | Should -Not -Throw { Update-GitHubUser -Location 'USA' } | Should -Not -Throw { Update-GitHubUser -Bio 'I love programming' } | Should -Not -Throw @@ -520,9 +520,9 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) } It 'Add/Remove-GitHubUserEmail - Adds and removes an email to the authenticated user (USER_FG_PAT)' { $email = (New-Guid).Guid + '@psmodule.io' - { Add-GitHubUserEmail -Emails $email } | Should -Not -Throw + { Add-GitHubUserEmail -Email $email } | Should -Not -Throw (Get-GitHubUserEmail).email | Should -Contain $email - { Remove-GitHubUserEmail -Emails $email } | Should -Not -Throw + { Remove-GitHubUserEmail -Email $email } | Should -Not -Throw (Get-GitHubUserEmail).email | Should -Not -Contain $email } } @@ -681,7 +681,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ } | Should -Not -Throw { $guid = (New-Guid).Guid - Update-GitHubOrganization -Organization 'psmodule-test-org2' -TwitterUsername $guid + Update-GitHubOrganization -Organization 'psmodule-test-org2' -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org2' -Location 'USA' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org2' -Description 'Test Organization' } | Should -Not -Throw @@ -819,7 +819,7 @@ Describe 'As a user - Classic PAT token (PAT)' { $user = Get-GitHubUser { Update-GitHubUser -Name 'Octocat' } | Should -Not -Throw { Update-GitHubUser -Blog 'https://psmodule.io' } | Should -Not -Throw - { Update-GitHubUser -TwitterUsername $guid } | Should -Not -Throw + { Update-GitHubUser -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubUser -Company 'PSModule' } | Should -Not -Throw { Update-GitHubUser -Location 'USA' } | Should -Not -Throw { Update-GitHubUser -Bio 'I love programming' } | Should -Not -Throw @@ -837,9 +837,9 @@ Describe 'As a user - Classic PAT token (PAT)' { } It 'Add/Remove-GitHubUserEmail - Adds and removes an email to the authenticated user (PAT)' { $email = (New-Guid).Guid + '@psmodule.io' - { Add-GitHubUserEmail -Emails $email } | Should -Not -Throw + { Add-GitHubUserEmail -Email $email } | Should -Not -Throw (Get-GitHubUserEmail).email | Should -Contain $email - { Remove-GitHubUserEmail -Emails $email } | Should -Not -Throw + { Remove-GitHubUserEmail -Email $email } | Should -Not -Throw (Get-GitHubUserEmail).email | Should -Not -Contain $email } } @@ -1054,7 +1054,7 @@ Describe 'As a GitHub App - Enterprise (APP_ENT)' { } | Should -Not -Throw { $guid = (New-Guid).Guid - Update-GitHubOrganization -Organization 'psmodule-test-org3' -TwitterUsername $guid + Update-GitHubOrganization -Organization 'psmodule-test-org3' -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org3' -Location 'USA' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org3' -Description 'Test Organization' } | Should -Not -Throw @@ -1174,7 +1174,7 @@ Describe 'As a GitHub App - Organization (APP_ORG)' { } | Should -Not -Throw { $guid = (New-Guid).Guid - Update-GitHubOrganization -Organization 'psmodule-test-org' -TwitterUsername $guid + Update-GitHubOrganization -Organization 'psmodule-test-org' -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org' -Location 'USA' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org' -Description 'Test Organization' } | Should -Not -Throw From 1e1a445a29bbeb5e6283c935b6427cfbd687e83b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 02:47:11 +0100 Subject: [PATCH 63/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20exampl?= =?UTF-8?q?es=20and=20tests=20to=20replace=20'Destination'=20parameter=20w?= =?UTF-8?q?ith=20'Path'=20in=20Get-GitHubEmoji=20for=20improved=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/Apps/AppManagement.ps1 | 6 ++---- examples/Apps/EnterpriseApps.ps1 | 6 ++---- examples/Teams/Get-AllTeams.ps1 | 0 tests/GitHub.Tests.ps1 | 8 ++++---- 4 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 examples/Teams/Get-AllTeams.ps1 diff --git a/examples/Apps/AppManagement.ps1 b/examples/Apps/AppManagement.ps1 index 1166429a2..3b9e935fc 100644 --- a/examples/Apps/AppManagement.ps1 +++ b/examples/Apps/AppManagement.ps1 @@ -1,10 +1,8 @@ -#Requires -Modules @{ ModuleName = 'GitHub'; RequiredVersion = '0.13.2' } - -# Install an app on the entire enterprise +# Install an app on the entire enterprise $appIDs = @( 'Iv1.f26b61bc99e69405' ) -$orgs = Get-GitHubEnterpriseInstallableOrganization -Enterprise 'msx' +$orgs = Get-GitHubAppInstallableOrganization -Enterprise 'msx' #FIXME: Add '#Requires -Modules' for [Get-GitHubEnterpriseInstallableOrganization] Suggestions: GitHub foreach ($org in $orgs) { foreach ($appID in $appIDs) { Install-GitHubAppOnEnterpriseOrganization -Enterprise msx -Organization $org.login -ClientID $appID -RepositorySelection all diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 index 3e56150a3..5c629994a 100644 --- a/examples/Apps/EnterpriseApps.ps1 +++ b/examples/Apps/EnterpriseApps.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules @{ ModuleName = 'GitHub'; RequiredVersion = '0.13.2' } - -$appIDs = @( +$appIDs = @( 'qweqweqwe', 'qweqweqweqwe' ) @@ -26,7 +24,7 @@ filter Install-GithubApp { } process { - $installableOrgs = Get-GitHubEnterpriseInstallableOrganization -Enterprise $Enterprise -Debug -Verbose + $installableOrgs = Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Debug -Verbose #FIXME: Add '#Requires -Modules' for [Get-GitHubEnterpriseInstallableOrganization] Suggestions: GitHub $orgs = $installableOrgs | Where-Object { $_.login -like $organization } foreach ($org in $orgs) { foreach ($appIDitem in $AppID) { diff --git a/examples/Teams/Get-AllTeams.ps1 b/examples/Teams/Get-AllTeams.ps1 deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 930321c45..00ce930da 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -448,7 +448,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) { Get-GitHubEmoji } | Should -Not -Throw } It 'Get-GitHubEmoji - Downloads all emojis (USER_FG_PAT)' { - { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw + { Get-GitHubEmoji -Path $Home } | Should -Not -Throw } } Context 'Repository' { @@ -605,7 +605,7 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ { Get-GitHubEmoji } | Should -Not -Throw } It 'Get-GitHubEmoji - Downloads all emojis (ORG_FG_PAT)' { - { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw + { Get-GitHubEmoji -Path $Home } | Should -Not -Throw } } Context 'Repository' { @@ -785,7 +785,7 @@ Describe 'As a user - Classic PAT token (PAT)' { { Get-GitHubEmoji } | Should -Not -Throw } It 'Get-GitHubEmoji - Downloads all emojis (PAT)' { - { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw + { Get-GitHubEmoji -Path $Home } | Should -Not -Throw } } Context 'GitIgnore' { @@ -964,7 +964,7 @@ Describe 'As GitHub Actions (GHA)' { { Get-GitHubEmoji } | Should -Not -Throw } It 'Get-GitHubEmoji - Downloads all emojis (GHA)' { - { Get-GitHubEmoji -Destination $Home } | Should -Not -Throw + { Get-GitHubEmoji -Path $Home } | Should -Not -Throw } } Context 'GitIgnore' { From f52d91013127844e54100bc2f9faa2b46c88e424 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 02:54:50 +0100 Subject: [PATCH 64/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20tests?= =?UTF-8?q?=20to=20replace=20usage=20of=20'guid'=20variable=20with=20stati?= =?UTF-8?q?c=20'PSModule'=20value=20for=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/GitHub.Tests.ps1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/GitHub.Tests.ps1 b/tests/GitHub.Tests.ps1 index 00ce930da..5fa4a693b 100644 --- a/tests/GitHub.Tests.ps1 +++ b/tests/GitHub.Tests.ps1 @@ -509,7 +509,7 @@ Describe 'As a user - Fine-grained PAT token - user account access (USER_FG_PAT) $tmpUser = Get-GitHubUser $tmpUser.name | Should -Be 'Octocat' $tmpUser.blog | Should -Be 'https://psmodule.io' - $tmpUser.twitter_username | Should -Be $guid + $tmpUser.twitter_username | Should -Be 'PSModule' $tmpUser.company | Should -Be 'PSModule' $tmpUser.location | Should -Be 'USA' $tmpUser.bio | Should -Be 'I love programming' @@ -680,7 +680,6 @@ Describe 'As a user - Fine-grained PAT token - organization account access (ORG_ Update-GitHubOrganization -Organization 'psmodule-test-org2' -Email $email } | Should -Not -Throw { - $guid = (New-Guid).Guid Update-GitHubOrganization -Organization 'psmodule-test-org2' -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org2' -Location 'USA' } | Should -Not -Throw @@ -826,7 +825,7 @@ Describe 'As a user - Classic PAT token (PAT)' { $tmpUser = Get-GitHubUser $tmpUser.name | Should -Be 'Octocat' $tmpUser.blog | Should -Be 'https://psmodule.io' - $tmpUser.twitter_username | Should -Be $guid + $tmpUser.twitter_username | Should -Be 'PSModule' $tmpUser.company | Should -Be 'PSModule' $tmpUser.location | Should -Be 'USA' $tmpUser.bio | Should -Be 'I love programming' @@ -1053,7 +1052,6 @@ Describe 'As a GitHub App - Enterprise (APP_ENT)' { Update-GitHubOrganization -Organization 'psmodule-test-org3' -Email $email } | Should -Not -Throw { - $guid = (New-Guid).Guid Update-GitHubOrganization -Organization 'psmodule-test-org3' -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org3' -Location 'USA' } | Should -Not -Throw @@ -1173,7 +1171,6 @@ Describe 'As a GitHub App - Organization (APP_ORG)' { Update-GitHubOrganization -Organization 'psmodule-test-org' -Email $email } | Should -Not -Throw { - $guid = (New-Guid).Guid Update-GitHubOrganization -Organization 'psmodule-test-org' -TwitterUsername 'PSModule' } | Should -Not -Throw { Update-GitHubOrganization -Organization 'psmodule-test-org' -Location 'USA' } | Should -Not -Throw From 96bf7f93019daf2711a9f0d5199237f7a4028d3c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 09:46:44 +0100 Subject: [PATCH 65/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Simplify=20erro?= =?UTF-8?q?r=20handling=20in=20multiple=20functions=20by=20removing=20try-?= =?UTF-8?q?catch=20blocks=20and=20directly=20processing=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/GitHub Apps/Get-GitHubAppByName.ps1 | 20 ++-- ...tHubAppInstallationForAuthenticatedApp.ps1 | 20 ++-- .../Commands/ConvertTo-GitHubOutput.ps1 | 62 ++++++------- .../Config/Initialize-GitHubConfig.ps1 | 45 ++++----- .../private/Teams/Get-GitHubTeamBySlug.ps1 | 66 +++++++------ .../private/Teams/Get-GitHubTeamListByOrg.ps1 | 80 ++++++++-------- .../Hashtable/ConvertFrom-HashTable.ps1 | 6 +- .../Hashtable/ConvertTo-HashTable.ps1 | 12 +-- .../Utilities/Hashtable/Join-Object.ps1 | 33 +++---- .../Hashtable/Remove-HashtableEntry.ps1 | 52 +++++------ tools/utilities/GetFunctionChanges.ps1 | 33 +++++++ .../GetFunctionMissingDefaultParamSet.ps1 | 92 +++++++++++++++++++ 12 files changed, 302 insertions(+), 219 deletions(-) create mode 100644 tools/utilities/GetFunctionChanges.ps1 create mode 100644 tools/utilities/GetFunctionMissingDefaultParamSet.ps1 diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 index 1b3edac54..c6e9d0f0e 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 @@ -36,18 +36,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = "/apps/$AppSlug" - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Context = $Context + APIEndpoint = "/apps/$AppSlug" + Method = 'GET' + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } end { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 index 6b701d68b..43f409f6c 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallationForAuthenticatedApp.ps1 @@ -31,18 +31,14 @@ } process { - try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/installations' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - } catch { - throw $_ + $inputObject = @{ + Context = $Context + APIEndpoint = '/app/installations' + Method = 'GET' + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response } } diff --git a/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1 b/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1 index 2d78140d7..39877374a 100644 --- a/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1 +++ b/src/functions/private/Commands/ConvertTo-GitHubOutput.ps1 @@ -52,46 +52,42 @@ } process { - try { - $outputLines = @() + $outputLines = @() - Write-Debug "Input object type: $($InputObject.GetType().Name)" - Write-Debug "Input object value:" - Write-Debug ($InputObject | Out-String) - - if ($InputObject -is [hashtable]) { - $InputObject = [PSCustomObject]$InputObject - } + Write-Debug "Input object type: $($InputObject.GetType().Name)" + Write-Debug 'Input object value:' + Write-Debug ($InputObject | Out-String) - foreach ($property in $InputObject.PSObject.Properties) { - $key = $property.Name - $value = $property.Value + if ($InputObject -is [hashtable]) { + $InputObject = [PSCustomObject]$InputObject + } - Write-Debug "Processing property: $key" - Write-Debug "Property value type: $($value.GetType().Name)" - Write-Debug "Property value:" - Write-Debug ($InputObject | Out-String) + foreach ($property in $InputObject.PSObject.Properties) { + $key = $property.Name + $value = $property.Value - # Convert hashtable or PSCustomObject to compressed JSON - if ($value -is [hashtable] -or $value -is [PSCustomObject]) { - Write-Debug "Converting property value to JSON" - $value = $value | ConvertTo-Json -Compress -Depth 100 - Write-Debug 'Property value:' - Write-Debug $value - } + Write-Debug "Processing property: $key" + Write-Debug "Property value type: $($value.GetType().Name)" + Write-Debug 'Property value:' + Write-Debug ($InputObject | Out-String) - $guid = [Guid]::NewGuid().ToString() - $EOFMarker = "EOF_$guid" - $outputLines += "$key<<$EOFMarker" - $outputLines += $value - $outputLines += $EOFMarker + # Convert hashtable or PSCustomObject to compressed JSON + if ($value -is [hashtable] -or $value -is [PSCustomObject]) { + Write-Debug 'Converting property value to JSON' + $value = $value | ConvertTo-Json -Compress -Depth 100 + Write-Debug 'Property value:' + Write-Debug $value } - Write-Debug "Output lines:" - Write-Debug ($outputLines | Out-String) - $outputLines - } catch { - throw $_ + + $guid = [Guid]::NewGuid().ToString() + $EOFMarker = "EOF_$guid" + $outputLines += "$key<<$EOFMarker" + $outputLines += $value + $outputLines += $EOFMarker } + Write-Debug 'Output lines:' + Write-Debug ($outputLines | Out-String) + $outputLines } end { diff --git a/src/functions/private/Config/Initialize-GitHubConfig.ps1 b/src/functions/private/Config/Initialize-GitHubConfig.ps1 index fce061650..619ba8df5 100644 --- a/src/functions/private/Config/Initialize-GitHubConfig.ps1 +++ b/src/functions/private/Config/Initialize-GitHubConfig.ps1 @@ -31,35 +31,30 @@ function Initialize-GitHubConfig { } process { - try { - Write-Debug "Force: [$Force]" - if ($Force) { - Write-Debug 'Forcing initialization of GitHubConfig.' - $context = Set-Context -ID $script:GitHub.DefaultConfig.ID -Context $script:GitHub.DefaultConfig -PassThru - $script:GitHub.Config = [GitHubConfig]$context - return - } + Write-Debug "Force: [$Force]" + if ($Force) { + Write-Debug 'Forcing initialization of GitHubConfig.' + $context = Set-Context -ID $script:GitHub.DefaultConfig.ID -Context $script:GitHub.DefaultConfig -PassThru + $script:GitHub.Config = [GitHubConfig]$context + return + } - Write-Debug "GitHubConfig ID: [$($script:GitHub.Config.ID)]" - if ($null -ne $script:GitHub.Config) { - Write-Debug 'GitHubConfig already initialized and available in memory.' - return - } + Write-Debug "GitHubConfig ID: [$($script:GitHub.Config.ID)]" + if ($null -ne $script:GitHub.Config) { + Write-Debug 'GitHubConfig already initialized and available in memory.' + return + } - Write-Debug 'Attempt to load the stored GitHubConfig from ContextVault' - $context = Get-Context -ID $script:GitHub.DefaultConfig.ID - if ($context) { - Write-Debug 'GitHubConfig loaded into memory.' - $script:GitHub.Config = [GitHubConfig]$context - return - } - Write-Debug 'Initializing GitHubConfig from defaults' - $context = Set-Context -ID $script:GitHub.DefaultConfig.ID -Context $script:GitHub.DefaultConfig -PassThru + Write-Debug 'Attempt to load the stored GitHubConfig from ContextVault' + $context = Get-Context -ID $script:GitHub.DefaultConfig.ID + if ($context) { + Write-Debug 'GitHubConfig loaded into memory.' $script:GitHub.Config = [GitHubConfig]$context - } catch { - Write-Error $_ - throw 'Failed to initialize GitHub config' + return } + Write-Debug 'Initializing GitHubConfig from defaults' + $context = Set-Context -ID $script:GitHub.DefaultConfig.ID -Context $script:GitHub.DefaultConfig -PassThru + $script:GitHub.Config = [GitHubConfig]$context } end { diff --git a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 index e54fe23c3..b17931c58 100644 --- a/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamBySlug.ps1 @@ -36,8 +36,7 @@ } process { - try { - $query = @" + $query = @" query(`$org: String!, `$teamSlug: String!) { organization(login: `$org) { team(slug: `$teamSlug) { @@ -69,43 +68,40 @@ query(`$org: String!, `$teamSlug: String!) { } "@ - # Variables hash that will be sent with the query - $variables = @{ - org = $Organization - teamSlug = $Slug - } - - # Send the request to the GitHub GraphQL API - $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context + # Variables hash that will be sent with the query + $variables = @{ + org = $Organization + teamSlug = $Slug + } - # Extract team data - $team = $response.data.organization.team + # Send the request to the GitHub GraphQL API + $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context - # Output the team object - if (-not $team) { - return - } + # Extract team data + $team = $response.data.organization.team - [GitHubTeam]( - @{ - Name = $team.name - Slug = $team.slug - NodeID = $team.id - CombinedSlug = $team.CombinedSlug - DatabaseID = $team.DatabaseId - Description = $team.description - Notifications = $team.notificationSetting -eq 'NOTIFICATIONS_ENABLED' ? $true : $false - Visible = $team.privacy -eq 'VISIBLE' ? $true : $false - ParentTeam = $team.parentTeam.slug - Organization = $team.organization.login - ChildTeams = $team.childTeams.nodes.name - CreatedAt = $team.createdAt - UpdatedAt = $team.updatedAt - } - ) - } catch { - throw $_ + # Output the team object + if (-not $team) { + return } + + [GitHubTeam]( + @{ + Name = $team.name + Slug = $team.slug + NodeID = $team.id + CombinedSlug = $team.CombinedSlug + DatabaseID = $team.DatabaseId + Description = $team.description + Notifications = $team.notificationSetting -eq 'NOTIFICATIONS_ENABLED' ? $true : $false + Visible = $team.privacy -eq 'VISIBLE' ? $true : $false + ParentTeam = $team.parentTeam.slug + Organization = $team.organization.login + ChildTeams = $team.childTeams.nodes.name + CreatedAt = $team.createdAt + UpdatedAt = $team.updatedAt + } + ) } end { diff --git a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 index 54dc49035..5353f4a01 100644 --- a/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubTeamListByOrg.ps1 @@ -33,8 +33,7 @@ } process { - try { - $query = @" + $query = @" query(`$org: String!, `$after: String) { organization(login: `$org) { teams(first: 100, after: `$after) { @@ -71,52 +70,49 @@ query(`$org: String!, `$after: String) { } "@ - # Variables hash that will be sent with the query - $variables = @{ - org = $Organization - } - - # Prepare to store results and handle pagination - $hasNextPage = $true - $after = $null + # Variables hash that will be sent with the query + $variables = @{ + org = $Organization + } - while ($hasNextPage) { - # Update the cursor for pagination - $variables['after'] = $after + # Prepare to store results and handle pagination + $hasNextPage = $true + $after = $null - # Send the request to the GitHub GraphQL API - $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context + while ($hasNextPage) { + # Update the cursor for pagination + $variables['after'] = $after - # Extract team data - $teams = $response.data.organization.teams + # Send the request to the GitHub GraphQL API + $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context - # Accumulate the teams in results - $teams.nodes | ForEach-Object { - [GitHubTeam]( - @{ - Name = $_.name - Slug = $_.slug - NodeID = $_.id - CombinedSlug = $_.combinedSlug - DatabaseId = $_.databaseId - Description = $_.description - Notifications = $_.notificationSetting -eq 'NOTIFICATIONS_ENABLED' ? $true : $false - Visible = $_.privacy -eq 'VISIBLE' ? $true : $false - ParentTeam = $_.parentTeam.slug - Organization = $_.organization.login - ChildTeams = $_.childTeams.nodes.name - CreatedAt = $_.createdAt - UpdatedAt = $_.updatedAt - } - ) - } + # Extract team data + $teams = $response.data.organization.teams - # Check if there's another page to fetch - $hasNextPage = $teams.pageInfo.hasNextPage - $after = $teams.pageInfo.endCursor + # Accumulate the teams in results + $teams.nodes | ForEach-Object { + [GitHubTeam]( + @{ + Name = $_.name + Slug = $_.slug + NodeID = $_.id + CombinedSlug = $_.combinedSlug + DatabaseId = $_.databaseId + Description = $_.description + Notifications = $_.notificationSetting -eq 'NOTIFICATIONS_ENABLED' ? $true : $false + Visible = $_.privacy -eq 'VISIBLE' ? $true : $false + ParentTeam = $_.parentTeam.slug + Organization = $_.organization.login + ChildTeams = $_.childTeams.nodes.name + CreatedAt = $_.createdAt + UpdatedAt = $_.updatedAt + } + ) } - } catch { - throw $_ + + # Check if there's another page to fetch + $hasNextPage = $teams.pageInfo.hasNextPage + $after = $teams.pageInfo.endCursor } } diff --git a/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1 b/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1 index 0827535cb..4a43511f8 100644 --- a/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1 +++ b/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1 @@ -48,11 +48,7 @@ } process { - try { - $InputObject | ConvertTo-Json -Depth 100 | ConvertFrom-Json - } catch { - throw $_ - } + $InputObject | ConvertTo-Json -Depth 100 | ConvertFrom-Json } end { diff --git a/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1 b/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1 index b4479001c..b759ac54b 100644 --- a/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1 +++ b/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1 @@ -67,15 +67,11 @@ filter ConvertTo-HashTable { } process { - try { - foreach ($item in $InputObject.PSObject.Properties) { - $name = if ($NameCasingStyle) { ($item.Name | ConvertTo-CasingStyle -To $NameCasingStyle) } else { $item.Name } - $hashtable[$name] = $item.Value - } - $hashtable - } catch { - throw $_ + foreach ($item in $InputObject.PSObject.Properties) { + $name = if ($NameCasingStyle) { ($item.Name | ConvertTo-CasingStyle -To $NameCasingStyle) } else { $item.Name } + $hashtable[$name] = $item.Value } + $hashtable } end { diff --git a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 index 0bd102559..9bd7335f3 100644 --- a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 +++ b/src/functions/private/Utilities/Hashtable/Join-Object.ps1 @@ -76,31 +76,26 @@ } 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 - } + if ($Main -isnot [hashtable]) { + $Main = $Main | ConvertTo-Hashtable + } + $hashtable = $Main.clone() - $Override.Keys | ForEach-Object { - $hashtable[$_] = $Override[$_] - } + foreach ($Override in $Overrides) { + if ($Override -isnot [hashtable]) { + $Override = $Override | ConvertTo-Hashtable } - if ($AsHashtable) { - return $hashtable + $Override.Keys | ForEach-Object { + $hashtable[$_] = $Override[$_] } + } - $hashtable | ConvertFrom-HashTable - } catch { - throw $_ + if ($AsHashtable) { + return $hashtable } + + $hashtable | ConvertFrom-HashTable } end { diff --git a/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 b/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 index 9b8e1c6da..e2744f2a3 100644 --- a/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 +++ b/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 @@ -60,44 +60,40 @@ } process { - try { - if ($NullOrEmptyValues) { - Write-Debug 'Remove keys with null or empty values' + 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) - } + Write-Debug " - [$($_.Name)] - Value: [$($_.Value)] - Remove" + $Hashtable.Remove($_.Name) } - if ($RemoveTypes) { - Write-Debug "Remove keys of type: [$RemoveTypes]" + } + 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) - } + Write-Debug " - [$($_.Name)] - Type: [$($_.Value.GetType().Name)] - Remove" + $Hashtable.Remove($_.Name) } - if ($KeepTypes) { - Write-Debug "Remove keys NOT of type: [$KeepTypes]" + } + 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) - } + Write-Debug " - [$($_.Name)] - Type: [$($_.Value.GetType().Name)] - Remove" + $Hashtable.Remove($_.Name) } - if ($RemoveNames) { - Write-Debug "Remove keys named: [$RemoveNames]" + } + if ($RemoveNames) { + Write-Debug "Remove keys named: [$RemoveNames]" ($Hashtable.GetEnumerator() | Where-Object { $_.Name -in $RemoveNames }) | ForEach-Object { - Write-Debug " - [$($_.Name)] - Remove" - $Hashtable.Remove($_.Name) - } + Write-Debug " - [$($_.Name)] - Remove" + $Hashtable.Remove($_.Name) } - if ($KeepNames) { - Write-Debug "Remove keys NOT named: [$KeepNames]" + } + 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) - } + Write-Debug " - [$($_.Name)] - Remove" + $Hashtable.Remove($_.Name) } - } catch { - throw $_ } } diff --git a/tools/utilities/GetFunctionChanges.ps1 b/tools/utilities/GetFunctionChanges.ps1 new file mode 100644 index 000000000..b4a22ac23 --- /dev/null +++ b/tools/utilities/GetFunctionChanges.ps1 @@ -0,0 +1,33 @@ +function Get-GitBranchFileContent { + [CmdletBinding()] + param( + # The path of the file in the repository + [Parameter(Mandatory)] + [ValidateScript({ Test-Path $_ })] + [string] $Path, + + # The branch to get file content from + [Parameter()] + [string] $Branch = 'main' + ) + + $filePaths = git ls-tree -r $Branch --name-only $Path + $content = @() + foreach ($filePath in $filePaths) { + # Retrieve file content from the first reference + $tmp = git show "$Branch`:$filePath" + $tmp = $tmp -replace '∩╗┐' + $content += $tmp + } + + return $content +} + +$main = Get-GitBranchFileContent -Path 'C:\Repos\GitHub\PSModule\Module\GitHub\src' -Branch 'main' +$head = Get-GitBranchFileContent -Path 'C:\Repos\GitHub\PSModule\Module\GitHub\src' -Branch 'HEAD' + +$main | Out-File -FilePath 'C:\Repos\GitHub\PSModule\Module\GitHub\src\main.txt' +$head | Out-File -FilePath 'C:\Repos\GitHub\PSModule\Module\GitHub\src\head.txt' + + + diff --git a/tools/utilities/GetFunctionMissingDefaultParamSet.ps1 b/tools/utilities/GetFunctionMissingDefaultParamSet.ps1 new file mode 100644 index 000000000..94e831390 --- /dev/null +++ b/tools/utilities/GetFunctionMissingDefaultParamSet.ps1 @@ -0,0 +1,92 @@ +function Get-FunctionsMissingDefaultParameterSet { + param ( + [string]$Path = 'C:\Repos\GitHub\PSModule\Module\GitHub\src', + [switch]$Fix = $true + ) + + function Get-IntFunctionsMissingDefaultParameterSet { + param ( + [string]$ScriptPath + ) + + $scriptContent = Get-Content -Raw -Path $ScriptPath + + try { + $ast = [System.Management.Automation.Language.Parser]::ParseInput($scriptContent, [ref]$null, [ref]$null) + } catch { + Write-Warning "Failed to parse $ScriptPath" + return + } + + $functions = $ast.FindAll({ param ($node) $node -is [System.Management.Automation.Language.FunctionDefinitionAst] }, $true) + + $fixesNeeded = @() + + foreach ($function in $functions) { + $cmdletBinding = $function.Body.ParamBlock?.Attributes | Where-Object { $_.TypeName.Name -eq 'CmdletBinding' } + + if ($cmdletBinding) { + $hasParameterSets = $function.Body.ParamBlock.Parameters | Where-Object { $_.Attributes.NamedArguments -match 'ParameterSetName' } + + if ($hasParameterSets) { + $defaultParamSet = $cmdletBinding.NamedArguments | Where-Object { $_.ArgumentName -eq 'DefaultParameterSetName' } + + if (-not $defaultParamSet) { + $fixesNeeded += [PSCustomObject]@{ + FilePath = $ScriptPath + Function = $function.Name + LineNumber = $function.Extent.StartLineNumber + Extent = $function.Extent + } + } + } + } + } + + return $fixesNeeded + } + + function Fix-Script { + param ( + [string]$ScriptPath, + [System.Management.Automation.Language.IScriptExtent]$FunctionExtent + ) + + $scriptContent = Get-Content -Raw -Path $ScriptPath + + # Ensure the correct format for the `[CmdletBinding()]` attribute + $updatedContent = $scriptContent -replace '(?<=\[CmdletBinding\(\s*)\)', "DefaultParameterSetName = '__AllParameterSets')" + + if ($updatedContent -ne $scriptContent) { + Set-Content -Path $ScriptPath -Value $updatedContent + Write-Host "Updated: $ScriptPath -> Added DefaultParameterSetName to function at line $($FunctionExtent.StartLineNumber)" + } + } + + $results = @() + $files = Get-ChildItem -Path $Path -Filter *.ps1 -Recurse + $files += Get-ChildItem -Path $Path -Filter *.psm1 -Recurse + + foreach ($file in $files) { + $missingDefaults = Get-IntFunctionsMissingDefaultParameterSet -ScriptPath $file.FullName + if ($missingDefaults) { + $results += $missingDefaults + + if ($Fix) { + foreach ($item in $missingDefaults) { + Fix-Script -ScriptPath $item.FilePath -FunctionExtent $item.Extent + } + } + } + } + + if (-not $Fix) { + if ($results) { + $results | Format-Table -AutoSize + } else { + Write-Host 'No issues found.' + } + } else { + Write-Host 'Fix applied where necessary.' + } +} From cd268676f12be2975c5da38537002915d5d43cc0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 10:02:40 +0100 Subject: [PATCH 66/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Simplify=20erro?= =?UTF-8?q?r=20handling=20by=20removing=20try-catch=20blocks=20in=20multip?= =?UTF-8?q?le=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Invoke-GitHubDeviceFlowLogin.ps1 | 40 ++--- .../DeviceFlow/Request-GitHubAccessToken.ps1 | 14 +- .../DeviceFlow/Request-GitHubDeviceCode.ps1 | 12 +- .../Test-GitHubAccessTokenRefreshRequired.ps1 | 12 +- .../Update-GitHubUserAccessToken.ps1 | 89 +++++----- .../DeviceFlow/Wait-GitHubAccessToken.ps1 | 128 +++++++------- .../public/Apps/GitHub App/Get-GitHubApp.ps1 | 16 +- .../public/Auth/Connect-GitHubApp.ps1 | 160 +++++++++--------- .../public/Auth/Disconnect-GitHubAccount.ps1 | 24 ++- .../public/Auth/Get-GitHubViewer.ps1 | 10 +- .../public/Commands/Add-GitHubMask.ps1 | 8 +- .../public/Commands/Add-GitHubSystemPath.ps1 | 10 +- .../public/Commands/Disable-GitHubCommand.ps1 | 12 +- .../public/Commands/Enable-GitHubCommand.ps1 | 12 +- .../public/Commands/Get-GitHubOutput.ps1 | 25 ++- .../Set-GitHubEnvironmentVariable.ps1 | 13 +- .../public/Commands/Set-GitHubLogGroup.ps1 | 6 +- .../Commands/Set-GitHubNoCommandGroup.ps1 | 6 +- .../public/Commands/Set-GitHubOutput.ps1 | 71 ++++---- .../public/Commands/Set-GitHubStepSummary.ps1 | 12 +- .../public/Commands/Write-GitHubDebug.ps1 | 12 +- .../public/Commands/Write-GitHubError.ps1 | 12 +- .../public/Commands/Write-GitHubNotice.ps1 | 12 +- .../public/Commands/Write-GitHubWarning.ps1 | 12 +- .../public/Config/Get-GitHubConfig.ps1 | 12 +- .../public/Config/Reset-GitHubConfig.ps1 | 9 +- .../public/Config/Set-GitHubConfig.ps1 | 13 +- .../Get-GitHubEnterpriseOrganization.ps1 | 55 +++--- .../public/Git/Get-GitHubGitConfig.ps1 | 5 +- .../public/Git/Set-GitHubGitConfig.ps1 | 75 ++++---- .../public/Gitignore/Get-GitHubGitignore.ps1 | 17 +- .../Organization/Get-GitHubOrganization.ps1 | 33 ++-- .../Releases/Releases/Get-GitHubRelease.ps1 | 29 ++-- .../Get-GitHubRepositoryAutolink.ps1 | 16 +- .../Repositories/New-GitHubRepository.ps1 | 141 ++++++++------- .../Status/Get-GitHubScheduledMaintenance.ps1 | 37 ++-- .../public/Status/Get-GitHubStatus.ps1 | 23 ++- .../Status/Get-GitHubStatusComponent.ps1 | 14 +- .../Status/Get-GitHubStatusIncident.ps1 | 20 +-- .../Users/Blocking/Block-GitHubUser.ps1 | 16 +- .../Users/Blocking/Get-GitHubBlockedUser.ps1 | 12 +- .../Users/Blocking/Test-GitHubBlockedUser.ps1 | 12 +- .../Users/Blocking/Unblock-GitHubUser.ps1 | 12 +- .../Users/Emails/Get-GitHubUserEmail.ps1 | 12 +- .../Followers/Get-GitHubUserFollower.ps1 | 12 +- .../Followers/Get-GitHubUserFollowing.ps1 | 12 +- .../Followers/Test-GitHubUserFollowing.ps1 | 12 +- src/functions/public/Users/Get-GitHubUser.ps1 | 34 ++-- 48 files changed, 586 insertions(+), 775 deletions(-) diff --git a/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1 b/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1 index abce72717..32afe8622 100644 --- a/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Invoke-GitHubDeviceFlowLogin.ps1 @@ -47,31 +47,27 @@ } process { - try { - do { - if ($RefreshToken) { - $tokenResponse = Wait-GitHubAccessToken -ClientID $ClientID -RefreshToken $RefreshToken -HostName $HostName - } else { - $deviceCodeResponse = Request-GitHubDeviceCode -ClientID $ClientID -Scope $Scope -HostName $HostName + do { + if ($RefreshToken) { + $tokenResponse = Wait-GitHubAccessToken -ClientID $ClientID -RefreshToken $RefreshToken -HostName $HostName + } else { + $deviceCodeResponse = Request-GitHubDeviceCode -ClientID $ClientID -Scope $Scope -HostName $HostName - $deviceCode = $deviceCodeResponse.device_code - $interval = $deviceCodeResponse.interval - $userCode = $deviceCodeResponse.user_code - $verificationUri = $deviceCodeResponse.verification_uri + $deviceCode = $deviceCodeResponse.device_code + $interval = $deviceCodeResponse.interval + $userCode = $deviceCodeResponse.user_code + $verificationUri = $deviceCodeResponse.verification_uri - 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 + 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 $_ - } + $tokenResponse = Wait-GitHubAccessToken -DeviceCode $deviceCode -ClientID $ClientID -Interval $interval -HostName $HostName + } + } while ($tokenResponse.error) + $tokenResponse } end { diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 index 37022a64f..c886d3fa4 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 @@ -77,17 +77,11 @@ Body = $body } - try { - Write-Debug ($RESTParams.GetEnumerator() | Out-String) + Write-Debug ($RESTParams.GetEnumerator() | Out-String) + $tokenResponse = Invoke-RestMethod @RESTParams -Verbose:$false + Write-Debug ($tokenResponse | ConvertTo-Json | Out-String) + return $tokenResponse - $tokenResponse = Invoke-RestMethod @RESTParams -Verbose:$false - - Write-Debug ($tokenResponse | ConvertTo-Json | Out-String) - return $tokenResponse - } catch { - Write-Error $_ - throw $_ - } } end { diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 index 2137e9d26..9431663f1 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 @@ -56,15 +56,9 @@ Body = $body } - try { - Write-Debug ($RESTParams.GetEnumerator() | Out-String) - - $deviceCodeResponse = Invoke-RestMethod @RESTParams -Verbose:$false - return $deviceCodeResponse - } catch { - Write-Error $_ - throw $_ - } + Write-Debug ($RESTParams.GetEnumerator() | Out-String) + $deviceCodeResponse = Invoke-RestMethod @RESTParams -Verbose:$false + return $deviceCodeResponse } end { diff --git a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 index 844398da7..1c2740a09 100644 --- a/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Test-GitHubAccessTokenRefreshRequired.ps1 @@ -26,14 +26,10 @@ } process { - try { - $tokenExpirationDate = $Context.TokenExpirationDate - $currentDateTime = Get-Date - $remainingDuration = [datetime]$tokenExpirationDate - $currentDateTime - $remainingDuration.TotalHours -lt $script:GitHub.Config.AccessTokenGracePeriodInHours - } catch { - throw $_ - } + $tokenExpirationDate = $Context.TokenExpirationDate + $currentDateTime = Get-Date + $remainingDuration = [datetime]$tokenExpirationDate - $currentDateTime + $remainingDuration.TotalHours -lt $script:GitHub.Config.AccessTokenGracePeriodInHours } end { diff --git a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 index 347c54bdf..cc1b013e1 100644 --- a/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Update-GitHubUserAccessToken.ps1 @@ -42,59 +42,56 @@ } 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 + 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 { - $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 + 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 } - $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-Context -Context $Context -ID $Context.ID + } 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 } + } + $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 ($PassThru) { - $Context.Token - } - } catch { - throw $_ + if ($PSCmdlet.ShouldProcess('Access token', 'Update/refresh')) { + Set-Context -Context $Context -ID $Context.ID + } + + if ($PassThru) { + $Context.Token } + } end { diff --git a/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1 index d57426197..6d1c65924 100644 --- a/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Wait-GitHubAccessToken.ps1 @@ -55,74 +55,70 @@ } process { - try { - 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 - } - 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 - } + 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 + } + 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 { diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 index 560050122..14a42f150 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubApp.ps1 @@ -46,17 +46,13 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'BySlug' { - Get-GitHubAppByName -AppSlug $Name -Context $Context - } - default { - Get-GitHubAuthenticatedApp -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + 'BySlug' { + Get-GitHubAppByName -AppSlug $Name -Context $Context + } + default { + Get-GitHubAuthenticatedApp -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Auth/Connect-GitHubApp.ps1 b/src/functions/public/Auth/Connect-GitHubApp.ps1 index c0a89cf53..5c0a4abfe 100644 --- a/src/functions/public/Auth/Connect-GitHubApp.ps1 +++ b/src/functions/public/Auth/Connect-GitHubApp.ps1 @@ -80,100 +80,96 @@ } process { - try { - $Context = $Context | Resolve-GitHubContext - $Context | Assert-GitHubContext -AuthType 'App' - - $installations = Get-GitHubAppInstallation -Context $Context - $selectedInstallations = @() - Write-Verbose "Found [$($installations.Count)] installations." - switch ($PSCmdlet.ParameterSetName) { - 'Filtered' { - $User | ForEach-Object { - $userItem = $_ - Write-Verbose "User filter: [$userItem]." - $selectedInstallations += $installations | Where-Object { - $_.target_type -eq 'User' -and $_.account.login -like $userItem - } + $Context = $Context | Resolve-GitHubContext + $Context | Assert-GitHubContext -AuthType 'App' + + $installations = Get-GitHubAppInstallation -Context $Context + $selectedInstallations = @() + Write-Verbose "Found [$($installations.Count)] installations." + switch ($PSCmdlet.ParameterSetName) { + 'Filtered' { + $User | ForEach-Object { + $userItem = $_ + Write-Verbose "User filter: [$userItem]." + $selectedInstallations += $installations | Where-Object { + $_.target_type -eq 'User' -and $_.account.login -like $userItem } - $Organization | ForEach-Object { - $organizationItem = $_ - Write-Verbose "Organization filter: [$organizationItem]." - $selectedInstallations += $installations | Where-Object { - $_.target_type -eq 'Organization' -and $_.account.login -like $organizationItem - } - } - $Enterprise | ForEach-Object { - $enterpriseItem = $_ - Write-Verbose "Enterprise filter: [$enterpriseItem]." - $selectedInstallations += $installations | Where-Object { - $_.target_type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem - } + } + $Organization | ForEach-Object { + $organizationItem = $_ + Write-Verbose "Organization filter: [$organizationItem]." + $selectedInstallations += $installations | Where-Object { + $_.target_type -eq 'Organization' -and $_.account.login -like $organizationItem } } - default { - Write-Verbose 'No target specified. Connecting to all installations.' - $selectedInstallations = $installations + $Enterprise | ForEach-Object { + $enterpriseItem = $_ + Write-Verbose "Enterprise filter: [$enterpriseItem]." + $selectedInstallations += $installations | Where-Object { + $_.target_type -eq 'Enterprise' -and $_.account.slug -like $enterpriseItem + } } } + default { + Write-Verbose 'No target specified. Connecting to all installations.' + $selectedInstallations = $installations + } + } - Write-Verbose "Found [$($selectedInstallations.Count)] installations for the target." - $selectedInstallations | ForEach-Object { - $installation = $_ - Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" - $token = New-GitHubAppInstallationAccessToken -Context $Context -InstallationID $installation.id - - $contextParams = @{ - AuthType = [string]'IAT' - TokenType = [string]'ghs' - DisplayName = [string]$Context.DisplayName - ApiBaseUri = [string]$Context.ApiBaseUri - ApiVersion = [string]$Context.ApiVersion - HostName = [string]$Context.HostName - HttpVersion = [string]$Context.HttpVersion - PerPage = [int]$Context.PerPage - ClientID = [string]$Context.ClientID - InstallationID = [string]$installation.id - Permissions = [pscustomobject]$installation.permissions - Events = [string[]]$installation.events - InstallationType = [string]$installation.target_type - Token = [securestring]$token.Token - TokenExpirationDate = [datetime]$token.ExpiresAt - } + Write-Verbose "Found [$($selectedInstallations.Count)] installations for the target." + $selectedInstallations | ForEach-Object { + $installation = $_ + Write-Verbose "Processing installation [$($installation.account.login)] [$($installation.id)]" + $token = New-GitHubAppInstallationAccessToken -Context $Context -InstallationID $installation.id + + $contextParams = @{ + AuthType = [string]'IAT' + TokenType = [string]'ghs' + DisplayName = [string]$Context.DisplayName + ApiBaseUri = [string]$Context.ApiBaseUri + ApiVersion = [string]$Context.ApiVersion + HostName = [string]$Context.HostName + HttpVersion = [string]$Context.HttpVersion + PerPage = [int]$Context.PerPage + ClientID = [string]$Context.ClientID + InstallationID = [string]$installation.id + Permissions = [pscustomobject]$installation.permissions + Events = [string[]]$installation.events + InstallationType = [string]$installation.target_type + Token = [securestring]$token.Token + TokenExpirationDate = [datetime]$token.ExpiresAt + } - switch ($installation.target_type) { - 'User' { - $contextParams['InstallationName'] = [string]$installation.account.login - $contextParams['Owner'] = [string]$installation.account.login - } - 'Organization' { - $contextParams['InstallationName'] = [string]$installation.account.login - $contextParams['Owner'] = [string]$installation.account.login - } - 'Enterprise' { - $contextParams['InstallationName'] = [string]$installation.account.slug - $contextParams['Enterprise'] = [string]$installation.account.slug - } + switch ($installation.target_type) { + 'User' { + $contextParams['InstallationName'] = [string]$installation.account.login + $contextParams['Owner'] = [string]$installation.account.login } - Write-Verbose 'Logging in using a managed installation access token...' - Write-Verbose ($contextParams | Format-Table | Out-String) - $contextObj = [InstallationGitHubContext]::new((Set-GitHubContext -Context $contextParams.Clone() -PassThru -Default:$Default)) - Write-Verbose ($contextObj | Format-List | Out-String) - if (-not $Silent) { - $name = $contextObj.name - Write-Host '✓ ' -ForegroundColor Green -NoNewline - Write-Host "Connected $name!" + 'Organization' { + $contextParams['InstallationName'] = [string]$installation.account.login + $contextParams['Owner'] = [string]$installation.account.login } - if ($PassThru) { - Write-Debug "Passing context [$contextObj] to the pipeline." - Write-Output $contextObj + 'Enterprise' { + $contextParams['InstallationName'] = [string]$installation.account.slug + $contextParams['Enterprise'] = [string]$installation.account.slug } - $contextParams.Clear() } - } catch { - Write-Error $_ - throw 'Failed to connect to GitHub using a GitHub App.' + Write-Verbose 'Logging in using a managed installation access token...' + Write-Verbose ($contextParams | Format-Table | Out-String) + $contextObj = [InstallationGitHubContext]::new((Set-GitHubContext -Context $contextParams.Clone() -PassThru -Default:$Default)) + Write-Verbose ($contextObj | Format-List | Out-String) + if (-not $Silent) { + $name = $contextObj.name + Write-Host '✓ ' -ForegroundColor Green -NoNewline + Write-Host "Connected $name!" + } + if ($PassThru) { + Write-Debug "Passing context [$contextObj] to the pipeline." + Write-Output $contextObj + } + $contextParams.Clear() } + } end { diff --git a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 index bbc702de2..1b2aafc29 100644 --- a/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Disconnect-GitHubAccount.ps1 @@ -43,21 +43,17 @@ } foreach ($contextItem in $Context) { $contextItem = Resolve-GitHubContext -Context $contextItem - try { - Remove-GitHubContext -Context $contextItem - $isDefaultContext = $contextItem.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 '" - } + Remove-GitHubContext -Context $contextItem + $isDefaultContext = $contextItem.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! [$contextItem]" - } - } catch { - throw $_ + if (-not $Silent) { + Write-Host '✓ ' -ForegroundColor Green -NoNewline + Write-Host "Logged out of GitHub! [$contextItem]" } } } diff --git a/src/functions/public/Auth/Get-GitHubViewer.ps1 b/src/functions/public/Auth/Get-GitHubViewer.ps1 index 658e4fc34..5dd7d9685 100644 --- a/src/functions/public/Auth/Get-GitHubViewer.ps1 +++ b/src/functions/public/Auth/Get-GitHubViewer.ps1 @@ -33,20 +33,16 @@ } process { - try { - $query = @" + $query = @" query { viewer { $($Fields -join "`n") } } "@ - $results = Invoke-GitHubGraphQLQuery -Query $query -Context $Context + $results = Invoke-GitHubGraphQLQuery -Query $query -Context $Context - $results.data.viewer - } catch { - throw $_ - } + $results.data.viewer } end { diff --git a/src/functions/public/Commands/Add-GitHubMask.ps1 b/src/functions/public/Commands/Add-GitHubMask.ps1 index 8b156f649..ae6a2f750 100644 --- a/src/functions/public/Commands/Add-GitHubMask.ps1 +++ b/src/functions/public/Commands/Add-GitHubMask.ps1 @@ -52,12 +52,8 @@ } process { - try { - foreach ($item in $Value) { - Write-Host "::add-mask::$item" - } - } catch { - throw $_ + foreach ($item in $Value) { + Write-Host "::add-mask::$item" } } diff --git a/src/functions/public/Commands/Add-GitHubSystemPath.ps1 b/src/functions/public/Commands/Add-GitHubSystemPath.ps1 index 2465ac7a7..ad7c9a639 100644 --- a/src/functions/public/Commands/Add-GitHubSystemPath.ps1 +++ b/src/functions/public/Commands/Add-GitHubSystemPath.ps1 @@ -30,14 +30,10 @@ } process { - try { - Write-Verbose "Current PATH: $env:PATH" - Write-Verbose "Adding system path: $Path" + Write-Verbose "Current PATH: $env:PATH" + Write-Verbose "Adding system path: $Path" - $Path | Out-File -FilePath $env:GITHUB_PATH -Append - } catch { - throw $_ - } + $Path | Out-File -FilePath $env:GITHUB_PATH -Append } end { diff --git a/src/functions/public/Commands/Disable-GitHubCommand.ps1 b/src/functions/public/Commands/Disable-GitHubCommand.ps1 index 0c8a6e1cb..0f89df98a 100644 --- a/src/functions/public/Commands/Disable-GitHubCommand.ps1 +++ b/src/functions/public/Commands/Disable-GitHubCommand.ps1 @@ -40,14 +40,10 @@ } process { - try { - $String = $String.ToLower() - - if ($env:GITHUB_ACTIONS -eq 'true') { - Write-Host "::stop-commands::$String" - } - } catch { - throw $_ + $String = $String.ToLower() + + if ($env:GITHUB_ACTIONS -eq 'true') { + Write-Host "::stop-commands::$String" } } diff --git a/src/functions/public/Commands/Enable-GitHubCommand.ps1 b/src/functions/public/Commands/Enable-GitHubCommand.ps1 index d1a0e6ee6..67d9fd008 100644 --- a/src/functions/public/Commands/Enable-GitHubCommand.ps1 +++ b/src/functions/public/Commands/Enable-GitHubCommand.ps1 @@ -39,14 +39,10 @@ } process { - try { - $String = $String.ToLower() - - if ($env:GITHUB_ACTIONS -eq 'true') { - Write-Host "::$String::" - } - } catch { - throw $_ + $String = $String.ToLower() + + if ($env:GITHUB_ACTIONS -eq 'true') { + Write-Host "::$String::" } } diff --git a/src/functions/public/Commands/Get-GitHubOutput.ps1 b/src/functions/public/Commands/Get-GitHubOutput.ps1 index 166423781..cfdbd6e6f 100644 --- a/src/functions/public/Commands/Get-GitHubOutput.ps1 +++ b/src/functions/public/Commands/Get-GitHubOutput.ps1 @@ -46,21 +46,18 @@ } process { - try { - if (-not $Path) { - throw 'The path to the GitHub output file is not set. Please set the path to the GitHub output file using the -Path parameter.' - } - Write-Debug "[$stackPath] - Output path" - Write-Debug $Path - if (-not (Test-Path -Path $Path)) { - throw "File not found: $Path" - } - - $outputContent = Get-Content -Path $Path -Raw - ConvertFrom-GitHubOutput -OutputContent $outputContent -AsHashtable:$AsHashtable - } catch { - throw $_ + if (-not $Path) { + throw 'The path to the GitHub output file is not set. Please set the path to the GitHub output file using the -Path parameter.' + } + Write-Debug "[$stackPath] - Output path" + Write-Debug $Path + if (-not (Test-Path -Path $Path)) { + throw "File not found: $Path" } + + $outputContent = Get-Content -Path $Path -Raw + ConvertFrom-GitHubOutput -OutputContent $outputContent -AsHashtable:$AsHashtable + } end { diff --git a/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1 b/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1 index 204d4e17f..29ecfb51c 100644 --- a/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1 +++ b/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1 @@ -40,19 +40,16 @@ } process { - try { - Write-Verbose "Env: [$Name] = [$Value]" + Write-Verbose "Env: [$Name] = [$Value]" - $guid = [guid]::NewGuid().Guid - $content = @" + $guid = [guid]::NewGuid().Guid + $content = @" $Name<<$guid $Value $guid "@ - $content | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - } catch { - throw $_ - } + $content | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + } end { diff --git a/src/functions/public/Commands/Set-GitHubLogGroup.ps1 b/src/functions/public/Commands/Set-GitHubLogGroup.ps1 index 7a08b63a9..85911531f 100644 --- a/src/functions/public/Commands/Set-GitHubLogGroup.ps1 +++ b/src/functions/public/Commands/Set-GitHubLogGroup.ps1 @@ -45,10 +45,6 @@ ) Write-Host "::group::$Name" - try { - . $ScriptBlock - } catch { - throw $_ - } + . $ScriptBlock Write-Host '::endgroup::' } diff --git a/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1 b/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1 index 4384c7a98..c9b10ff72 100644 --- a/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1 +++ b/src/functions/public/Commands/Set-GitHubNoCommandGroup.ps1 @@ -51,11 +51,7 @@ $guid = [string][guid]::NewGuid().Guid Disable-GitHubCommand -String $guid - try { - . $ScriptBlock - } catch { - throw $_ - } + . $ScriptBlock Enable-GitHubCommand -String $guid } diff --git a/src/functions/public/Commands/Set-GitHubOutput.ps1 b/src/functions/public/Commands/Set-GitHubOutput.ps1 index ded04e4f3..bc0094814 100644 --- a/src/functions/public/Commands/Set-GitHubOutput.ps1 +++ b/src/functions/public/Commands/Set-GitHubOutput.ps1 @@ -42,51 +42,48 @@ } process { - try { - if (-not (Test-Path -Path $Path)) { - throw "File not found: $Path" - } + if (-not (Test-Path -Path $Path)) { + throw "File not found: $Path" + } - $outputs = Get-GitHubOutput -Path $Path -AsHashtable + $outputs = Get-GitHubOutput -Path $Path -AsHashtable - if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { - Write-Warning 'Cannot create output as the step has no ID.' - } + if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { + Write-Warning 'Cannot create output as the step has no ID.' + } - switch -Regex ($value.GetType().Name) { - 'SecureString' { - $Value = $Value | ConvertFrom-SecureString -AsPlainText - Add-Mask -Value $Value - } - 'Hashtable|PSCustomObject' { - Write-Debug 'Converting value to JSON:' - $Value = $Value | ConvertTo-Json -Compress -Depth 100 - Write-Debug $value - } - default {} + switch -Regex ($value.GetType().Name) { + 'SecureString' { + $Value = $Value | ConvertFrom-SecureString -AsPlainText + Add-Mask -Value $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) { - Write-Debug "[$stackPath] - Running in GitHub-Script composite action" - if (-not $outputs.ContainsKey('result')) { - $outputs['result'] = @{} - } - $outputs['result'][$Name] = $Value - } else { - Write-Debug "[$stackPath] - Running in a custom action" - $outputs[$Name] = $Value + 'Hashtable|PSCustomObject' { + Write-Debug 'Converting value to JSON:' + $Value = $Value | ConvertTo-Json -Compress -Depth 100 + Write-Debug $value } + default {} + } - if ($PSCmdlet.ShouldProcess('GitHub Output', 'Set')) { - $outputs | ConvertTo-GitHubOutput | Set-Content -Path $Path + 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) { + Write-Debug "[$stackPath] - Running in GitHub-Script composite action" + if (-not $outputs.ContainsKey('result')) { + $outputs['result'] = @{} } - } catch { - throw $_ + $outputs['result'][$Name] = $Value + } else { + Write-Debug "[$stackPath] - Running in a custom action" + $outputs[$Name] = $Value } + + if ($PSCmdlet.ShouldProcess('GitHub Output', 'Set')) { + $outputs | ConvertTo-GitHubOutput | Set-Content -Path $Path + } + } end { diff --git a/src/functions/public/Commands/Set-GitHubStepSummary.ps1 b/src/functions/public/Commands/Set-GitHubStepSummary.ps1 index d04e0dd2b..d13bb16f5 100644 --- a/src/functions/public/Commands/Set-GitHubStepSummary.ps1 +++ b/src/functions/public/Commands/Set-GitHubStepSummary.ps1 @@ -48,15 +48,11 @@ } process { - try { - Write-Verbose 'Step summary:' - Write-Verbose $Summary + Write-Verbose 'Step summary:' + Write-Verbose $Summary - $Append = -not $Overwrite - $Summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append:$Append - } catch { - throw $_ - } + $Append = -not $Overwrite + $Summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append:$Append } end { diff --git a/src/functions/public/Commands/Write-GitHubDebug.ps1 b/src/functions/public/Commands/Write-GitHubDebug.ps1 index e473db310..b187b4f14 100644 --- a/src/functions/public/Commands/Write-GitHubDebug.ps1 +++ b/src/functions/public/Commands/Write-GitHubDebug.ps1 @@ -41,14 +41,10 @@ } process { - try { - if ($env:GITHUB_ACTIONS -eq 'true') { - Write-Host "::debug::$Message" - } else { - Write-Debug "$Message" - } - } catch { - throw $_ + if ($env:GITHUB_ACTIONS -eq 'true') { + Write-Host "::debug::$Message" + } else { + Write-Debug "$Message" } } diff --git a/src/functions/public/Commands/Write-GitHubError.ps1 b/src/functions/public/Commands/Write-GitHubError.ps1 index 3ab1c6d87..506f54cd2 100644 --- a/src/functions/public/Commands/Write-GitHubError.ps1 +++ b/src/functions/public/Commands/Write-GitHubError.ps1 @@ -61,14 +61,10 @@ } 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 $_ + 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 } } diff --git a/src/functions/public/Commands/Write-GitHubNotice.ps1 b/src/functions/public/Commands/Write-GitHubNotice.ps1 index d206f4390..32cef882d 100644 --- a/src/functions/public/Commands/Write-GitHubNotice.ps1 +++ b/src/functions/public/Commands/Write-GitHubNotice.ps1 @@ -61,14 +61,10 @@ } 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 $_ + 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 } } diff --git a/src/functions/public/Commands/Write-GitHubWarning.ps1 b/src/functions/public/Commands/Write-GitHubWarning.ps1 index 22de869a4..7ca6eb747 100644 --- a/src/functions/public/Commands/Write-GitHubWarning.ps1 +++ b/src/functions/public/Commands/Write-GitHubWarning.ps1 @@ -61,14 +61,10 @@ } 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 $_ + 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 } } diff --git a/src/functions/public/Config/Get-GitHubConfig.ps1 b/src/functions/public/Config/Get-GitHubConfig.ps1 index 42633f786..a87859ee0 100644 --- a/src/functions/public/Config/Get-GitHubConfig.ps1 +++ b/src/functions/public/Config/Get-GitHubConfig.ps1 @@ -26,15 +26,11 @@ } process { - try { - if (-not $Name) { - return [GitHubConfig]($script:GitHub.Config) - } - - $script:GitHub.Config.$Name - } catch { - throw $_ + if (-not $Name) { + return [GitHubConfig]($script:GitHub.Config) } + + $script:GitHub.Config.$Name } end { diff --git a/src/functions/public/Config/Reset-GitHubConfig.ps1 b/src/functions/public/Config/Reset-GitHubConfig.ps1 index 8b2d979fa..508621e4d 100644 --- a/src/functions/public/Config/Reset-GitHubConfig.ps1 +++ b/src/functions/public/Config/Reset-GitHubConfig.ps1 @@ -21,13 +21,8 @@ } process { - try { - if ($PSCmdlet.ShouldProcess('GitHubConfig', 'Reset')) { - Initialize-GitHubConfig -Force - } - } catch { - Write-Error $_ - throw 'Failed to reset GitHub module configuration.' + if ($PSCmdlet.ShouldProcess('GitHubConfig', 'Reset')) { + Initialize-GitHubConfig -Force } } diff --git a/src/functions/public/Config/Set-GitHubConfig.ps1 b/src/functions/public/Config/Set-GitHubConfig.ps1 index 66718e18d..9985effbb 100644 --- a/src/functions/public/Config/Set-GitHubConfig.ps1 +++ b/src/functions/public/Config/Set-GitHubConfig.ps1 @@ -31,15 +31,10 @@ function Set-GitHubConfig { } process { - 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 - } - } catch { - Write-Error $_ - throw 'Failed to set GitHub module configuration.' + 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 } } diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 index 98ff3efee..d9d021aa2 100644 --- a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 @@ -32,8 +32,7 @@ } process { - try { - $query = @" + $query = @" query(`$enterpriseSlug: String!, `$first: Int = 100, `$after: String) { enterprise(slug: `$enterpriseSlug) { organizations(first: `$first, after: `$after) { @@ -52,39 +51,37 @@ query(`$enterpriseSlug: String!, `$first: Int = 100, `$after: String) { } "@ - # Initialize pagination variables - $variables = @{ - 'enterpriseSlug' = $Enterprise - 'first' = 100 - 'after' = $null + # 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 } - $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 - } + # 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 { diff --git a/src/functions/public/Git/Get-GitHubGitConfig.ps1 b/src/functions/public/Git/Get-GitHubGitConfig.ps1 index 3698f8b0d..950918ce9 100644 --- a/src/functions/public/Git/Get-GitHubGitConfig.ps1 +++ b/src/functions/public/Git/Get-GitHubGitConfig.ps1 @@ -25,7 +25,6 @@ } process { - try { $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue Write-Debug "GITEXISTS: $gitExists" if (-not $gitExists) { @@ -63,9 +62,7 @@ } } $config - } catch { - throw $_ - } + } end { diff --git a/src/functions/public/Git/Set-GitHubGitConfig.ps1 b/src/functions/public/Git/Set-GitHubGitConfig.ps1 index e5d9daae0..22d2e1fa3 100644 --- a/src/functions/public/Git/Set-GitHubGitConfig.ps1 +++ b/src/functions/public/Git/Set-GitHubGitConfig.ps1 @@ -32,51 +32,48 @@ } process { - try { - $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue - Write-Debug "GITEXISTS: $gitExists" - if (-not $gitExists) { - Write-Verbose 'Git is not installed. Cannot configure git.' - return - } + $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue + Write-Debug "GITEXISTS: $gitExists" + if (-not $gitExists) { + Write-Verbose 'Git is not installed. Cannot configure git.' + return + } - $cmdresult = git rev-parse --is-inside-work-tree 2>&1 - Write-Debug "LASTEXITCODE: $LASTEXITCODE" - Write-Debug "CMDRESULT: $cmdresult" - if ($LASTEXITCODE -ne 0) { - Write-Verbose 'Not a git repository. Cannot configure git.' - $Global:LASTEXITCODE = 0 - Write-Debug "Resetting LASTEXITCODE: $LASTEXITCODE" - return - } + $cmdresult = git rev-parse --is-inside-work-tree 2>&1 + Write-Debug "LASTEXITCODE: $LASTEXITCODE" + Write-Debug "CMDRESULT: $cmdresult" + if ($LASTEXITCODE -ne 0) { + Write-Verbose 'Not a git repository. Cannot configure git.' + $Global:LASTEXITCODE = 0 + Write-Debug "Resetting LASTEXITCODE: $LASTEXITCODE" + return + } - $username = $Context.UserName - $id = $Context.DatabaseID - $token = $Context.Token | ConvertFrom-SecureString -AsPlainText - $hostName = $Context.HostName - $installationName = $Context.InstallationName - $sshUser = $Context.Enterprise ?? 'git' + $username = $Context.UserName + $id = $Context.DatabaseID + $token = $Context.Token | ConvertFrom-SecureString -AsPlainText + $hostName = $Context.HostName + $installationName = $Context.InstallationName + $sshUser = $Context.Enterprise ?? 'git' - if ($PSCmdlet.ShouldProcess("$username on $installationName", 'Set Git configuration')) { - $git = 'git' - @( - @('config', '--global', 'user.name', "$username"), - @('config', '--global', 'user.email', "$id+$username@users.noreply.github.com"), - @('config', '--global', '--add', "url.https://oauth2:$token@$hostName/$installationName.insteadOf", - "ssh://$sshUser@$hostName`:$installationName"), - @('config', '--global', '--add', "url.https://oauth2:$token@$hostName/$installationName.insteadOf", - "https://$hostName/$installationName") - ) | ForEach-Object { - Write-Verbose "$git $($_ -join ' ')" - & $git $_ - if ($LASTEXITCODE -ne 0) { - throw "Failed to run git command. ($LASTEXITCODE)" - } + if ($PSCmdlet.ShouldProcess("$username on $installationName", 'Set Git configuration')) { + $git = 'git' + @( + @('config', '--global', 'user.name', "$username"), + @('config', '--global', 'user.email', "$id+$username@users.noreply.github.com"), + @('config', '--global', '--add', "url.https://oauth2:$token@$hostName/$installationName.insteadOf", + "ssh://$sshUser@$hostName`:$installationName"), + @('config', '--global', '--add', "url.https://oauth2:$token@$hostName/$installationName.insteadOf", + "https://$hostName/$installationName") + ) | ForEach-Object { + Write-Verbose "$git $($_ -join ' ')" + & $git $_ + if ($LASTEXITCODE -ne 0) { + throw "Failed to run git command. ($LASTEXITCODE)" } } - } catch { - throw $_ } + } end { diff --git a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 index 7746c1116..f8bd75a94 100644 --- a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 +++ b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 @@ -47,18 +47,13 @@ } process { - try { - $Name = $PSBoundParameters['Name'] - switch ($PSCmdlet.ParameterSetName) { - 'List' { - Get-GitHubGitignoreList -Context $Context - } - 'Name' { - Get-GitHubGitignoreByName -Name $Name -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + 'List' { + Get-GitHubGitignoreList -Context $Context + } + 'Name' { + Get-GitHubGitignoreByName -Name $Name -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index 2a7c20dfd..c715eac9e 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -33,7 +33,7 @@ [List organizations](https://docs.github.com/rest/orgs/orgs) #> [OutputType([pscustomobject])] - [CmdletBinding(DefaultParameterSetName = '__DefaultSet')] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'All', Justification = 'Required for parameter set')] param( # The organization name. The name is not case sensitive. @@ -66,7 +66,7 @@ # The number of results per page (max 100). [Parameter(ParameterSetName = 'AllOrg')] [Parameter(ParameterSetName = 'UserOrg')] - [Parameter(ParameterSetName = '__DefaultSet')] + [Parameter(ParameterSetName = '__AllParameterSets')] [ValidateRange(0, 100)] [int] $PerPage, @@ -89,24 +89,19 @@ } 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 - } + switch ($PSCmdlet.ParameterSetName) { + 'NamedOrg' { + Get-GitHubOrganizationByName -Organization $Organization -Context $Context + } + 'NamedUser' { + Get-GitHubUserOrganization -Username $Username -Context $Context + } + 'AllOrg' { + Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context + } + default { + Get-GitHubMyOrganization -PerPage $PerPage -Context $Context | Get-GitHubOrganizationByName -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 index 15d784595..ede7522d6 100644 --- a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 @@ -87,24 +87,21 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'All' { - Get-GitHubReleaseAll -Owner $Owner -Repository $Repository -PerPage $PerPage -Context $Context - } - 'Latest' { - Get-GitHubReleaseLatest -Owner $Owner -Repository $Repository -Context $Context - } - 'Tag' { - Get-GitHubReleaseByTagName -Owner $Owner -Repository $Repository -Tag $Tag -Context $Context - } - 'ID' { - Get-GitHubReleaseByID -Owner $Owner -Repository $Repository -ID $ID -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + 'All' { + Get-GitHubReleaseAll -Owner $Owner -Repository $Repository -PerPage $PerPage -Context $Context + } + 'Latest' { + Get-GitHubReleaseLatest -Owner $Owner -Repository $Repository -Context $Context + } + 'Tag' { + Get-GitHubReleaseByTagName -Owner $Owner -Repository $Repository -Tag $Tag -Context $Context + } + 'ID' { + Get-GitHubReleaseByID -Owner $Owner -Repository $Repository -ID $ID -Context $Context } - } catch { - throw $_ } + } end { diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 index fde361916..eb3d7b079 100644 --- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 @@ -56,17 +56,13 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'ById' { - Get-GitHubRepositoryAutolinkById -Owner $Owner -Repository $Repository -ID $ID -Context $Context - } - default { - Get-GitHubRepositoryAutolinkList -Owner $Owner -Repository $Repository -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + 'ById' { + Get-GitHubRepositoryAutolinkById -Owner $Owner -Repository $Repository -ID $ID -Context $Context + } + default { + Get-GitHubRepositoryAutolinkList -Owner $Owner -Repository $Repository -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 index d773f3146..60d7bd9f0 100644 --- a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 @@ -338,88 +338,85 @@ filter New-GitHubRepository { } process { - 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 + $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 + } - switch ($PSCmdlet.ParameterSetName) { - 'user' { - if ($PSCmdlet.ShouldProcess("repository for user [$Name]", 'Create')) { - New-GitHubRepositoryUser @params - } + switch ($PSCmdlet.ParameterSetName) { + 'user' { + if ($PSCmdlet.ShouldProcess("repository for user [$Name]", 'Create')) { + New-GitHubRepositoryUser @params } - 'org' { - if ($PSCmdlet.ShouldProcess("repository for organization [$Owner/$Name]", 'Create')) { - New-GitHubRepositoryOrg @params - } + } + 'org' { + if ($PSCmdlet.ShouldProcess("repository for organization [$Owner/$Name]", 'Create')) { + New-GitHubRepositoryOrg @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' - } - Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues - New-GitHubRepositoryFromTemplate @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' } + Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues + New-GitHubRepositoryFromTemplate @params } - '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 + } + '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 } } - } catch { - throw $_ } + } end { diff --git a/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1 b/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1 index 0afc4e02b..96f4c6237 100644 --- a/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1 +++ b/src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1 @@ -55,29 +55,26 @@ } 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" + $baseURL = $script:StatusBaseURL[$Stamp] + + if ($Active) { + $APIURI = "$baseURL/api/v2/scheduled-maintenances/active.json" $response = Invoke-RestMethod -Uri $APIURI -Method Get $response.scheduled_maintenances - } catch { - throw $_ + 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 + } end { diff --git a/src/functions/public/Status/Get-GitHubStatus.ps1 b/src/functions/public/Status/Get-GitHubStatus.ps1 index f8ccb4652..1dada6a2a 100644 --- a/src/functions/public/Status/Get-GitHubStatus.ps1 +++ b/src/functions/public/Status/Get-GitHubStatus.ps1 @@ -44,22 +44,19 @@ } 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 - } - - $APIURI = "$baseURL/api/v2/status.json" + if ($Summary) { + $APIURI = "$baseURL/api/v2/summary.json" $response = Invoke-RestMethod -Uri $APIURI -Method Get - $response.status - } catch { - throw $_ + $response + return } + + $APIURI = "$baseURL/api/v2/status.json" + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.status + } end { diff --git a/src/functions/public/Status/Get-GitHubStatusComponent.ps1 b/src/functions/public/Status/Get-GitHubStatusComponent.ps1 index a8a699740..5aaa7b06d 100644 --- a/src/functions/public/Status/Get-GitHubStatusComponent.ps1 +++ b/src/functions/public/Status/Get-GitHubStatusComponent.ps1 @@ -31,15 +31,11 @@ } process { - try { - $baseURL = $script:StatusBaseURL[$Stamp] - - $APIURI = "$baseURL/api/v2/components.json" - $response = Invoke-RestMethod -Uri $APIURI -Method Get - $response.components - } catch { - throw $_ - } + $baseURL = $script:StatusBaseURL[$Stamp] + + $APIURI = "$baseURL/api/v2/components.json" + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.components } end { diff --git a/src/functions/public/Status/Get-GitHubStatusIncident.ps1 b/src/functions/public/Status/Get-GitHubStatusIncident.ps1 index 8710340b5..2bca48fc4 100644 --- a/src/functions/public/Status/Get-GitHubStatusIncident.ps1 +++ b/src/functions/public/Status/Get-GitHubStatusIncident.ps1 @@ -44,22 +44,18 @@ } process { - try { - $baseURL = $script:StatusBaseURL[$Stamp] + $baseURL = $script:StatusBaseURL[$Stamp] - 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" + if ($Unresolved) { + $APIURI = "$baseURL/api/v2/incidents/unresolved.json" $response = Invoke-RestMethod -Uri $APIURI -Method Get $response.incidents - } catch { - throw $_ + return } + + $APIURI = "$baseURL/api/v2/incidents.json" + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.incidents } end { diff --git a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 index 822227907..a9ee8940c 100644 --- a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 +++ b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 @@ -59,17 +59,13 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - 'Organization' { - Block-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context - } - '__AllParameterSets' { - Block-GitHubUserByUser -Username $Username -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + 'Organization' { + Block-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context + } + '__AllParameterSets' { + Block-GitHubUserByUser -Username $Username -Context $Context } - } catch { - throw $_ } } diff --git a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 index a8628e148..9a507d14c 100644 --- a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 +++ b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 @@ -57,14 +57,10 @@ } process { - try { - if ($Organization) { - Get-GitHubBlockedUserByOrganization -Organization $Organization -PerPage $PerPage -Context $Context - } else { - Get-GitHubBlockedUserByUser -PerPage $PerPage -Context $Context - } - } catch { - throw $_ + if ($Organization) { + Get-GitHubBlockedUserByOrganization -Organization $Organization -PerPage $PerPage -Context $Context + } else { + Get-GitHubBlockedUserByUser -PerPage $PerPage -Context $Context } } diff --git a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 index 7f9d06eb6..f7043118c 100644 --- a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 +++ b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 @@ -69,14 +69,10 @@ } 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 $_ + if ($Organization) { + Test-GitHubBlockedUserByOrganization -Organization $Organization -Username $Username -PerPage $PerPage -Context $Context + } else { + Test-GitHubBlockedUserByUser -Username $Username -PerPage $PerPage -Context $Context } } diff --git a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 index c7f602f45..7495ff593 100644 --- a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 +++ b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 @@ -62,14 +62,10 @@ } process { - try { - if ($Organization) { - Unblock-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context - } else { - Unblock-GitHubUserByUser -Username $Username -Context $Context - } - } catch { - throw $_ + if ($Organization) { + Unblock-GitHubUserByOrganization -Organization $Organization -Username $Username -Context $Context + } else { + Unblock-GitHubUserByUser -Username $Username -Context $Context } } diff --git a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 index ed591a3a7..da5f510a6 100644 --- a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 @@ -48,14 +48,10 @@ } 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 } } diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 index 90ffb73a7..65cf93c6b 100644 --- a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 +++ b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 @@ -50,14 +50,10 @@ } 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 } } diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 index af0f38800..8dd082767 100644 --- a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 @@ -50,14 +50,10 @@ } 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 } } diff --git a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 index 2ae70b097..c3293f3a1 100644 --- a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 @@ -56,14 +56,10 @@ } 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 } } diff --git a/src/functions/public/Users/Get-GitHubUser.ps1 b/src/functions/public/Users/Get-GitHubUser.ps1 index 0744f87e4..5bd094a89 100644 --- a/src/functions/public/Users/Get-GitHubUser.ps1 +++ b/src/functions/public/Users/Get-GitHubUser.ps1 @@ -72,26 +72,22 @@ } process { - try { - switch ($PSCmdlet.ParameterSetName) { - '__AllParameterSets' { - $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-GitHubAllUser -Since $Since -PerPage $PerPage -Context $Context - } + switch ($PSCmdlet.ParameterSetName) { + '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-GitHubAllUser -Since $Since -PerPage $PerPage -Context $Context + } + default { + $user = Get-GitHubMyUser -Context $Context + $social_accounts = Get-GitHubMyUserSocials -Context $Context + $user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force + $user } - } catch { - throw $_ } } From 37d9921da7bb5dcfc873540c6dad3c4fac790c09 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 10:06:41 +0100 Subject: [PATCH 67/71] Alias cleanup --- .../Organization/Blocking/Block-GitHubUserByOrganization.ps1 | 2 -- .../Blocking/Get-GitHubBlockedUserByOrganization.ps1 | 2 -- .../Blocking/Test-GitHubBlockedUserByOrganization.ps1 | 2 -- .../Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 | 2 -- .../private/Organization/Get-GitHubOrganizationByName.ps1 | 2 -- .../Autolinks/Get-GitHubRepositoryAutolinkById.ps1 | 3 ++- .../Repositories/New-GitHubRepositoryFromTemplate.ps1 | 1 - .../Repositories/Repositories/New-GitHubRepositoryOrg.ps1 | 3 ++- .../public/Repositories/Repositories/New-GitHubRepository.ps1 | 3 ++- src/functions/public/Teams/Get-GitHubTeam.ps1 | 1 - src/functions/public/Users/Blocking/Block-GitHubUser.ps1 | 2 -- src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 | 2 -- src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 | 2 -- src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 | 2 -- 14 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 61107ab29..0c179c0be 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -25,8 +25,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] [Alias('login')] [string] $Organization, diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index 61470b46b..e4c6c1d85 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -19,8 +19,6 @@ param( # The organization name. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] - [Alias('owner')] [Alias('login')] [string] $Organization, diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index ffe2fc25b..5a5b1df83 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -25,8 +25,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] [Alias('login')] [string] $Organization, diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index 988d824d9..6d50bd1ad 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -24,8 +24,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] [Alias('login')] [string] $Organization, diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index 40fc84ff1..37aba9e79 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -32,8 +32,6 @@ ValueFromPipelineByPropertyName )] [Alias('login')] - [Alias('org')] - [Alias('owner')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index da8d73721..c9f7c068e 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -21,7 +21,8 @@ param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository without the .git extension. The name is not case sensitive. diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index bd0088220..c63a95e8e 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -51,7 +51,6 @@ # The organization or person who will own the new repository. # To create a new repository in an organization, the authenticated user must be a member of the specified organization. [Parameter(Mandatory)] - [Alias('org')] [string] $Owner, # The name of the new repository. diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index 40517dcab..ab7b2078d 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -63,7 +63,8 @@ filter New-GitHubRepositoryOrg { param( # The account owner of the repository. The name is not case sensitive. [Parameter(Mandatory)] - [Alias('org')] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository. diff --git a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 index 60d7bd9f0..a01592a22 100644 --- a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 @@ -110,7 +110,8 @@ filter New-GitHubRepository { # The account owner of the repository. The name is not case sensitive. [Parameter(ParameterSetName = 'org')] [Parameter(ParameterSetName = 'fork')] - [Alias('org')] + [Alias('Organization')] + [Alias('User')] [string] $Owner, # The name of the repository. diff --git a/src/functions/public/Teams/Get-GitHubTeam.ps1 b/src/functions/public/Teams/Get-GitHubTeam.ps1 index b8a87dca8..6560786b1 100644 --- a/src/functions/public/Teams/Get-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Get-GitHubTeam.ps1 @@ -32,7 +32,6 @@ # The organization name. The name is not case sensitive. # If not provided, the owner from the context will be used. [Parameter()] - [Alias('Org')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. diff --git a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 index a9ee8940c..4d4701ddb 100644 --- a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 +++ b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 @@ -41,8 +41,6 @@ [Parameter( ParameterSetName = '__AllParameterSets' )] - [Alias('org')] - [Alias('owner')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. diff --git a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 index 9a507d14c..a769e0e71 100644 --- a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 +++ b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 @@ -28,8 +28,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] [Alias('login')] [string] $Organization, diff --git a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 index f7043118c..58f9f3dff 100644 --- a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 +++ b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 @@ -41,8 +41,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] [string] $Organization, # The number of results per page (max 100). diff --git a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 index 7495ff593..a61c784d3 100644 --- a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 +++ b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 @@ -39,8 +39,6 @@ ValueFromPipeline, ValueFromPipelineByPropertyName )] - [Alias('org')] - [Alias('owner')] [string] $Organization, # The context to run the command in. Used to get the details for the API call. From c82fcdc30c278daf812458a9abc4b56f098a40f1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 10:10:17 +0100 Subject: [PATCH 68/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20Get-?= =?UTF-8?q?GitHubGitConfig=20function=20for=20improved=20readability=20and?= =?UTF-8?q?=20maintainability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/Git/Get-GitHubGitConfig.ps1 | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/functions/public/Git/Get-GitHubGitConfig.ps1 b/src/functions/public/Git/Get-GitHubGitConfig.ps1 index 950918ce9..dff753103 100644 --- a/src/functions/public/Git/Get-GitHubGitConfig.ps1 +++ b/src/functions/public/Git/Get-GitHubGitConfig.ps1 @@ -25,43 +25,43 @@ } process { - $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue - Write-Debug "GITEXISTS: $gitExists" - if (-not $gitExists) { - Write-Verbose 'Git is not installed. Cannot get git configuration.' - return - } + $gitExists = Get-Command -Name 'git' -ErrorAction SilentlyContinue + Write-Debug "GITEXISTS: $gitExists" + if (-not $gitExists) { + Write-Verbose 'Git is not installed. Cannot get git configuration.' + return + } - $cmdresult = git rev-parse --is-inside-work-tree 2>&1 - Write-Debug "LASTEXITCODE: $LASTEXITCODE" - Write-Debug "CMDRESULT: $cmdresult" - if ($LASTEXITCODE -ne 0) { - Write-Verbose 'Not a git repository. Cannot get git configuration.' - $Global:LASTEXITCODE = 0 - Write-Debug "Resetting LASTEXITCODE: $LASTEXITCODE" - return - } + $cmdresult = git rev-parse --is-inside-work-tree 2>&1 + Write-Debug "LASTEXITCODE: $LASTEXITCODE" + Write-Debug "CMDRESULT: $cmdresult" + if ($LASTEXITCODE -ne 0) { + Write-Verbose 'Not a git repository. Cannot get git configuration.' + $Global:LASTEXITCODE = 0 + Write-Debug "Resetting LASTEXITCODE: $LASTEXITCODE" + return + } - $config = @() - $configList = git config --$Scope --list 2>&1 - if ($LASTEXITCODE -ne 0) { - Write-Verbose "Failed to get git configuration for [$Scope]." - $global:LASTEXITCODE = 0 - Write-Debug "Resetting LASTEXITCODE: $LASTEXITCODE" - return $config - } + $config = @() + $configList = git config --$Scope --list 2>&1 + if ($LASTEXITCODE -ne 0) { + Write-Verbose "Failed to get git configuration for [$Scope]." + $global:LASTEXITCODE = 0 + Write-Debug "Resetting LASTEXITCODE: $LASTEXITCODE" + return $config + } - $configList = $configList | Sort-Object - $configList | ForEach-Object { - Write-Debug "CONFIG: $_" - $name, $value = $_ -split '=', 2 - $name = ('' + $name).Trim() - $value = ('' + $value).Trim() - $config += @{ - $name = $value - } + $configList = $configList | Sort-Object + $configList | ForEach-Object { + Write-Debug "CONFIG: $_" + $name, $value = $_ -split '=', 2 + $name = ('' + $name).Trim() + $value = ('' + $value).Trim() + $config += @{ + $name = $value } - $config + } + $config } From 190efad38f09b7f5ccfbcaa5e38385314b0f60e4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 11:30:56 +0100 Subject: [PATCH 69/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20debug?= =?UTF-8?q?=20and=20verbose=20flags=20from=20GitHub=20app=20installation?= =?UTF-8?q?=20workflow;=20add=20GetDefaultsFromContext=20utility=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Process-PSModule.yml | 3 - CodingStandard.md | 189 ++++++++++++++++++++ examples/Apps/AppManagement.ps1 | 2 +- examples/Apps/EnterpriseApps.ps1 | 12 +- tools/Guidelines.md | 194 --------------------- tools/utilities/GetDefaultsFromContext.ps1 | 21 +++ 6 files changed, 213 insertions(+), 208 deletions(-) create mode 100644 CodingStandard.md delete mode 100644 tools/Guidelines.md create mode 100644 tools/utilities/GetDefaultsFromContext.ps1 diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index 3d703e6a5..5252ed337 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -36,6 +36,3 @@ jobs: TEST_USER_ORG_FG_PAT: ${{ secrets.TEST_USER_ORG_FG_PAT }} TEST_USER_USER_FG_PAT: ${{ secrets.TEST_USER_USER_FG_PAT }} TEST_USER_PAT: ${{ secrets.TEST_USER_PAT }} - with: - Debug: true - Verbose: true diff --git a/CodingStandard.md b/CodingStandard.md new file mode 100644 index 000000000..8e08fafc2 --- /dev/null +++ b/CodingStandard.md @@ -0,0 +1,189 @@ +--- + +# Combined Specification for the Module + +This document outlines the conventions, naming standards, and best practices for building PowerShell functions and classes in this module. It merges all guidelines, including the additional notes and clarifications. + +--- + +## General Coding Standards + +1. **PowerShell Keywords** + - All PowerShell keywords (e.g. `if`, `return`, `throw`, `function`, `param`) **must** be in lowercase. + +2. **Brace Style** + - Use **One True Bracing Style (OTBS)**. + - Opening brace on the same line as the statement; closing brace on its own line. + +3. **Coverage** + - We do **not** need 100% coverage of the GitHub API. + - Maintain a separate file listing the endpoints you intentionally **do not** cover, so the coverage report can mark them accordingly (e.g., ⚠️). + +4. **Convert Filter Types** + - Wherever filters are used, ensure they are implemented as standard PowerShell functions with `begin`, `process`, and `end` blocks. + +--- + +## Functions + +- **Grouping** + - Group functions by the *object type* they handle, using folders named for that object type (e.g. “Repository”), **not** by the API endpoint URL. + +- **Naming** + - Public function name format: **`Verb-GitHubNoun`**. + - Private function name format: **`Verb-GitHubNoun`** (same style but no aliases). + - **`Get-`** functions must **not** include `[CmdletBinding(SupportsShouldProcess)]`. You only use `SupportsShouldProcess` on commands that change or remove data (`Set-`, `Remove-`, `Add-`, etc.). + +- **Default Parameter Sets** + - Do **not** declare `DefaultParameterSetName = '__AllParameterSets'`. + - Only specify a `DefaultParameterSetName` if it is actually different from the first parameter set. + +- **One API Call = One Function** + - If you find that a single function is handling multiple distinct API calls, split it into multiple functions. + +- **Public vs. Private** + 1. **Public Functions** + - Support pipeline input if appropriate. + - Should begin by calling `Resolve-GitHubContext` to handle the `Context` parameter, which can be either a string or a `GitHubContext` object. + - Use parameter sets (with `begin`, `process`, `end`) if you have multiple ways to call the same logical operation. + - If choosing among multiple underlying private functions, use a `switch` statement in the `process` block keyed on the parameter set name. + - If a parameter like `$Repository` is missing, you can default to `$Context.Repo`. If no value is found, **throw** an error. + 2. **Private Functions** + - **No pipeline input**. + - No aliases on either the function or its parameters. + - **`Context` is mandatory** (type `GitHubContext`), since public functions should already have resolved it. + - **`Owner`, `Organization`, `ID`, `Repository`** are also mandatory if required by the endpoint. + - Must not contain logic to default parameters from `Context`; that is resolved in public functions. + +--- + +## Documentation for Functions + +All function documentation follows standard PowerShell help conventions, with some notes: + +1. **.SYNOPSIS**, **.DESCRIPTION**, **.EXAMPLES** + - Examples in your code should include fencing (e.g., triple backticks) because the PSModule framework removes default fences. + +2. **.PARAMETER** + - Do **not** store parameter documentation in a comment block separate from the parameter. Instead, use inline parameter documentation via the `[Parameter()]` attribute and descriptions in triple-slash (`///`) comments above each parameter. + +3. **.NOTES** + - Include a link to the official documentation (if any) that the function is based on, so it’s discoverable via online help. + +4. **.LINK** + - First link should be the function’s own local documentation (generated for the PowerShell module). + - Additional links can point to official GitHub or API documentation. + +--- + +## Parameter Guidelines + +1. **Always Declare [Parameter()]** + - Every parameter must explicitly have a `[Parameter()]` attribute, even if empty. + - Place these attributes in a consistent order (see **Parameter Attributes Order** below). + +2. **Parameter Types** + - Always specify a type, e.g. `[string] $Owner` (rather than `$Owner` alone). + +3. **Parameter Naming** + - Use **PascalCase** for parameters. + - Convert snake_case from the API docs to **PascalCase** in the function. + - **`ID`** should be the short name. If needed, add an alias for a long form (e.g., `[Alias('SomeLongName')]`) or for a different style (`'id'`, `'Id'`), depending on user expectations. + - If the function name implies the object (e.g., `Get-GitHubRepository`), do **not** name the parameter `RepositoryId`. Just `ID` (or `Name`, etc.) suffices. Keep it object-oriented rather than repeating the context. + - `Owner` should always have the aliases: `Organization` and `User`. + - `Username` can have the alias `Login` if relevant for a particular API. + - Use `Repository` (not `Repo`). If you need an alias for backward compatibility, add `[Alias('Repo')]`. + +4. **Parameter Attribute Order** + 1. `[Parameter()]` + 2. `[ValidateNotNullOrEmpty()]` or other validation attributes + 3. `[Alias()]` if any + 4. Then the parameter definition itself: `[string] $ParamName` + +5. **Parameter Defaulting** + - For **public** functions, if the user hasn’t provided a parameter (like `$Repository`), default it from the context: + ```powershell + if (-not $Repository) { + $Repository = $Context.Repo + } + if (-not $Repository) { + throw "Repository not specified and not found in the context." + } + ``` + - For **private** functions, the calling function should already have done this. Private functions assume mandatory parameters. + +6. **Remove `[org]` Alias** + - Do not use `[Alias('org')]` on the `$Organization` parameter. Use `[Alias('User','Organization')]` on `$Owner` instead. + +--- + +## Function Content & Flow + +1. **Structure** + - Always use `begin`, `process`, and `end` blocks. + - **`begin`**: Validate parameters, call `Assert-GitHubContext` if needed, set up any local state. + - Add a comment stating which permissions are required for the API call. + - **`process`**: Main logic, including pipeline handling if public. + - **`end`**: Cleanup if necessary. + +2. **ShouldProcess** + - Only use `[CmdletBinding(SupportsShouldProcess)]` for commands that create, update, or remove data. **Do not** apply it to `Get-` commands. + +3. **API Method Naming** + - Use PascalCase for the method in your splat (e.g., `Post`, `Delete`, `Put`, `Get`). + - The `Method` property in your hashtable to `Invoke-GitHubAPI` (or other REST calls) should reflect that standard. + +4. **Splatting** + - Always splat the API call. The standard order in the splat is: + 1. `Method` + 2. `APIEndpoint` (or `Endpoint`, with `APIEndpoint` as an alias if necessary) + 3. `Body` + 4. `Context` + - Body is always a hashtable containing the payload for `POST`, `PATCH`, or `PUT` calls. + +5. **Removing String Checks** + - Do **not** use `if ([string]::IsNullOrEmpty($Param))`. Instead, check `-not $Param` or rely on `[ValidateNotNullOrEmpty()]`. + +6. **Pipeline Output** + - After calling `Invoke-GitHubAPI @inputObject`, you can **either**: + - `ForEach-Object { Write-Output $_.Response }` + - or `Select-Object -ExpandProperty Response` + - Choose which pattern best fits your scenario, but be consistent within a function. + +--- + +## Classes + +1. **One Class per Resource** + - Each distinct resource type gets its own `.ps1` or `.psm1` with a single class definition. + +2. **Property and Method Naming** + - Use PascalCase for all public properties and methods. + +3. **Return Types / Interfaces** + - Each class that you return should have a consistent interface. + - Remove any properties that are purely “API wrapper” fields (e.g., raw HTTP artifacts that aren’t relevant to the user). + +--- + +## Additional Notes + +1. **Endpoint Coverage File** + - Maintain a list of endpoints you’re deliberately **not** implementing, so that your coverage reporting can include a ⚠️ for them. + +2. **Parameter Name Design** + - Use object-oriented naming that reflects the entity. For example, if the function is `Remove-GitHubRepository`, simply use `-ID` (or `-Name`) rather than `-RepositoryID`. + +3. **Aliases** + - Private functions have **no** aliases (function-level or parameter-level). + - Public functions can add aliases where it makes sense (`Owner` has `-User`/`-Organization`, `Repository` might have `-Repo` alias if needed, `Username` might have `-Login`). + +4. **Mandatory Context for Private** + - Private functions must always expect a resolved `[GitHubContext] $Context`. Public functions handle any string-based or null context resolution logic. + +5. **We Do Not Have to Cover Every Possible API** + - Some endpoints (e.g., “hovercards” or other rarely used features) can be excluded. + +--- + +That’s it. This spec captures all the bullet points and original guidelines in one place. Use it as the authoritative reference for coding style, function naming, parameter declarations, and general best practices in your module. diff --git a/examples/Apps/AppManagement.ps1 b/examples/Apps/AppManagement.ps1 index 3b9e935fc..041d19f19 100644 --- a/examples/Apps/AppManagement.ps1 +++ b/examples/Apps/AppManagement.ps1 @@ -2,7 +2,7 @@ $appIDs = @( 'Iv1.f26b61bc99e69405' ) -$orgs = Get-GitHubAppInstallableOrganization -Enterprise 'msx' #FIXME: Add '#Requires -Modules' for [Get-GitHubEnterpriseInstallableOrganization] Suggestions: GitHub +$orgs = Get-GitHubAppInstallableOrganization -Enterprise 'msx' foreach ($org in $orgs) { foreach ($appID in $appIDs) { Install-GitHubAppOnEnterpriseOrganization -Enterprise msx -Organization $org.login -ClientID $appID -RepositorySelection all diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 index 5c629994a..69de8c402 100644 --- a/examples/Apps/EnterpriseApps.ps1 +++ b/examples/Apps/EnterpriseApps.ps1 @@ -19,12 +19,8 @@ filter Install-GithubApp { [string] $AppID ) - begin { - - } - process { - $installableOrgs = Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Debug -Verbose #FIXME: Add '#Requires -Modules' for [Get-GitHubEnterpriseInstallableOrganization] Suggestions: GitHub + $installableOrgs = Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Debug -Verbose $orgs = $installableOrgs | Where-Object { $_.login -like $organization } foreach ($org in $orgs) { foreach ($appIDitem in $AppID) { @@ -37,12 +33,8 @@ filter Install-GithubApp { } } } - - end { - - } } -$appIDs | Install-GithubApp -Organization $organization -Debug -Verbose +$appIDs | Install-GitHubApp -Organization $organization -Debug -Verbose $installation = Get-GitHubAppInstallation diff --git a/tools/Guidelines.md b/tools/Guidelines.md deleted file mode 100644 index 24eeba15b..000000000 --- a/tools/Guidelines.md +++ /dev/null @@ -1,194 +0,0 @@ -# Guidelines - -Writing down guidelines so that it can be the basis for pester tests. - -## Functions - -- Group functions by the object type they are working with in a folder based on the name of the object, NOT based on the API. -- DefaultParameterSetName must never be declared unless its different the default parameter set. - -### Name - -- Verb-GitHubNoun - based on what object type they are working with. Let parameters dictate the scope of the function. - -#### Name - Public functions - -#### Name - Private functions - -- No aliases - -### Documentation - -#### .SYNOPSIS - -#### .DESCRIPTION - -#### .EXAMPLES - -- PSModule framework removes the default fencing. So, we need to add the fencing back in the examples where we see fit. - -#### .PARAMETERS - -- Parameter docs do not go in the comment block. They are in the `param` block above each parameter. - Principle: Keep documentation close to the code it documents. - -#### .NOTES - -- Have a link to the documentation with the display name of the official documentation. This is so that when user search on the online -function documentation they can search based on the official documentation. - -#### .LINK - -- First link is to the function documentation that is generated for the PowerShell module. -- Other links can be to the official documentation. - -### Parameters - -- Parameters use the PascalCase version of the parameter name in the official documentation. - -#### Parameters - public functions - -- `Context` parameter supports `string` and `GitHubContext`. -> This is why we have `Resolve-GitHubContext` in the public functions. -- Evaluation of default values for other scoping parameters happen in `process` block. -- `Owner` always have `User` and `Organization` as aliases -- `Repository` is always spelled out. -- `ID` when needed, should be the short form, but have the long form as an alias supporting both lower_snake_case and PascalCase. - -#### Parameters - private functions - -- No aliases -- `Context` parameter is `GitHubContext`. Calling function should have resolved the context to a `GitHubContext` object already. - -### Content - -- Use begin, process, end and optionally clean blocks. -- begin block is for parameter validation and setup. -- process block is for the main logic. This should also have a foreach loop for pipelining. -- All context defaults must be evaluated in the process block. -- One API call = one function -- API parameters are always splatted - - The name of the splat is `$inputObject` - - The order of the splat is: - - `Method` - - `APIEndpoint` - - `Body` - - `Context` -- API Body is always a hashtable - -- If function calls `Invoke-GitHubAPI`, `Invoke-RestMethod` or `Invoke-WebRequest` that requires a `Context` parameter: - - Function must also have `Assert-GitHubContext` in begin block. - - Add a comment below `Assert-GitHubContext` stating the permissions needed for the API call. - -### Content - Public - -- If Public function - - Resolve-GitHubContext - -- To select underlying private functions use parameter sets, in a swticth statement. - - Use the `default` block to cover the default parameter set `__AllParameterSets`. - -### Content - Private - -- Pipelining is not supported - -## Classes - -- One class pr type of resource -- Properties are PascalCased (as expected by PowerShell users) - -```pwsh -if ([string]::IsNullOrEmpty($Enterprise)) { - $Enterprise = $Context.Enterprise -} -Write-Debug "Enterprise: [$Enterprise]" - -if ([string]::IsNullOrEmpty($Organization)) { - $Organization = $Context.Organization -} -Write-Debug "Organization: [$Organization]" - -if ([string]::IsNullOrEmpty($Owner)) { - $Owner = $Context.Owner -} -Write-Debug "Owner: [$Owner]" - -if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo -} -Write-Debug "Repo: [$Repo]" - -# What about "Name", "Login", "Username" -``` - - -## TO DO - -In private, make Context Mandatory - -if ([string]::IsNullOrEmpty($Repo)) { - $Repo = $Context.Repo - } -Write-Debug "Repo: [$Repo]" -if (-not $Repo) { throw } - -Remove [org] alias on $organization parameter - -Rename $Repo to $Repository - -Add Alias Organization and User for $Owner prarm -Aliases, one pr line or one pr definition? - -Document: API Method is written in Sentencase/PascalCase, Post, Delete, Put, Get, etc. - -SupportsShouldProcess must not be on Get- functions - -Context Enterprise, Owner, Organization, ID, Repo Are mandatory in private functions - - -Parameters always have a [Parameter()] attribute -Parameters always define type, then a space to the value [string] $String -ID should be the main parameter name -Parameters, snake_case -> PascalCase - -Dont use DefaultParameterSet = '__AllParameterSets' - -Class every return to have an agreed interface -Remove API spefic properties - -Username alias is login - -All PowerShell keywords = lowercase - -Brace style: One True Bracing Style (OTBS) - - -Private functions do not take pipeline params -Private functions have no aliases, on functions or params - -We do really not have to have 100% API coverage... like Hovercards.. ? -convert all filter types to function type (we have begin, process, end) - -Parameter attribute order: -1. Parameter()] -Function attribute order: -y. [CmdletBinding()] -z. param() - - -Output to pipeline, select or foreach? -Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response - } - -Invoke-GitHubAPI @inputObject | Select-Object -ExpandProperty Response - - -Rename APIEndpoint to Endpoint (maybe keep APIEndpoint as alias) - - -Remove if([string]IsNullOrEmpty()) - - -Add a file where we store endponits we do not wish to cover. Update the coverage report with ⚠️ - -Parameter name design: Assume there is an object that is processed. Not RepositoryID for a function that has repository in it. The value/name at hand is related to the object being processed. Object oriented naming. diff --git a/tools/utilities/GetDefaultsFromContext.ps1 b/tools/utilities/GetDefaultsFromContext.ps1 new file mode 100644 index 000000000..4f258e58b --- /dev/null +++ b/tools/utilities/GetDefaultsFromContext.ps1 @@ -0,0 +1,21 @@ +if ([string]::IsNullOrEmpty($Enterprise)) { + $Enterprise = $Context.Enterprise +} +Write-Debug "Enterprise: [$Enterprise]" + +if ([string]::IsNullOrEmpty($Organization)) { + $Organization = $Context.Organization +} +Write-Debug "Organization: [$Organization]" + +if ([string]::IsNullOrEmpty($Owner)) { + $Owner = $Context.Owner +} +Write-Debug "Owner: [$Owner]" + +if ([string]::IsNullOrEmpty($Repo)) { + $Repo = $Context.Repo +} +Write-Debug "Repo: [$Repo]" + +# What about "Name", "Login", "Username" From b72350888c346076b7b7b26edcb1288c78778525 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 11:46:48 +0100 Subject: [PATCH 70/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Standardize=20H?= =?UTF-8?q?TTP=20method=20casing=20in=20API=20calls=20across=20multiple=20?= =?UTF-8?q?scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/public/Config/GitHubConfig.ps1 | 2 +- src/classes/public/Context/GitHubContext.ps1 | 2 +- .../private/Actions/Get-GitHubWorkflowRunByRepo.ps1 | 4 ++-- .../private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 | 2 +- .../Get-GitHubEnterpriseOrganizationAppInstallation.ps1 | 2 +- .../GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 | 2 +- .../Install-GitHubAppOnEnterpriseOrganization.ps1 | 2 +- .../Uninstall-GitHubAppOnEnterpriseOrganization.ps1 | 2 +- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 | 2 +- .../Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 | 2 +- .../private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 | 2 +- .../private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 | 2 +- .../private/Gitignore/Get-GitHubGitignoreByName.ps1 | 2 +- src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 | 2 +- src/functions/private/License/Get-GitHubLicenseByName.ps1 | 2 +- src/functions/private/License/Get-GitHubLicenseList.ps1 | 2 +- .../private/License/Get-GitHubRepositoryLicense.ps1 | 2 +- .../Blocking/Block-GitHubUserByOrganization.ps1 | 2 +- .../Blocking/Get-GitHubBlockedUserByOrganization.ps1 | 2 +- .../Blocking/Test-GitHubBlockedUserByOrganization.ps1 | 2 +- .../Blocking/Unblock-GitHubUserByOrganization.ps1 | 2 +- .../private/Organization/Get-GitHubAllOrganization.ps1 | 2 +- .../private/Organization/Get-GitHubMyOrganization.ps1 | 2 +- .../private/Organization/Get-GitHubOrganizationByName.ps1 | 2 +- .../private/Organization/Get-GitHubUserOrganization.ps1 | 2 +- .../private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 | 2 +- .../Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 | 2 +- .../private/Releases/Releases/Get-GitHubReleaseAll.ps1 | 2 +- .../private/Releases/Releases/Get-GitHubReleaseByID.ps1 | 2 +- .../Releases/Releases/Get-GitHubReleaseByTagName.ps1 | 2 +- .../private/Releases/Releases/Get-GitHubReleaseLatest.ps1 | 2 +- .../Autolinks/Get-GitHubRepositoryAutolinkById.ps1 | 2 +- .../Autolinks/Get-GitHubRepositoryAutolinkList.ps1 | 2 +- .../Repositories/Fork/New-GitHubRepositoryAsFork.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubMyRepositories.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryByName.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryListByID.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryListByOrg.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryListByUser.ps1 | 2 +- .../Repositories/New-GitHubRepositoryFromTemplate.ps1 | 2 +- .../Repositories/Repositories/New-GitHubRepositoryOrg.ps1 | 2 +- .../Repositories/Repositories/New-GitHubRepositoryUser.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 | 2 +- src/functions/private/Teams/Get-GitHubRepoTeam.ps1 | 2 +- .../private/Users/Blocking/Block-GitHubUserByUser.ps1 | 2 +- .../private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 | 2 +- .../private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 | 2 +- .../private/Users/Blocking/Unblock-GitHubUserByUser.ps1 | 2 +- .../private/Users/Emails/Get-GitHubUserAllEmail.ps1 | 2 +- .../private/Users/Emails/Get-GitHubUserPublicEmail.ps1 | 2 +- .../Users/Followers/Get-GitHubUserFollowersOfUser.ps1 | 2 +- .../private/Users/Followers/Get-GitHubUserFollowingMe.ps1 | 2 +- .../private/Users/Followers/Get-GitHubUserFollowingUser.ps1 | 2 +- .../private/Users/Followers/Get-GitHubUserMyFollowers.ps1 | 2 +- .../private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 | 2 +- .../Users/Followers/Test-GitHubUserFollowedByUser.ps1 | 2 +- .../private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 | 2 +- .../private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 | 2 +- .../private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 | 2 +- src/functions/private/Users/Get-GitHubAllUser.ps1 | 2 +- src/functions/private/Users/Get-GitHubMyUser.ps1 | 2 +- src/functions/private/Users/Get-GitHubUserByName.ps1 | 2 +- src/functions/private/Users/Get-GitHubUserCard.ps1 | 2 +- .../private/Users/Keys/Get-GitHubUserKeyForUser.ps1 | 2 +- src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 | 2 +- .../private/Users/Keys/Get-GitHubUserMyKeyById.ps1 | 2 +- .../Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 | 2 +- .../SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 | 2 +- .../SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 | 2 +- .../Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 | 2 +- .../Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 | 2 +- src/functions/public/API/Invoke-GitHubAPI.ps1 | 5 +++-- .../Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 | 2 +- .../Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 | 2 +- .../public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 | 2 +- .../public/Actions/Workflow/Disable-GitHubWorkflow.ps1 | 2 +- .../public/Actions/Workflow/Enable-GitHubWorkflow.ps1 | 2 +- .../public/Actions/Workflow/Get-GitHubWorkflow.ps1 | 2 +- .../public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 | 2 +- .../public/Actions/Workflow/Start-GitHubWorkflow.ps1 | 2 +- .../Add-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../Get-GitHubAppAccessibleRepository.ps1 | 2 +- .../Get-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../Remove-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../Update-GitHubAppInstallationRepositoryAccess.ps1 | 2 +- .../GitHub App/Get-GitHubAppInstallableOrganization.ps1 | 2 +- .../GitHub App/New-GitHubAppInstallationAccessToken.ps1 | 2 +- .../Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 | 2 +- .../Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 | 2 +- .../Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 | 2 +- src/functions/public/Branches/Get-GitHubRepoBranch.ps1 | 2 +- src/functions/public/Emojis/Get-GitHubEmoji.ps1 | 2 +- src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 | 2 +- src/functions/public/Markdown/Get-GitHubMarkdown.ps1 | 2 +- src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 | 2 +- src/functions/public/Meta/Get-GitHubApiVersion.ps1 | 2 +- src/functions/public/Meta/Get-GitHubMeta.ps1 | 2 +- src/functions/public/Meta/Get-GitHubOctocat.ps1 | 2 +- src/functions/public/Meta/Get-GitHubRoot.ps1 | 2 +- src/functions/public/Meta/Get-GitHubZen.ps1 | 2 +- .../Organization/Members/Get-GitHubOrganizationMember.ps1 | 2 +- .../Members/Get-GitHubOrganizationPendingInvitation.ps1 | 2 +- .../Members/New-GitHubOrganizationInvitation.ps1 | 2 +- .../Members/Remove-GitHubOrganizationInvitation.ps1 | 2 +- .../public/Organization/Remove-GitHubOrganization.ps1 | 4 ++-- .../public/Organization/Update-GitHubOrganization.ps1 | 2 +- .../Update-GitHubOrganizationSecurityFeature.ps1 | 2 +- src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 | 2 +- .../public/Releases/Assets/Add-GitHubReleaseAsset.ps1 | 2 +- .../public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 | 4 ++-- .../public/Releases/Assets/Set-GitHubReleaseAsset.ps1 | 2 +- .../public/Releases/Releases/New-GitHubRelease.ps1 | 2 +- .../public/Releases/Releases/New-GitHubReleaseNote.ps1 | 2 +- .../public/Releases/Releases/Remove-GitHubRelease.ps1 | 4 ++-- .../public/Releases/Releases/Set-GitHubRelease.ps1 | 2 +- .../Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 | 2 +- .../Autolinks/Remove-GitHubRepositoryAutolink.ps1 | 4 ++-- .../CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 | 2 +- ...isable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 | 2 +- .../Repositories/Disable-GitHubRepositorySecurityFix.ps1 | 2 +- .../Disable-GitHubRepositoryVulnerabilityAlert.ps1 | 2 +- ...Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 | 2 +- .../Repositories/Enable-GitHubRepositorySecurityFix.ps1 | 2 +- .../Enable-GitHubRepositoryVulnerabilityAlert.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryActivity.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryCodeownersError.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryContributor.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryFork.ps1 | 2 +- .../Repositories/Get-GitHubRepositoryLanguage.ps1 | 2 +- .../Repositories/Get-GitHubRepositorySecurityFix.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTag.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 | 2 +- .../Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 | 2 +- .../Repositories/Repositories/Move-GitHubRepository.ps1 | 2 +- .../Repositories/Repositories/Remove-GitHubRepository.ps1 | 4 ++-- .../Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 | 2 +- .../Repositories/Start-GitHubRepositoryEvent.ps1 | 2 +- .../Test-GitHubRepositoryVulnerabilityAlert.ps1 | 2 +- .../Repositories/Repositories/Update-GitHubRepository.ps1 | 2 +- .../RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 | 2 +- .../RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 | 2 +- .../Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 | 2 +- .../Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 | 2 +- .../Tags/Remove-GitHubRepositoryTagProtection.ps1 | 4 ++-- src/functions/public/Teams/New-GitHubTeam.ps1 | 2 +- src/functions/public/Teams/Remove-GitHubTeam.ps1 | 4 ++-- src/functions/public/Teams/Update-GitHubTeam.ps1 | 2 +- src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 | 2 +- .../public/Users/Emails/Remove-GitHubUserEmail.ps1 | 4 ++-- .../Users/Emails/Update-GitHubUserEmailVisibility.ps1 | 2 +- .../public/Users/Followers/Add-GitHubUserFollowing.ps1 | 2 +- .../public/Users/Followers/Remove-GitHubUserFollowing.ps1 | 2 +- .../public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 | 2 +- .../public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 | 4 ++-- src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 | 2 +- src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 | 6 +++--- .../Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 | 2 +- .../Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 | 4 ++-- .../public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 | 2 +- .../Users/Social-Accounts/Remove-GitHubUserSocial.ps1 | 4 ++-- src/functions/public/Users/Update-GitHubUser.ps1 | 2 +- 162 files changed, 178 insertions(+), 177 deletions(-) diff --git a/src/classes/public/Config/GitHubConfig.ps1 b/src/classes/public/Config/GitHubConfig.ps1 index 02fdd1eb5..32a7b5bfc 100644 --- a/src/classes/public/Config/GitHubConfig.ps1 +++ b/src/classes/public/Config/GitHubConfig.ps1 @@ -23,7 +23,7 @@ # The default value for the HTTP protocol version. [string] $HttpVersion - # The default value for the 'per_page' API parameter used in 'Get' functions that support paging. + # The default value for the 'per_page' API parameter used in 'GET' functions that support paging. [int] $PerPage # Simple parameterless constructor diff --git a/src/classes/public/Context/GitHubContext.ps1 b/src/classes/public/Context/GitHubContext.ps1 index cc930e252..8145217cd 100644 --- a/src/classes/public/Context/GitHubContext.ps1 +++ b/src/classes/public/Context/GitHubContext.ps1 @@ -59,7 +59,7 @@ # The default value for the HTTP protocol version. [string] $HttpVersion - # The default value for the 'per_page' API parameter used in 'Get' functions that support paging. + # The default value for the 'per_page' API parameter used in 'GET' functions that support paging. [int] $PerPage # Simple parameterless constructor diff --git a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 index 013824138..dfc12141b 100644 --- a/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 +++ b/src/functions/private/Actions/Get-GitHubWorkflowRunByRepo.ps1 @@ -106,10 +106,10 @@ } $inputObject = @{ - Context = $Context - APIEndpoint = "/repos/$Owner/$Repository/actions/runs" Method = 'GET' + APIEndpoint = "/repos/$Owner/$Repository/actions/runs" Body = $body + Context = $Context } Invoke-GitHubAPI @inputObject | ForEach-Object { diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 index 780b0aada..f7f0c4cba 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 @@ -36,7 +36,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/app' Context = $Context } diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 index 9458c8e2a..dde6598a6 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubEnterpriseOrganizationAppInstallation.ps1 @@ -56,7 +56,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" Body = $body Context = $Context diff --git a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 index 99dc2eea5..818e26128 100644 --- a/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubOrganizationAppInstallation.ps1 @@ -48,7 +48,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization/installations" Body = $body Context = $Context diff --git a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 index 97ba02be6..86ad14af4 100644 --- a/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Install-GitHubAppOnEnterpriseOrganization.ps1 @@ -57,7 +57,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations" Body = $body Context = $Context diff --git a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index 9a54a1eda..5555145e4 100644 --- a/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID" Context = $Context } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index 754242cea..d2a451fb1 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -39,7 +39,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/app/hook/deliveries/$ID" Context = $Context } diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 2e1b05468..243c15c8a 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -42,7 +42,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/app/hook/deliveries' Body = $body Context = $Context diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 index c886d3fa4..ed32bc697 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubAccessToken.ps1 @@ -71,7 +71,7 @@ } $RESTParams = @{ - Method = 'Post' + Method = 'POST' Uri = "https://$HostName/login/oauth/access_token" Headers = $headers Body = $body diff --git a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 index 9431663f1..9341aedec 100644 --- a/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 +++ b/src/functions/private/Auth/DeviceFlow/Request-GitHubDeviceCode.ps1 @@ -50,7 +50,7 @@ } $RESTParams = @{ - Method = 'Post' + Method = 'POST' Uri = "https://$HostName/login/device/code" Headers = $headers Body = $body diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 index dc69d7627..037907a32 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 @@ -35,7 +35,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/gitignore/templates/$Name" Accept = 'application/vnd.github.raw+json' Context = $Context diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 index b3230fd97..e5e925cef 100644 --- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 +++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 @@ -33,7 +33,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/gitignore/templates' Context = $Context } diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1 index 5c6b1b2a1..6bf335b71 100644 --- a/src/functions/private/License/Get-GitHubLicenseByName.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1 @@ -38,7 +38,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/licenses/$Name" Accept = 'application/vnd.github+json' Context = $Context diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1 index 1ada0eb20..ea035e964 100644 --- a/src/functions/private/License/Get-GitHubLicenseList.ps1 +++ b/src/functions/private/License/Get-GitHubLicenseList.ps1 @@ -34,7 +34,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/licenses' Context = $Context } diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 index 91fab62a6..de5ce94c0 100644 --- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 +++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 @@ -52,7 +52,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/license" ContentType = $contentType Context = $Context diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 index 0c179c0be..90b9e5602 100644 --- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 @@ -50,7 +50,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/orgs/$Organization/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 index e4c6c1d85..ec1076277 100644 --- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 @@ -45,7 +45,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization/blocks" Body = $body Context = $Context diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 index 5a5b1df83..5a6a1729e 100644 --- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 @@ -49,7 +49,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 index 6d50bd1ad..feac1635c 100644 --- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 +++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 @@ -50,7 +50,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/orgs/$Organization/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 index 43b410332..143b24978 100644 --- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 @@ -50,7 +50,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/organizations' Body = $body Context = $Context diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 index 6a7817b36..b2cf45b2c 100644 --- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 @@ -48,7 +48,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/orgs' Body = $body Context = $Context diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 index 37aba9e79..82044c881 100644 --- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 +++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 @@ -48,7 +48,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization" Context = $Context } diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 index e51be1fda..5da211dfc 100644 --- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 +++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 @@ -50,7 +50,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/orgs" Body = $body Context = $Context diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 index ffd56af31..e7a739fba 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 @@ -47,7 +47,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" Context = $Context } diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 index 4c3e63257..512f93e4a 100644 --- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 +++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 @@ -56,7 +56,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/releases/$ID/assets" Body = $body Context = $Context diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 index 834416933..bd5c52614 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 @@ -50,7 +50,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/releases" Body = $body Context = $Context diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 index a7ca3a32e..dc0c5c030 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 @@ -45,7 +45,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 index ea447b8e0..519cf54f4 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/releases/tags/$Tag" Context = $Context } diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 index 478e8128d..80f7a6936 100644 --- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 +++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/releases/latest" Context = $Context } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 index c9f7c068e..911d64a31 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 @@ -49,7 +49,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/autolinks/$ID" Context = $Context } diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 index 0fed912df..909c59277 100644 --- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 +++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/autolinks" Context = $Context } diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 index 35bba9061..33e22db8d 100644 --- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 +++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 @@ -82,7 +82,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/forks" Body = $body Context = $Context diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 index f1e964561..e457be1c0 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 @@ -143,7 +143,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/repos' body = $body Context = $Context diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 index 21c551c6c..c70381b38 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository" Context = $Context } diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 index 6effb2de6..327f46ddb 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 @@ -45,7 +45,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/repositories' Body = $body Context = $Context diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 index 4e5add734..2d90213b9 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 @@ -77,7 +77,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Owner/repos" Body = $body Context = $Context diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 index a8aa65066..62be02f6f 100644 --- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 +++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 @@ -79,7 +79,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/repos" Body = $body Context = $Context diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 index c63a95e8e..ccc0f6642 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 @@ -93,7 +93,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$TemplateOwner/$TemplateRepo/generate" Body = $body Context = $Context diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 index ab7b2078d..8b363ec27 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 @@ -246,7 +246,7 @@ filter New-GitHubRepositoryOrg { } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/orgs/$Owner/repos" Body = $body Context = $Context diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 index 7f200a2e7..15c3ce1a2 100644 --- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 +++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 @@ -239,7 +239,7 @@ filter New-GitHubRepositoryUser { } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/user/repos' Body = $body Context = $Context diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 index 8edf2fdae..fabed8ed5 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamByName.ps1 @@ -36,7 +36,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization/teams/$Name" Context = $Context } diff --git a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 index 5874a45ff..82a885e6e 100644 --- a/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 +++ b/src/functions/private/Teams/Get-GitHubRESTTeamListByOrg.ps1 @@ -33,7 +33,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization/teams" Context = $Context } diff --git a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 index 44c4044c7..beb962a7f 100644 --- a/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/functions/private/Teams/Get-GitHubRepoTeam.ps1 @@ -25,7 +25,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/teams" Context = $Context } diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 index 69b67ab2d..5ded734db 100644 --- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/user/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 index b2f2c2dab..06a0d10c8 100644 --- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 @@ -40,7 +40,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/blocks' Body = $body Context = $Context diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 index 55abe7880..bb9f3cd47 100644 --- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 @@ -52,7 +52,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/user/blocks/$Username" Body = $body Context = $Context diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 index 2106321e5..1a476643d 100644 --- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 +++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/user/blocks/$Username" Context = $Context } diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 index ce5a12a5e..2f6ed0c39 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 @@ -41,7 +41,7 @@ per_page = $PerPage } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/emails' Body = $body Context = $Context diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 index 8d30f8aa8..9472d3844 100644 --- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 +++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 @@ -44,7 +44,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/public_emails' Body = $body Context = $Context diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 index c5421bb81..9a5717989 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 @@ -50,7 +50,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/followers" Body = $body Context = $Context diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 index 2b1e3648d..1aac909a0 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 @@ -41,7 +41,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/following' Body = $body Context = $Context diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 index 2f6a50199..86c3ea4d4 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 @@ -50,7 +50,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/following" Body = $body Context = $Context diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 index 2020f97d9..ca171a676 100644 --- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 +++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 @@ -45,7 +45,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/followers' Body = $body Context = $Context diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 index 1c13e72cc..5b9c2eb3a 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/user/following/$Username" Context = $Context } diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 index 096ecfc0b..711d6bd38 100644 --- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 +++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 @@ -46,7 +46,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/following/$Follows" Context = $Context } diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 index 5de1341f4..a4b53da27 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 @@ -49,7 +49,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/gpg_keys" Body = $body Context = $Context diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 index 2ba32a3d6..df23a99e2 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 @@ -43,7 +43,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/gpg_keys' Body = $body Context = $Context diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 index 762a06eb5..b08e22e64 100644 --- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 +++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/user/gpg_keys/$ID" Context = $Context } diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1 index 90c9a84fa..f6737a8b0 100644 --- a/src/functions/private/Users/Get-GitHubAllUser.ps1 +++ b/src/functions/private/Users/Get-GitHubAllUser.ps1 @@ -50,7 +50,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/users' Body = $body Context = $Context diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1 index ac651d081..fd8e2ef99 100644 --- a/src/functions/private/Users/Get-GitHubMyUser.ps1 +++ b/src/functions/private/Users/Get-GitHubMyUser.ps1 @@ -34,7 +34,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user' Context = $Context } diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1 index 3aaa54162..dec316116 100644 --- a/src/functions/private/Users/Get-GitHubUserByName.ps1 +++ b/src/functions/private/Users/Get-GitHubUserByName.ps1 @@ -52,7 +52,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username" Context = $Context } diff --git a/src/functions/private/Users/Get-GitHubUserCard.ps1 b/src/functions/private/Users/Get-GitHubUserCard.ps1 index e5804dd57..15c78b811 100644 --- a/src/functions/private/Users/Get-GitHubUserCard.ps1 +++ b/src/functions/private/Users/Get-GitHubUserCard.ps1 @@ -58,7 +58,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/hovercard" Body = $body Context = $Context diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 index dca33a90e..bc374421c 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 @@ -49,7 +49,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/keys" Body = $body Context = $Context diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 index f062bdba7..caeed8684 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 @@ -43,7 +43,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/keys' Body = $body Context = $Context diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 index f905f5a95..b46ce6ad7 100644 --- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 +++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/user/keys/$ID" Context = $Context } 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 17b29af8f..26f028e2d 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 @@ -43,7 +43,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/ssh_signing_keys' Body = $body Context = $Context 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 029be0952..34b13c546 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 @@ -42,7 +42,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/user/ssh_signing_keys/$ID" Context = $Context } 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 49f29c23f..4be8b3a64 100644 --- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 +++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 @@ -49,7 +49,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/ssh_signing_keys" Body = $body Context = $Context diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 index b26950bcd..d3d3a745e 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 @@ -41,7 +41,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/user/social_accounts' Body = $body Context = $Context diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 index dcfa7a5ce..876314349 100644 --- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 +++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 @@ -40,7 +40,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/users/$Username/social_accounts" Context = $Context } diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1 index 4f7e42990..c06dfe242 100644 --- a/src/functions/public/API/Invoke-GitHubAPI.ps1 +++ b/src/functions/public/API/Invoke-GitHubAPI.ps1 @@ -28,7 +28,8 @@ filter Invoke-GitHubAPI { param( # The HTTP method to be used for the API request. It can be one of the following: GET, POST, PUT, DELETE, or PATCH. [Parameter()] - [Microsoft.PowerShell.Commands.WebRequestMethod] $Method = 'Get', + [ValidateSet('GET', 'POST', 'PUT', 'DELETE', 'PATCH')] + $Method = 'GET', # The base URI for the GitHub API. This is usually `https://api.github.com`, but can be adjusted if necessary. [Parameter( @@ -157,7 +158,7 @@ filter Invoke-GitHubAPI { if ($Body) { # Use body to create the query string for certain situations - if ($Method -eq 'Get') { + if ($Method -eq 'GET') { # If body conatins 'per_page' and its is null, set it to $context.PerPage if ($Body['per_page'] -eq 0) { Write-Debug "Setting per_page to the default value in context [$($Context.PerPage)]." diff --git a/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 index 74bf22dbb..10d3374fd 100644 --- a/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Remove-GitHubWorkflowRun.ps1 @@ -57,7 +57,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "repos/$Owner/$Repository/actions/runs/$ID" Context = $Context } diff --git a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 index 887a45891..907ce26b8 100644 --- a/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Restart-GitHubWorkflowRun.ps1 @@ -53,7 +53,7 @@ process { $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/rerun" Context = $Context } diff --git a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 index 454affeba..052b404d9 100644 --- a/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 +++ b/src/functions/public/Actions/Workflow Run/Stop-GitHubWorkflowRun.ps1 @@ -53,7 +53,7 @@ process { $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/actions/runs/$ID/cancel" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 index 420a807f4..0b5070875 100644 --- a/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Disable-GitHubWorkflow.ps1 @@ -43,7 +43,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/disable" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 index 3ba7036ed..26fe8df5d 100644 --- a/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Enable-GitHubWorkflow.ps1 @@ -40,7 +40,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/enable" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 index 883933483..ce06cd825 100644 --- a/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflow.ps1 @@ -61,7 +61,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows" Body = $body Context = $Context diff --git a/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 index 3b27d7839..9fdcf09aa 100644 --- a/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 +++ b/src/functions/public/Actions/Workflow/Get-GitHubWorkflowUsage.ps1 @@ -49,7 +49,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/timing" Context = $Context } diff --git a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 index 81f1dce53..e4994bf9b 100644 --- a/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 +++ b/src/functions/public/Actions/Workflow/Start-GitHubWorkflow.ps1 @@ -74,7 +74,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/actions/workflows/$ID/dispatches" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 index 5417dad11..c15db0c18 100644 --- a/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Add-GitHubAppInstallationRepositoryAccess.ps1 @@ -68,7 +68,7 @@ } $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/add" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 index 43710de83..3f5d442ac 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppAccessibleRepository.ps1 @@ -60,7 +60,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations/$Organization/accessible_repositories" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 index 277b0fb3f..ffdb353de 100644 --- a/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Get-GitHubAppInstallationRepositoryAccess.ps1 @@ -70,7 +70,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 index 56841d851..e6934724c 100644 --- a/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Remove-GitHubAppInstallationRepositoryAccess.ps1 @@ -68,7 +68,7 @@ } $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories/remove" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 index 583083d22..309a890b1 100644 --- a/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 +++ b/src/functions/public/Apps/GitHub App Installations/Update-GitHubAppInstallationRepositoryAccess.ps1 @@ -83,7 +83,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$ID/repositories" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 index 8cc6baf15..153d87077 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 @@ -44,7 +44,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations" Body = $body Context = $Context diff --git a/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 index 4ceac55bc..ab45043b2 100644 --- a/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 +++ b/src/functions/public/Apps/GitHub App/New-GitHubAppInstallationAccessToken.ps1 @@ -74,7 +74,7 @@ process { $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/app/installations/$ID/access_tokens" Context = $Context } diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 index 32e48b5ab..9b4441214 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 @@ -35,7 +35,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/app/hook/config' Context = $Context } diff --git a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 index 88ddd4988..89a8ebecf 100644 --- a/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Invoke-GitHubAppWebhookReDelivery.ps1 @@ -49,7 +49,7 @@ process { $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/app/hook/deliveries/$ID/attempts" Context = $Context } diff --git a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 index 574dfe353..931bc777f 100644 --- a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 +++ b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 @@ -63,7 +63,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = '/app/hook/config' Body = $body Context = $Context diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 index 512a00564..868519613 100644 --- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 +++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/branches" Context = $Context } diff --git a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 index 4c6146a96..76b80b280 100644 --- a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 +++ b/src/functions/public/Emojis/Get-GitHubEmoji.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/emojis' Context = $Context } diff --git a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 index e3c13aee4..d908028ce 100644 --- a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 +++ b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 @@ -42,7 +42,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/graphql' Body = $body Context = $Context diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 index 5fbb8d5cd..26ea0073a 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 @@ -57,7 +57,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/markdown' Body = $body Context = $Context diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 index 2b95365c8..d381f9c95 100644 --- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 +++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 @@ -42,7 +42,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/markdown/raw' ContentType = 'text/plain' Body = $body diff --git a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 index fed1c2fce..363ebc3e7 100644 --- a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 +++ b/src/functions/public/Meta/Get-GitHubApiVersion.ps1 @@ -32,7 +32,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' ApiEndpoint = '/versions' Context = $Context } diff --git a/src/functions/public/Meta/Get-GitHubMeta.ps1 b/src/functions/public/Meta/Get-GitHubMeta.ps1 index 77861c59b..7d837185e 100644 --- a/src/functions/public/Meta/Get-GitHubMeta.ps1 +++ b/src/functions/public/Meta/Get-GitHubMeta.ps1 @@ -40,7 +40,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' ApiEndpoint = '/meta' Context = $Context } diff --git a/src/functions/public/Meta/Get-GitHubOctocat.ps1 b/src/functions/public/Meta/Get-GitHubOctocat.ps1 index 975c95ac8..99e0eeaae 100644 --- a/src/functions/public/Meta/Get-GitHubOctocat.ps1 +++ b/src/functions/public/Meta/Get-GitHubOctocat.ps1 @@ -45,7 +45,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/octocat' Body = $body Context = $Context diff --git a/src/functions/public/Meta/Get-GitHubRoot.ps1 b/src/functions/public/Meta/Get-GitHubRoot.ps1 index bb21e6a0a..86b4ff457 100644 --- a/src/functions/public/Meta/Get-GitHubRoot.ps1 +++ b/src/functions/public/Meta/Get-GitHubRoot.ps1 @@ -31,7 +31,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/' Context = $Context } diff --git a/src/functions/public/Meta/Get-GitHubZen.ps1 b/src/functions/public/Meta/Get-GitHubZen.ps1 index 1acd7c953..9945b8cdc 100644 --- a/src/functions/public/Meta/Get-GitHubZen.ps1 +++ b/src/functions/public/Meta/Get-GitHubZen.ps1 @@ -31,7 +31,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/zen' Context = $Context } diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 index e82ea1a19..6b8cdf5c8 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 @@ -55,7 +55,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization/members" Body = $body Context = $Context diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 index cae4a29cf..242b6a036 100644 --- a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 +++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 @@ -64,7 +64,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/orgs/$Organization/invitations" Body = $body Context = $Context diff --git a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 index 4606230aa..128a7d0f6 100644 --- a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 @@ -85,7 +85,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/orgs/$Organization/invitations" Body = $body Context = $Context diff --git a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 index 73fd9158f..38f4ba031 100644 --- a/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 +++ b/src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/orgs/$Organization/invitations/$ID" Context = $Context } diff --git a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 index b98b5bf0c..b0443d96f 100644 --- a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Remove-GitHubOrganization.ps1 @@ -43,12 +43,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/orgs/$Organization" Context = $Context } - if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("organization [$Organization]", 'DELETE')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Organization/Update-GitHubOrganization.ps1 b/src/functions/public/Organization/Update-GitHubOrganization.ps1 index 30f972cf0..a3d6ecd55 100644 --- a/src/functions/public/Organization/Update-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganization.ps1 @@ -204,7 +204,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/orgs/$Organization" Body = $body Context = $Context diff --git a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 index 802fb86c3..c087c6734 100644 --- a/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 +++ b/src/functions/public/Organization/Update-GitHubOrganizationSecurityFeature.ps1 @@ -84,7 +84,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/orgs/$Organization/$SecurityProduct/$Enablement" Body = $body Context = $Context diff --git a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 index bdba61482..de7da0229 100644 --- a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 +++ b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 @@ -49,7 +49,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = '/rate_limit' Context = $Context } diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 index 7e7a5efa1..b52da2c5e 100644 --- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 @@ -131,7 +131,7 @@ $uploadURI = $release.upload_url -replace '{\?name,label}', "?name=$($Name)&label=$($Label)" $inputObject = @{ - Method = 'Post' + Method = 'POST' URI = $uploadURI ContentType = $ContentType UploadFilePath = $FilePath diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 index 295eab381..b6eaecfe8 100644 --- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 @@ -46,12 +46,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" Context = $Context } - if ($PSCmdlet.ShouldProcess("Asset with ID [$ID] in [$Owner/$Repository]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Asset with ID [$ID] in [$Owner/$Repository]", 'DELETE')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 index 7041a7721..a5def48de 100644 --- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 +++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 @@ -67,7 +67,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/repos/$Owner/$Repository/releases/assets/$ID" Body = $body Context = $Context diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 index ab2f2d755..021a3900a 100644 --- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 @@ -106,7 +106,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/releases" Body = $body Context = $Context diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 index 7a0fa45f4..a4ccd2d8f 100644 --- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 +++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 @@ -115,7 +115,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/releases/generate-notes" Body = $body } diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 index 80542040e..1184c427e 100644 --- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 @@ -49,12 +49,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" Context = $Context } - if ($PSCmdlet.ShouldProcess("Release with ID [$ID] in [$Owner/$Repository]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Release with ID [$ID] in [$Owner/$Repository]", 'DELETE')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 index 5108990a5..1559ef234 100644 --- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 +++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 @@ -103,7 +103,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/repos/$Owner/$Repository/releases/$ID" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 index daffe6beb..4ba3ae2dd 100644 --- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 @@ -65,7 +65,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/autolinks" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 index c662e7337..61828136c 100644 --- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 +++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 @@ -49,13 +49,13 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository/autolinks/$ID" Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Autolink with ID [$ID] for repository [$Owner/$Repository]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Autolink with ID [$ID] for repository [$Owner/$Repository]", 'DELETE')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 index 2bad4715d..ca11ddcd2 100644 --- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 +++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 @@ -45,7 +45,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/properties/values" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index f92a7fafd..b8550b69f 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository/private-vulnerability-reporting" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 index a3c0a256d..3c6c8879b 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 index ba694aef5..19b2a9128 100644 --- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 index 45ed9ac0a..b7fa7fded 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/repos/$Owner/$Repository/private-vulnerability-reporting" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 index 1617d42a4..c9ff4d15e 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 index c820d34e6..b6b2ac79d 100644 --- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 @@ -45,7 +45,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index 3c325fe1d..ee99c5c17 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -129,7 +129,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/activity" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 index 14fd9511b..ee15aeafe 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 @@ -55,7 +55,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/codeowners/errors" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 index 47dbaae2a..b5023d916 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 @@ -61,7 +61,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/contributors" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 index 0335d6158..9ea73adda 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 @@ -57,7 +57,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/forks" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 index 715221bb3..4476bcc98 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 @@ -43,7 +43,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/languages" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 index cf84e7180..5f6c671ae 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 @@ -45,7 +45,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/automated-security-fixes" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 index 1be5b3066..b6e883ae5 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 @@ -51,7 +51,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/tags" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 index 301e3c881..b2970e9df 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 @@ -59,7 +59,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/teams" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 index cd92be828..7ed6016d6 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 @@ -47,7 +47,7 @@ } $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/topics" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 index 9a975465d..590ee728b 100644 --- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 @@ -68,7 +68,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/transfer" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 index 0f363939e..4ce1579f6 100644 --- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 @@ -44,12 +44,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository" Context = $Context } - if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repository]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("repo [$Owner/$Repository]", 'DELETE')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 index ea243e9b6..e5ac86ce7 100644 --- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 +++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 @@ -50,7 +50,7 @@ } $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/repos/$Owner/$Repository/topics" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 index 490d53d10..db4b33d32 100644 --- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 +++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 @@ -84,7 +84,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/dispatches" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 index 12f361893..9e1f0ff0e 100644 --- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 +++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 @@ -46,7 +46,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/vulnerability-alerts" Context = $Context } diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 index 4c708d204..d12467553 100644 --- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 +++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 @@ -223,7 +223,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/repos/$Owner/$Repository" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 index d7233a5e9..ac524015b 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 @@ -49,7 +49,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/rulesets/rule-suites/$ID" Context = $Context } diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 index 15f040993..036147e51 100644 --- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 +++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 @@ -87,7 +87,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/rulesets/rule-suites" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 index 50759e4a2..545058183 100644 --- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 @@ -44,7 +44,7 @@ process { $inputObject = @{ - Method = 'Get' + Method = 'GET' APIEndpoint = "/repos/$Owner/$Repository/tags/protection" Context = $Context } diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 index 41910a68c..88fca8de4 100644 --- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 @@ -51,7 +51,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/repos/$Owner/$Repository/tags/protection" Body = $body Context = $Context diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 index 952adfed1..9acfe1e77 100644 --- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 +++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 @@ -47,12 +47,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/repos/$Owner/$Repository/tags/protection/$TagProtectionId" Context = $Context } - if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repository]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("tag protection state with ID [$TagProtectionId] for repository [$Owner/$Repository]", 'DELETE')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1 index 74a9d2297..8e8d5253e 100644 --- a/src/functions/public/Teams/New-GitHubTeam.ps1 +++ b/src/functions/public/Teams/New-GitHubTeam.ps1 @@ -109,7 +109,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = "/orgs/$Organization/teams" Body = $body Context = $Context diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1 index 71889c919..4a7b4a022 100644 --- a/src/functions/public/Teams/Remove-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1 @@ -47,12 +47,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/orgs/$Organization/teams/$Name" Context = $Context } - if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Delete')) { + if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'DELETE')) { Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1 index 98ab729c3..843a038d5 100644 --- a/src/functions/public/Teams/Update-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Update-GitHubTeam.ps1 @@ -100,7 +100,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = "/orgs/$Organization/teams/$Name" Body = $body Context = $Context diff --git a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 index 7d4527afd..64bcc2e42 100644 --- a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 @@ -47,7 +47,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/user/emails' Body = $body Context = $Context diff --git a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 index 2ace0b7de..e797bc277 100644 --- a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 +++ b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 @@ -45,13 +45,13 @@ } $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = '/user/emails' Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Email addresses [$($Email -join ', ')]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Email addresses [$($Email -join ', ')]", 'DELETE')) { $null = Invoke-GitHubAPI @inputObject | ForEach-Object { Write-Output $_.Response } diff --git a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 index 947dbe9a2..ce0a4ca91 100644 --- a/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 +++ b/src/functions/public/Users/Emails/Update-GitHubUserEmailVisibility.ps1 @@ -51,7 +51,7 @@ } $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = '/user/email/visibility' Body = $body Context = $Context diff --git a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 index 3f4c0a79a..6937844b7 100644 --- a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 @@ -43,7 +43,7 @@ process { $inputObject = @{ - Method = 'Put' + Method = 'PUT' APIEndpoint = "/user/following/$Username" Context = $Context } diff --git a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 index 57512912d..50c05bdcf 100644 --- a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 +++ b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 @@ -41,7 +41,7 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/user/following/$Username" Context = $Context } diff --git a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 index 8b8503b82..7666ed9f5 100644 --- a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 @@ -61,7 +61,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/user/gpg_keys' Body = $body Context = $Context diff --git a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 index 3398b9745..6dd0d0c59 100644 --- a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 +++ b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 @@ -41,12 +41,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/user/gpg_keys/$ID" Context = $Context } - if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("GPG key with ID [$ID]", 'DELETE')) { Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 index a676dda90..de8375a50 100644 --- a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 @@ -55,7 +55,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/user/keys' Body = $body Context = $Context diff --git a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 index 535b76464..21eb19876 100644 --- a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 +++ b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 @@ -42,12 +42,12 @@ process { $inputObject = @{ - Context = $Context + Method = 'DELETE' APIEndpoint = "/user/keys/$ID" - Method = 'Delete' + Context = $Context } - if ($PSCmdlet.ShouldProcess("Key with ID [$ID]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Key with ID [$ID]", 'DELETE')) { Invoke-GitHubAPI @inputObject } } 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 ff451fadf..0a3e252f6 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 @@ -57,7 +57,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/user/ssh_signing_keys' Body = $body Context = $Context 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 dcda75f2e..7b30b078d 100644 --- a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 +++ b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 @@ -43,12 +43,12 @@ process { $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = "/user/ssh_signing_keys/$ID" Context = $Context } - if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("SSH signing key with ID [$ID]", 'DELETE')) { Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 index c28aeb43f..c3099981b 100644 --- a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 @@ -43,7 +43,7 @@ } $inputObject = @{ - Method = 'Post' + Method = 'POST' APIEndpoint = '/user/social_accounts' Body = $body Context = $Context diff --git a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 index 334537a91..3a62449c1 100644 --- a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 +++ b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 @@ -44,13 +44,13 @@ } $inputObject = @{ - Method = 'Delete' + Method = 'DELETE' APIEndpoint = '/user/social_accounts' Body = $body Context = $Context } - if ($PSCmdlet.ShouldProcess("Social accounts [$($URL -join ', ')]", 'Delete')) { + if ($PSCmdlet.ShouldProcess("Social accounts [$($URL -join ', ')]", 'DELETE')) { Invoke-GitHubAPI @inputObject } } diff --git a/src/functions/public/Users/Update-GitHubUser.ps1 b/src/functions/public/Users/Update-GitHubUser.ps1 index da8e4afa1..32f4f0d68 100644 --- a/src/functions/public/Users/Update-GitHubUser.ps1 +++ b/src/functions/public/Users/Update-GitHubUser.ps1 @@ -88,7 +88,7 @@ $body | Remove-HashtableEntry -NullOrEmptyValues $inputObject = @{ - Method = 'Patch' + Method = 'PATCH' APIEndpoint = '/user' Body = $body Context = $Context From ad26ea2c2094b79b01290dcfa35110569702dc06 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Feb 2025 12:58:42 +0100 Subject: [PATCH 71/71] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Coding?= =?UTF-8?q?Standard.md=20to=20clarify=20coding=20standards=20and=20ensure?= =?UTF-8?q?=20consistency=20for=20developers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CodingStandard.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CodingStandard.md b/CodingStandard.md index 8e08fafc2..f460d9d09 100644 --- a/CodingStandard.md +++ b/CodingStandard.md @@ -1,10 +1,7 @@ ---- - -# Combined Specification for the Module +# Coding Standards for `GitHub` -This document outlines the conventions, naming standards, and best practices for building PowerShell functions and classes in this module. It merges all guidelines, including the additional notes and clarifications. - ---- +Start by reading the general coding standards for [`PSModule`](https://psmodule.io/docs) which is the basis for all modules in the framework. +Additions or adjustments to those defaults are covered in this document to ensure that the modules drive consistancy for all developers. ## General Coding Standards