-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples to Get-GitHubOrganizationPendingInvitation and New-GitHu…
…bOrganizationInvitation functions; implement Remove-GitHubOrganizationInvitation function
- Loading branch information
1 parent
66af62d
commit 6ac17a6
Showing
5 changed files
with
169 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,19 @@ | |
"[Rate limits for the API](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)" | ||
and "[Best practices for using the REST API](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)." | ||
.EXAMPLE | ||
New-GitHubOrganizationInvitation -Organization 'PSModule' -InviteeID 12345679 -Role 'admin' | ||
Invites the user with the ID `12345679` to the organization `PSModule` with the role `admin`. | ||
.EXAMPLE | ||
New-GitHubOrganizationInvitation -Organization 'PSModule' -Email '[email protected]' | ||
Invites the user with the email `[email protected]` to the organization `PSModule`. | ||
.NOTES | ||
[Create an organization invitation](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations) | ||
#> | ||
#SkipTest:FunctionTest:Will add a test for this function in a future PR | ||
[CmdletBinding(SupportsShouldProcess)] | ||
param( | ||
# The organization name. The name is not case sensitive. | ||
|
71 changes: 71 additions & 0 deletions
71
src/functions/public/Organization/Members/Remove-GitHubOrganizationInvitation.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
function Remove-GitHubOrganizationInvitation { | ||
<# | ||
.SYNOPSIS | ||
Cancel an organization invitation | ||
.DESCRIPTION | ||
Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner. | ||
This endpoint triggers [notifications](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications). | ||
.EXAMPLE | ||
Remove-GitHubOrganizationInvitation -Organization 'github' -InvitationID '12345678' | ||
Cancel the invitation with the ID '12345678' for the organization `github`. | ||
.NOTES | ||
[Cancel an organization invitation](https://docs.github.com/rest/orgs/members#cancel-an-organization-invitation) | ||
#> | ||
[OutputType([bool])] | ||
[CmdletBinding(SupportsShouldProcess)] | ||
param( | ||
# The organization name. The name is not case sensitive. | ||
[Parameter(Mandatory)] | ||
[Alias('Org')] | ||
[string] $Organization, | ||
|
||
# The unique identifier of the invitation. | ||
[Parameter(Mandatory)] | ||
[Alias('invitation_id')] | ||
[string] $InvitationID, | ||
|
||
# The context 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 { | ||
try { | ||
$inputObject = @{ | ||
Context = $Context | ||
APIEndpoint = "/orgs/$Organization/invitations/$InvitationID" | ||
Method = 'DELETE' | ||
} | ||
|
||
try { | ||
if ($PSCmdlet.ShouldProcess('GitHub Organization invitation', 'Remove')) { | ||
$null = (Invoke-GitHubAPI @inputObject) | ||
} | ||
return $true | ||
} catch { | ||
Write-Error $_.Exception.Response | ||
throw $_ | ||
} | ||
} catch { | ||
throw $_ | ||
} | ||
} | ||
|
||
end { | ||
Write-Debug "[$stackPath] - End" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters