From c3f5eb04fa53e00660aec75c980b2f22bdd83b47 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 25 Nov 2024 13:12:38 +0100 Subject: [PATCH 1/2] Rename file to align with function name --- .../public/Teams/Remove-GitHubTeam.ps1 | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/functions/public/Teams/Remove-GitHubTeam.ps1 diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1 new file mode 100644 index 000000000..5f4e04a98 --- /dev/null +++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1 @@ -0,0 +1,45 @@ +function Remove-GitHubTeam { + <# + .SYNOPSIS + Delete a team + + .DESCRIPTION + To delete a team, the authenticated user must be an organization owner or team maintainer. + If you are an organization owner, deleting a parent team will delete all of its child teams as well. + + .EXAMPLE + An example + + .NOTES + [Delete a team](https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team) + #> + [OutputType([void])] + [CmdletBinding(SupportsShouldProcess)] + param ( + # The organization name. The name is not case sensitive. + [Parameter(Mandatory)] + [Alias('Org')] + [string] $Organization, + + # The slug of the team name. + [Parameter(Mandatory)] + [Alias('Team', 'TeamName', 'slug', 'team_slug')] + [string] $Name, + + # The context to run the command in + [Parameter()] + [string] $Context = (Get-GitHubConfig -Name DefaultContext) + ) + + $inputObject = @{ + Context = $Context + Method = 'Delete' + APIEndpoint = "/orgs/$Organization/teams/$Name" + } + + if ($PSCmdlet.ShouldProcess("$Organization/$Name", 'Delete')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } +} From 35cc90a4de8095e5389b828b4b93cfca23e448d9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 25 Nov 2024 13:30:20 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20deprecat?= =?UTF-8?q?ed=20Delete-GitHubTeam=20function=20and=20update=20examples=20i?= =?UTF-8?q?n=20related=20team=20management=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/Teams/Delete-GitHubTeam.ps1 | 45 ------------------- src/functions/public/Teams/New-GitHubTeam.ps1 | 12 +++++ .../public/Teams/Remove-GitHubTeam.ps1 | 2 +- .../public/Teams/Update-GitHubTeam.ps1 | 12 ++++- 4 files changed, 24 insertions(+), 47 deletions(-) delete mode 100644 src/functions/public/Teams/Delete-GitHubTeam.ps1 diff --git a/src/functions/public/Teams/Delete-GitHubTeam.ps1 b/src/functions/public/Teams/Delete-GitHubTeam.ps1 deleted file mode 100644 index 5f4e04a98..000000000 --- a/src/functions/public/Teams/Delete-GitHubTeam.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -function Remove-GitHubTeam { - <# - .SYNOPSIS - Delete a team - - .DESCRIPTION - To delete a team, the authenticated user must be an organization owner or team maintainer. - If you are an organization owner, deleting a parent team will delete all of its child teams as well. - - .EXAMPLE - An example - - .NOTES - [Delete a team](https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team) - #> - [OutputType([void])] - [CmdletBinding(SupportsShouldProcess)] - param ( - # The organization name. The name is not case sensitive. - [Parameter(Mandatory)] - [Alias('Org')] - [string] $Organization, - - # The slug of the team name. - [Parameter(Mandatory)] - [Alias('Team', 'TeamName', 'slug', 'team_slug')] - [string] $Name, - - # The context to run the command in - [Parameter()] - [string] $Context = (Get-GitHubConfig -Name DefaultContext) - ) - - $inputObject = @{ - Context = $Context - Method = 'Delete' - APIEndpoint = "/orgs/$Organization/teams/$Name" - } - - if ($PSCmdlet.ShouldProcess("$Organization/$Name", '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 4a8b6b634..b6ae7bf04 100644 --- a/src/functions/public/Teams/New-GitHubTeam.ps1 +++ b/src/functions/public/Teams/New-GitHubTeam.ps1 @@ -12,6 +12,18 @@ `maintainers`. For more information, see "[About teams](https://docs.github.com/github/setting-up-and-managing-organizations-and-teams/about-teams)". + .EXAMPLE + $params = @{ + Organization = 'github' + Name = 'team-name' + Description = 'A new team' + Maintainers = 'octocat' + RepoNames = 'github/octocat' + Privacy = 'closed' + Permission = 'pull' + } + New-GitHubTeam @params + .NOTES [Create a team](https://docs.github.com/rest/teams/teams#create-a-team) #> diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1 index 5f4e04a98..49ddc5cac 100644 --- a/src/functions/public/Teams/Remove-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1 @@ -8,7 +8,7 @@ If you are an organization owner, deleting a parent team will delete all of its child teams as well. .EXAMPLE - An example + Remove-GitHubTeam -Organization 'github' -Name 'team-name' .NOTES [Delete a team](https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team) diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1 index 038b924c0..a3531ddab 100644 --- a/src/functions/public/Teams/Update-GitHubTeam.ps1 +++ b/src/functions/public/Teams/Update-GitHubTeam.ps1 @@ -7,7 +7,17 @@ To edit a team, the authenticated user must either be an organization owner or a team maintainer. .EXAMPLE - + $params = @{ + Organization = 'github' + Name = 'team-name' + NewName = 'new-team-name' + Description = 'A new team' + Privacy = 'closed' + NotificationSetting = 'notifications_enabled' + Permission = 'pull' + ParentTeamID = 123456 + } + Update-GitHubTeam @params .NOTES [Update a team](https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team)