From 8cc37239aa3e43d79bea6c5e97bfc9872a94b98f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 21 Sep 2023 02:35:33 +0200 Subject: [PATCH] cleanup --- .../public/Actions/Stop-GitHubWorkflowRun.ps1 | 26 +++++-------------- .../Deployments/Get-GitHubEnvironment.ps1 | 6 +---- .../Get-GitHubEnvironmentSecrets.ps1 | 24 ++--------------- .../Deployments/Update-GitHubEnvironment.ps1 | 4 --- src/GitHub/public/Emojis/Get-GitHubEmojis.ps1 | 1 - .../public/Markdown/Get-GitHubMarkdown.ps1 | 4 --- .../public/Markdown/Get-GitHubMarkdownRaw.ps1 | 4 --- .../public/Teams/Get-GitHubRepoTeam.ps1 | 6 +---- src/GitHub/public/Users/Get-GitHubUser.ps1 | 9 +------ src/GitHub/public/Users/Set-GitHubUser.ps1 | 6 +---- 10 files changed, 12 insertions(+), 78 deletions(-) diff --git a/src/GitHub/public/Actions/Stop-GitHubWorkflowRun.ps1 b/src/GitHub/public/Actions/Stop-GitHubWorkflowRun.ps1 index 55e73df82..fdd2f5a13 100644 --- a/src/GitHub/public/Actions/Stop-GitHubWorkflowRun.ps1 +++ b/src/GitHub/public/Actions/Stop-GitHubWorkflowRun.ps1 @@ -8,9 +8,6 @@ [Parameter()] [string] $Repo = $script:Repo, - [Parameter()] - [string] $Token = $script:AccessToken, - [Alias('workflow_id')] [Parameter( Mandatory, @@ -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 {} diff --git a/src/GitHub/public/Deployments/Get-GitHubEnvironment.ps1 b/src/GitHub/public/Deployments/Get-GitHubEnvironment.ps1 index 3c3192713..704d3133d 100644 --- a/src/GitHub/public/Deployments/Get-GitHubEnvironment.ps1 +++ b/src/GitHub/public/Deployments/Get-GitHubEnvironment.ps1 @@ -5,10 +5,7 @@ [string] $Owner = $script:Owner, [Parameter()] - [string] $Repo = $script:Repo, - - [Parameter()] - [string] $Token = $script:AccessToken + [string] $Repo = $script:Repo ) begin {} @@ -20,7 +17,6 @@ $InputObject = @{ APIEndpoint = "/repos/$Owner/$Repo/environments" Method = 'GET' - Token = $Token } $Response = Invoke-GitHubAPI @InputObject diff --git a/src/GitHub/public/Deployments/Get-GitHubEnvironmentSecrets.ps1 b/src/GitHub/public/Deployments/Get-GitHubEnvironmentSecrets.ps1 index 14287985e..ce41d8a1b 100644 --- a/src/GitHub/public/Deployments/Get-GitHubEnvironmentSecrets.ps1 +++ b/src/GitHub/public/Deployments/Get-GitHubEnvironmentSecrets.ps1 @@ -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 {} } diff --git a/src/GitHub/public/Deployments/Update-GitHubEnvironment.ps1 b/src/GitHub/public/Deployments/Update-GitHubEnvironment.ps1 index 7eeaaaeab..9ac227481 100644 --- a/src/GitHub/public/Deployments/Update-GitHubEnvironment.ps1 +++ b/src/GitHub/public/Deployments/Update-GitHubEnvironment.ps1 @@ -11,9 +11,6 @@ [Parameter()] [string] $Repo = $script:Repo, - [Parameter()] - [string] $Token = $script:AccessToken, - [Alias('environment_name')] [Parameter( Mandatory, @@ -33,7 +30,6 @@ environment_name = $Name } Method = 'PUT' - Token = $Token } $Response = Invoke-GitHubAPI @InputObject diff --git a/src/GitHub/public/Emojis/Get-GitHubEmojis.ps1 b/src/GitHub/public/Emojis/Get-GitHubEmojis.ps1 index bb6639dbb..aa9b1ef89 100644 --- a/src/GitHub/public/Emojis/Get-GitHubEmojis.ps1 +++ b/src/GitHub/public/Emojis/Get-GitHubEmojis.ps1 @@ -12,7 +12,6 @@ $InputObject = @{ APIEndpoint = '/emojis' Method = 'GET' - Token = $Token } $Response = Invoke-GitHubAPI @InputObject diff --git a/src/GitHub/public/Markdown/Get-GitHubMarkdown.ps1 b/src/GitHub/public/Markdown/Get-GitHubMarkdown.ps1 index fc645ba18..9e7f485b4 100644 --- a/src/GitHub/public/Markdown/Get-GitHubMarkdown.ps1 +++ b/src/GitHub/public/Markdown/Get-GitHubMarkdown.ps1 @@ -5,9 +5,6 @@ #> [CmdletBinding()] param ( - [Parameter()] - [string] $Token = $script:AccessToken, - [Parameter()] [switch] $Text, @@ -27,7 +24,6 @@ text = $Text } Method = 'POST' - $Token = $Token } $Response = Invoke-GitHubAPI @InputObject diff --git a/src/GitHub/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/GitHub/public/Markdown/Get-GitHubMarkdownRaw.ps1 index 3ab35c404..1e76b8bec 100644 --- a/src/GitHub/public/Markdown/Get-GitHubMarkdownRaw.ps1 +++ b/src/GitHub/public/Markdown/Get-GitHubMarkdownRaw.ps1 @@ -5,9 +5,6 @@ #> [CmdletBinding()] param ( - [Parameter()] - [string] $Token = $script:AccessToken, - [Parameter()] [switch] $Text, @@ -20,7 +17,6 @@ ContentType = 'text/plain' Data = $Text Method = 'POST' - $Token = $Token } $Response = Invoke-GitHubAPI @InputObject diff --git a/src/GitHub/public/Teams/Get-GitHubRepoTeam.ps1 b/src/GitHub/public/Teams/Get-GitHubRepoTeam.ps1 index 27dd0c1a7..afa117aef 100644 --- a/src/GitHub/public/Teams/Get-GitHubRepoTeam.ps1 +++ b/src/GitHub/public/Teams/Get-GitHubRepoTeam.ps1 @@ -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" } diff --git a/src/GitHub/public/Users/Get-GitHubUser.ps1 b/src/GitHub/public/Users/Get-GitHubUser.ps1 index d608e2d05..93e24f670 100644 --- a/src/GitHub/public/Users/Get-GitHubUser.ps1 +++ b/src/GitHub/public/Users/Get-GitHubUser.ps1 @@ -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 @@ -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 diff --git a/src/GitHub/public/Users/Set-GitHubUser.ps1 b/src/GitHub/public/Users/Set-GitHubUser.ps1 index cf96482ce..c42642efa 100644 --- a/src/GitHub/public/Users/Set-GitHubUser.ps1 +++ b/src/GitHub/public/Users/Set-GitHubUser.ps1 @@ -36,10 +36,7 @@ # The new short biography of the user. [Parameter()] - [string] $Bio, - - [Parameter()] - [string] $Token = $script:AccessToken + [string] $Bio ) $Body = @{} @@ -57,7 +54,6 @@ APIEndpoint = '/user' Body = $Body Method = 'PATCH' - Token = $Token } $Response = Invoke-GitHubAPI @InputObject