Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Sep 21, 2023
1 parent 0a9a766 commit 8cc3723
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 78 deletions.
26 changes: 6 additions & 20 deletions src/GitHub/public/Actions/Stop-GitHubWorkflowRun.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
[Parameter()]
[string] $Repo = $script:Repo,

[Parameter()]
[string] $Token = $script:AccessToken,

[Alias('workflow_id')]
[Parameter(
Mandatory,
Expand All @@ -24,24 +21,13 @@
process {
# API Reference
# https://docs.github.com/en/rest/reference/actions#cancel-a-workflow-run
$APICall = @{
Uri = "$APIBaseURI/repos/$Owner/$Repo/actions/runs/$ID/cancel"
Headers = @{
Authorization = "token $Token"
'Content-Type' = 'application/json'
}
Method = 'POST'
Body = @{} | ConvertTo-Json -Depth 100
$InputObject = @{
Method = 'POST'
APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/cancel"
}
try {
if ($PSBoundParameters.ContainsKey('Verbose')) {
$APICall
}
$Response = Invoke-RestMethod @APICall
} catch {
throw $_
}
return $Response
$Response = Invoke-GitHubAPI @InputObject

$Response
}

end {}
Expand Down
6 changes: 1 addition & 5 deletions src/GitHub/public/Deployments/Get-GitHubEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
[string] $Owner = $script:Owner,

[Parameter()]
[string] $Repo = $script:Repo,

[Parameter()]
[string] $Token = $script:AccessToken
[string] $Repo = $script:Repo
)

begin {}
Expand All @@ -20,7 +17,6 @@
$InputObject = @{
APIEndpoint = "/repos/$Owner/$Repo/environments"
Method = 'GET'
Token = $Token
}

$Response = Invoke-GitHubAPI @InputObject
Expand Down
24 changes: 2 additions & 22 deletions src/GitHub/public/Deployments/Get-GitHubEnvironmentSecrets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,14 @@
# https://docs.github.com/en/rest/reference/repos#get-all-environments

$InputObject = @{
APIEndpoint = "/repos/$Owner/$Repo/environments"
Token = $Token
APIEndpoint = "/repositories/$RepoID/environments/$EnvironmentName/secrets"
Method = 'GET'
Verbose = $Verbose
}

$Response = Invoke-GitHubAPI @InputObject

$Response

$APICall = @{
Uri = "$APIBaseURI/repositories/$RepoID/environments/$EnvironmentName/secrets"
Headers = @{
Authorization = "token $Token"
'Content-Type' = 'application/json'
}
Method = 'GET'
Body = @{} | ConvertTo-Json -Depth 100
}
try {
if ($PSBoundParameters.ContainsKey('Verbose')) {
$APICall
}
$Response = Invoke-RestMethod @APICall
} catch {
throw $_
}
return $Response.secrets
}

end {}
}
4 changes: 0 additions & 4 deletions src/GitHub/public/Deployments/Update-GitHubEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
[Parameter()]
[string] $Repo = $script:Repo,

[Parameter()]
[string] $Token = $script:AccessToken,

[Alias('environment_name')]
[Parameter(
Mandatory,
Expand All @@ -33,7 +30,6 @@
environment_name = $Name
}
Method = 'PUT'
Token = $Token
}

$Response = Invoke-GitHubAPI @InputObject
Expand Down
1 change: 0 additions & 1 deletion src/GitHub/public/Emojis/Get-GitHubEmojis.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
$InputObject = @{
APIEndpoint = '/emojis'
Method = 'GET'
Token = $Token
}

$Response = Invoke-GitHubAPI @InputObject
Expand Down
4 changes: 0 additions & 4 deletions src/GitHub/public/Markdown/Get-GitHubMarkdown.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#>
[CmdletBinding()]
param (
[Parameter()]
[string] $Token = $script:AccessToken,

[Parameter()]
[switch] $Text,

Expand All @@ -27,7 +24,6 @@
text = $Text
}
Method = 'POST'
$Token = $Token
}

$Response = Invoke-GitHubAPI @InputObject
Expand Down
4 changes: 0 additions & 4 deletions src/GitHub/public/Markdown/Get-GitHubMarkdownRaw.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#>
[CmdletBinding()]
param (
[Parameter()]
[string] $Token = $script:AccessToken,

[Parameter()]
[switch] $Text,

Expand All @@ -20,7 +17,6 @@
ContentType = 'text/plain'
Data = $Text
Method = 'POST'
$Token = $Token
}

$Response = Invoke-GitHubAPI @InputObject
Expand Down
6 changes: 1 addition & 5 deletions src/GitHub/public/Teams/Get-GitHubRepoTeam.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ function Get-GitHubRepoTeam {
[string] $Owner = $script:Owner,

[Parameter()]
[string] $Repo = $script:Repo,

[Parameter()]
[string] $Token = $script:AccessToken
[string] $Repo = $script:Repo
)

$InputObject = @{
Token = $Token
Method = 'Get'
APIEndpoint = "/repos/$Owner/$Repo/teams"
}
Expand Down
9 changes: 1 addition & 8 deletions src/GitHub/public/Users/Get-GitHubUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
If the authenticated user is authenticated through basic authentication or OAuth with the user scope, then the response lists public and private profile information.
If the authenticated user is authenticated through OAuth without the user scope, then the response lists only public profile information.
.PARAMETER Token
Parameter description
.EXAMPLE
An example
Expand All @@ -18,15 +15,11 @@
#>
[CmdletBinding()]
[Alias('Get-GitHubContext')]
param (
[Parameter()]
[string] $Token = $script:AccessToken
)
param ()

$InputObject = @{
APIEndpoint = '/user'
Method = 'GET'
Token = $Token
}

$Response = Invoke-GitHubAPI @InputObject
Expand Down
6 changes: 1 addition & 5 deletions src/GitHub/public/Users/Set-GitHubUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@

# The new short biography of the user.
[Parameter()]
[string] $Bio,

[Parameter()]
[string] $Token = $script:AccessToken
[string] $Bio
)

$Body = @{}
Expand All @@ -57,7 +54,6 @@
APIEndpoint = '/user'
Body = $Body
Method = 'PATCH'
Token = $Token
}

$Response = Invoke-GitHubAPI @InputObject
Expand Down

0 comments on commit 8cc3723

Please sign in to comment.