From 0858d7179383eb277520e9a4943c42a3a5d708c7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 22 Dec 2024 17:44:02 +0100 Subject: [PATCH 1/3] Add function to uninstall a GitHub App from an enterprise organization --- ...GitHubAppOnEnterpriseOrganization copy.ps1 | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization copy.ps1 diff --git a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization copy.ps1 b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization copy.ps1 new file mode 100644 index 000000000..cb663b905 --- /dev/null +++ b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization copy.ps1 @@ -0,0 +1,68 @@ +function Uninstall-GitHubAppOnEnterpriseOrganization { + <# + .SYNOPSIS + Uninstall a GitHub App from an organization. + + .DESCRIPTION + Uninstall a GitHub App from an organization. + + The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/organization_installations (write) permission. + + .EXAMPLE + Uninstall-GitHubAppOnEnterpriseOrganization -Enterprise 'github' -Organization 'octokit' -InstallationID '123456' + + Uninstall the GitHub App with the installation ID '123456' from the organization 'octokit' in the enterprise 'github'. + #> + #SkipTest:FunctionTest:Will add a test for this function in a future PR + [CmdletBinding()] + param( + # The enterprise slug or ID. + [Parameter()] + [string] $Enterprise, + + # The organization name. The name is not case sensitive. + [Parameter(Mandatory)] + [string] $Organization, + + # The client ID of the GitHub App to install. + [Parameter(Mandatory)] + [Alias('installation_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 + if ([string]::IsNullOrEmpty($Enterprise)) { + $Enterprise = $Context.Enterprise + } + Write-Debug "Enterprise: [$Enterprise]" + } + + process { + try { + $inputObject = @{ + Context = $Context + APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$InstallationID}" + Method = 'Delete' + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} From 0c56e9fdcebe2fec37f8095453b537285b53928c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 22 Dec 2024 17:47:40 +0100 Subject: [PATCH 2/3] Fix name --- ...n copy.ps1 => Uninstall-GitHubAppOnEnterpriseOrganization.ps1} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/functions/public/Enterprise/{Install-GitHubAppOnEnterpriseOrganization copy.ps1 => Uninstall-GitHubAppOnEnterpriseOrganization.ps1} (100%) diff --git a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization copy.ps1 b/src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 similarity index 100% rename from src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization copy.ps1 rename to src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 From bcd214207273123b1e22fa06b5cb6e624d67ab08 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 22 Dec 2024 18:01:00 +0100 Subject: [PATCH 3/3] Fix formatting in documentation for Uninstall-GitHubAppOnEnterpriseOrganization function --- .../Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 index cb663b905..8aa9be3f4 100644 --- a/src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 +++ b/src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1 @@ -11,7 +11,7 @@ .EXAMPLE Uninstall-GitHubAppOnEnterpriseOrganization -Enterprise 'github' -Organization 'octokit' -InstallationID '123456' - Uninstall the GitHub App with the installation ID '123456' from the organization 'octokit' in the enterprise 'github'. + Uninstall the GitHub App with the installation ID `123456` from the organization `octokit` in the enterprise `github`. #> #SkipTest:FunctionTest:Will add a test for this function in a future PR [CmdletBinding()]