Skip to content

Commit ff9ac50

Browse files
🩹 [Patch]: Add function to uninstall a GitHub App from an enterprise organization (#235)
## Description This pull request introduces a new PowerShell function to uninstall a GitHub App from an enterprise organization. The function includes parameters for the enterprise, organization, and installation ID, and makes an API call to remove the specified installation. New functionality: * [`src/functions/public/Enterprise/Uninstall-GitHubAppOnEnterpriseOrganization.ps1`](diffhunk://#diff-28129cb6b97ff80748123a1dd7472ae8b7dbfb34e8b4156bd0ac6f36d72a8baaR1-R68): Added the `Uninstall-GitHubAppOnEnterpriseOrganization` function to uninstall a GitHub App from an organization. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 1b7a3b8 commit ff9ac50

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
function Uninstall-GitHubAppOnEnterpriseOrganization {
2+
<#
3+
.SYNOPSIS
4+
Uninstall a GitHub App from an organization.
5+
6+
.DESCRIPTION
7+
Uninstall a GitHub App from an organization.
8+
9+
The authenticated GitHub App must be installed on the enterprise and be granted the Enterprise/organization_installations (write) permission.
10+
11+
.EXAMPLE
12+
Uninstall-GitHubAppOnEnterpriseOrganization -Enterprise 'github' -Organization 'octokit' -InstallationID '123456'
13+
14+
Uninstall the GitHub App with the installation ID `123456` from the organization `octokit` in the enterprise `github`.
15+
#>
16+
#SkipTest:FunctionTest:Will add a test for this function in a future PR
17+
[CmdletBinding()]
18+
param(
19+
# The enterprise slug or ID.
20+
[Parameter()]
21+
[string] $Enterprise,
22+
23+
# The organization name. The name is not case sensitive.
24+
[Parameter(Mandatory)]
25+
[string] $Organization,
26+
27+
# The client ID of the GitHub App to install.
28+
[Parameter(Mandatory)]
29+
[Alias('installation_id')]
30+
[string] $InstallationID,
31+
32+
# The context to run the command in. Used to get the details for the API call.
33+
# Can be either a string or a GitHubContext object.
34+
[Parameter()]
35+
[object] $Context = (Get-GitHubContext)
36+
)
37+
38+
begin {
39+
$stackPath = Get-PSCallStackPath
40+
Write-Debug "[$stackPath] - Start"
41+
$Context = Resolve-GitHubContext -Context $Context
42+
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
43+
if ([string]::IsNullOrEmpty($Enterprise)) {
44+
$Enterprise = $Context.Enterprise
45+
}
46+
Write-Debug "Enterprise: [$Enterprise]"
47+
}
48+
49+
process {
50+
try {
51+
$inputObject = @{
52+
Context = $Context
53+
APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations/$InstallationID}"
54+
Method = 'Delete'
55+
}
56+
57+
Invoke-GitHubAPI @inputObject | ForEach-Object {
58+
Write-Output $_.Response
59+
}
60+
} catch {
61+
throw $_
62+
}
63+
}
64+
65+
end {
66+
Write-Debug "[$stackPath] - End"
67+
}
68+
}

0 commit comments

Comments
 (0)