File tree Expand file tree Collapse file tree 4 files changed +142
-6
lines changed
src/GitHub/public/Repositories/Tags Expand file tree Collapse file tree 4 files changed +142
-6
lines changed Original file line number Diff line number Diff line change 1+ filter Get-GitHubRepositoryTagProtection {
2+ <#
3+ . SYNOPSIS
4+ List tag protection states for a repository
5+
6+ . DESCRIPTION
7+ This returns the tag protection states of a repository.
8+
9+ This information is only available to repository administrators.
10+
11+ . EXAMPLE
12+ Get-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world'
13+
14+ Gets the tag protection states of the 'hello-world' repository.
15+
16+ . NOTES
17+ https://docs.github.com/rest/repos/tags#list-tag-protection-states-for-a-repository
18+
19+ #>
20+ [OutputType ([pscustomobject ])]
21+ [CmdletBinding ()]
22+ param (
23+ # The account owner of the repository. The name is not case sensitive.
24+ [Parameter ()]
25+ [Alias (' org' )]
26+ [string ] $Owner = (Get-GitHubConfig - Name Owner),
27+
28+ # The name of the repository without the .git extension. The name is not case sensitive.
29+ [Parameter ()]
30+ [string ] $Repo = (Get-GitHubConfig - Name Repo)
31+ )
32+
33+ $inputObject = @ {
34+ APIEndpoint = " /repos/$Owner /$Repo /tags/protection"
35+ Method = ' GET'
36+ }
37+
38+ Invoke-GitHubAPI @inputObject | ForEach-Object {
39+ Write-Output $_.Response
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ filter New-GitHubRepositoryTagProtection {
2+ <#
3+ . SYNOPSIS
4+ Create a tag protection state for a repository
5+
6+ . DESCRIPTION
7+ This creates a tag protection state for a repository.
8+ This endpoint is only available to repository administrators.
9+
10+ . EXAMPLE
11+ New-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -Pattern 'v1.*'
12+
13+ Creates a tag protection state for the 'hello-world' repository with the pattern 'v1.*'.
14+
15+ . NOTES
16+ https://docs.github.com/rest/repos/tags#create-a-tag-protection-state-for-a-repository
17+
18+ #>
19+ [OutputType ([pscustomobject ])]
20+ [CmdletBinding (SupportsShouldProcess )]
21+ param (
22+ # The account owner of the repository. The name is not case sensitive.
23+ [Parameter ()]
24+ [Alias (' org' )]
25+ [string ] $Owner = (Get-GitHubConfig - Name Owner),
26+
27+ # The name of the repository without the .git extension. The name is not case sensitive.
28+ [Parameter ()]
29+ [string ] $Repo = (Get-GitHubConfig - Name Repo),
30+
31+ # An optional glob pattern to match against when enforcing tag protection.
32+ [Parameter (Mandatory )]
33+ [string ] $Pattern
34+ )
35+
36+ $body [' pattern' ] = $Pattern
37+
38+ $inputObject = @ {
39+ APIEndpoint = " /repos/$Owner /$Repo /tags/protection"
40+ Method = ' POST'
41+ Body = $body
42+ }
43+
44+ if ($PSCmdlet.ShouldProcess (" tag protection state on pattern [$Pattern ] for repository [$Owner /$Repo ]" , ' Create' )) {
45+ Invoke-GitHubAPI @inputObject | ForEach-Object {
46+ Write-Output $_.Response
47+ }
48+ }
49+ }
Original file line number Diff line number Diff line change 1+ filter Remove-GitHubRepositoryTagProtection {
2+ <#
3+ . SYNOPSIS
4+ Delete a tag protection state for a repository
5+
6+ . DESCRIPTION
7+ This deletes a tag protection state for a repository.
8+ This endpoint is only available to repository administrators.
9+
10+ . EXAMPLE
11+ Remove-GitHubRepositoryTagProtection -Owner 'octocat' -Repo 'hello-world' -TagProtectionId 1
12+
13+ Deletes the tag protection state with the id 1 for the 'hello-world' repository.
14+
15+ . NOTES
16+ https://docs.github.com/rest/repos/tags#delete-a-tag-protection-state-for-a-repository
17+
18+ #>
19+ [OutputType ([pscustomobject ])]
20+ [CmdletBinding (SupportsShouldProcess )]
21+ param (
22+ # The account owner of the repository. The name is not case sensitive.
23+ [Parameter ()]
24+ [Alias (' org' )]
25+ [string ] $Owner = (Get-GitHubConfig - Name Owner),
26+
27+ # The name of the repository without the .git extension. The name is not case sensitive.
28+ [Parameter ()]
29+ [string ] $Repo = (Get-GitHubConfig - Name Repo),
30+
31+ # The unique identifier of the tag protection.
32+ [Parameter (Mandatory )]
33+ [int ] $TagProtectionId
34+ )
35+
36+ $inputObject = @ {
37+ APIEndpoint = " /repos/$Owner /$Repo /tags/protection/$TagProtectionId "
38+ Method = ' DELETE'
39+ }
40+
41+ if ($PSCmdlet.ShouldProcess (" tag protection state with ID [$TagProtectionId ] for repository [$Owner /$Repo ]" , ' Delete' )) {
42+ Invoke-GitHubAPI @inputObject | ForEach-Object {
43+ Write-Output $_.Response
44+ }
45+ }
46+ }
Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ $response = Invoke-RestMethod -Uri $APIDocURI -Method Get
2121# @{n = 'PUT'; e = { (($_.value.psobject.Properties.Name) -contains 'PUT') } }, `
2222# @{n = 'PATCH'; e = { (($_.value.psobject.Properties.Name) -contains 'PATCH') } } | Format-Table
2323
24- $path = ' /repos/{owner}/{repo}/properties/values '
25- $method = ' get '
24+ $path = ' /repos/{owner}/{repo}/tags/protection/{tag_protection_id} '
25+ $method = ' delete '
2626$response.paths .$path .$method
2727$response.paths .$path .$method.tags | clip # -> Namespace/foldername
2828$response.paths .$path .$method.operationId | clip # -> FunctionName
@@ -42,11 +42,11 @@ $response.paths.$path.$method.responses.'200'.content.'application/json'.schema.
4242
4343$response.components.schemas.PSobject.Properties | ForEach-Object {
4444 [pscustomobject ]@ {
45- Name = $_ .Name
46- Title = $_ .Value .title
47- Type = $_ .Value.type
45+ Name ame
46+ Titlee .title
47+ Typelype
4848 Properties = $_.Value.properties
49- Required = $_ .Value .required
49+ Requiredlue .required
5050 }
5151}
5252
You can’t perform that action at this time.
0 commit comments