diff --git a/Coverage.md b/Coverage.md
index 454cdf01..984361d8 100644
--- a/Coverage.md
+++ b/Coverage.md
@@ -9,15 +9,15 @@
Covered functions |
- 153 |
+ 155 |
Missing functions |
- 832 |
+ 830 |
Coverage |
- 15.53% |
+ 15.74% |
@@ -30,8 +30,8 @@
| `/advisories/{ghsa_id}` | | :x: | | | |
| `/app` | | :white_check_mark: | | | |
| `/app-manifests/{code}/conversions` | | | | :x: | |
-| `/app/hook/config` | | :x: | :x: | | |
-| `/app/hook/deliveries` | | :x: | | | |
+| `/app/hook/config` | | :white_check_mark: | :x: | | |
+| `/app/hook/deliveries` | | :white_check_mark: | | | |
| `/app/hook/deliveries/{delivery_id}` | | :x: | | | |
| `/app/hook/deliveries/{delivery_id}/attempts` | | | | :x: | |
| `/app/installation-requests` | | :x: | | | |
diff --git a/scripts/Set-CoverageReport.ps1 b/scripts/Set-CoverageReport.ps1
index adb907e3..ab0fd749 100644
--- a/scripts/Set-CoverageReport.ps1
+++ b/scripts/Set-CoverageReport.ps1
@@ -8,7 +8,7 @@ function Find-APIMethod {
.SYNOPSIS
Find API methods in a directory
#>
- param (
+ param(
[Parameter(Mandatory)]
[string] $SearchDirectory,
diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1
index 76d7c219..af96d6dc 100644
--- a/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1
+++ b/src/functions/private/Gitignore/Get-GitHubGitignoreByName.ps1
@@ -1,4 +1,4 @@
-filter Get-GitHubGitignoreByName {
+filter Get-GitHubGitignoreByName {
<#
.SYNOPSIS
Get a gitignore template
@@ -17,14 +17,18 @@ filter Get-GitHubGitignoreByName {
#>
[CmdletBinding()]
- param (
+ param(
+ [Parameter(Mandatory)]
+ [string] $Name,
+
+ # The context to run the command in.
[Parameter()]
- [ValidateNotNullOrEmpty()]
- [string] $Name
+ [string] $Context
)
process {
$inputObject = @{
+ Context = $Context
APIEndpoint = "/gitignore/templates/$Name"
Accept = 'application/vnd.github.raw+json'
Method = 'GET'
diff --git a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1 b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1
index d4a7e3ab..0a6b4e3c 100644
--- a/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1
+++ b/src/functions/private/Gitignore/Get-GitHubGitignoreList.ps1
@@ -1,4 +1,4 @@
-filter Get-GitHubGitignoreList {
+filter Get-GitHubGitignoreList {
<#
.SYNOPSIS
Get all gitignore templates
@@ -18,9 +18,14 @@ filter Get-GitHubGitignoreList {
#>
[OutputType([string[]])]
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
+ )
$inputObject = @{
+ Context = $Context
APIEndpoint = '/gitignore/templates'
Method = 'GET'
}
@@ -28,5 +33,4 @@ filter Get-GitHubGitignoreList {
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
-
}
diff --git a/src/functions/private/License/Get-GitHubLicenseByName.ps1 b/src/functions/private/License/Get-GitHubLicenseByName.ps1
index b091d721..09ac0311 100644
--- a/src/functions/private/License/Get-GitHubLicenseByName.ps1
+++ b/src/functions/private/License/Get-GitHubLicenseByName.ps1
@@ -1,4 +1,4 @@
-filter Get-GitHubLicenseByName {
+filter Get-GitHubLicenseByName {
<#
.SYNOPSIS
Get a license
@@ -18,16 +18,20 @@ filter Get-GitHubLicenseByName {
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
- param (
+ param(
# The license keyword, license name, or license SPDX ID. For example, mit or mpl-2.0.
- [Parameter()]
- [ValidateNotNullOrEmpty()]
+ [Parameter(Mandatory)]
[Alias('license')]
- [string] $Name
+ [string] $Name,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
process {
$inputObject = @{
+ Context = $Context
APIEndpoint = "/licenses/$Name"
Accept = 'application/vnd.github+json'
Method = 'GET'
@@ -36,6 +40,5 @@ filter Get-GitHubLicenseByName {
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
-
}
}
diff --git a/src/functions/private/License/Get-GitHubLicenseList.ps1 b/src/functions/private/License/Get-GitHubLicenseList.ps1
index 9caba426..6cefaf8b 100644
--- a/src/functions/private/License/Get-GitHubLicenseList.ps1
+++ b/src/functions/private/License/Get-GitHubLicenseList.ps1
@@ -1,4 +1,4 @@
-filter Get-GitHubLicenseList {
+filter Get-GitHubLicenseList {
<#
.SYNOPSIS
Get all commonly used licenses
@@ -19,9 +19,14 @@ filter Get-GitHubLicenseList {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[OutputType([string[]])]
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
+ )
$inputObject = @{
+ Context = $Context
APIEndpoint = '/licenses'
Method = 'GET'
}
diff --git a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1 b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1
index 73a2912e..5a66a489 100644
--- a/src/functions/private/License/Get-GitHubRepositoryLicense.ps1
+++ b/src/functions/private/License/Get-GitHubRepositoryLicense.ps1
@@ -1,4 +1,4 @@
-filter Get-GitHubRepositoryLicense {
+filter Get-GitHubRepositoryLicense {
<#
.SYNOPSIS
Get the license for a repository
@@ -19,17 +19,22 @@ filter Get-GitHubRepositoryLicense {
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
+ [Parameter(Mandatory)]
+ [string] $Repo,
+
+ # The context to run the command in.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/license"
Accept = 'application/vnd.github+json'
Method = 'GET'
diff --git a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1
index 4097f4bf..2de6597c 100644
--- a/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Block-GitHubUserByOrganization.ps1
@@ -18,7 +18,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -36,11 +36,15 @@
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
- [Alias('login')]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks/$Username"
Method = 'PUT'
}
diff --git a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1
index 4363c6bc..679a1800 100644
--- a/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Get-GitHubBlockedUserByOrganization.ps1
@@ -16,7 +16,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('org')]
@@ -27,7 +27,11 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$body = @{
@@ -35,6 +39,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1
index 7f44bdc3..2aea67d2 100644
--- a/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Test-GitHubBlockedUserByOrganization.ps1
@@ -18,7 +18,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -35,10 +35,15 @@
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks/$Username"
Method = 'GET'
}
diff --git a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1 b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1
index 14637373..fed32fe3 100644
--- a/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1
+++ b/src/functions/private/Organization/Blocking/Unblock-GitHubUserByOrganization.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -36,10 +36,15 @@
ValueFromPipelineByPropertyName
)]
[Alias('login')]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName/blocks/$Username"
Method = 'DELETE'
}
diff --git a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1 b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1
index 630a82bf..49563e4d 100644
--- a/src/functions/private/Organization/Get-GitHubAllOrganization.ps1
+++ b/src/functions/private/Organization/Get-GitHubAllOrganization.ps1
@@ -21,7 +21,7 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
- param (
+ param(
# A organization ID. Only return organizations with an ID greater than this ID.
[Parameter()]
[int] $Since = 0,
@@ -29,7 +29,11 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$body = @{
@@ -38,6 +42,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = '/organizations'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1 b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1
index eeb37355..4d967c66 100644
--- a/src/functions/private/Organization/Get-GitHubMyOrganization.ps1
+++ b/src/functions/private/Organization/Get-GitHubMyOrganization.ps1
@@ -24,11 +24,15 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$body = @{
@@ -36,6 +40,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/orgs'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1 b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1
index 5b2a7868..aec458c2 100644
--- a/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1
+++ b/src/functions/private/Organization/Get-GitHubOrganizationByName.ps1
@@ -24,7 +24,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -34,11 +34,16 @@
[Alias('login')]
[Alias('org')]
[Alias('owner')]
- [string] $OrganizationName
+ [string] $OrganizationName,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName"
Method = 'GET'
}
diff --git a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1 b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1
index cd2ea411..6979b7a8 100644
--- a/src/functions/private/Organization/Get-GitHubUserOrganization.ps1
+++ b/src/functions/private/Organization/Get-GitHubUserOrganization.ps1
@@ -22,7 +22,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(Mandatory)]
[string] $Username,
@@ -30,7 +30,11 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$body = @{
@@ -38,6 +42,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/orgs"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1
index e7387d5f..d5210ad2 100644
--- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1
+++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByID.ps1
@@ -19,22 +19,27 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [Parameter(Mandatory)]
+ [string] $Repo,
# The unique identifier of the asset.
[Parameter(Mandatory)]
[Alias('asset_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
Method = 'GET'
}
diff --git a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1 b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1
index ea8dd0bd..027860a3 100644
--- a/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1
+++ b/src/functions/private/Releases/Assets/Get-GitHubReleaseAssetByReleaseID.ps1
@@ -16,14 +16,14 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [Parameter(Mandatory)]
+ [string] $Repo,
# The unique identifier of the release.
[Parameter(
@@ -36,13 +36,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo', 'ID'
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/$ID/assets"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1
index 2ed5b014..44e2152c 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseAll.ps1
@@ -18,25 +18,31 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [Parameter(Mandatory)]
+ [string] $Repo,
# The number of results per page (max 100).
[Parameter(ParameterSetName = 'AllUsers')]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo'
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1
index ae2cab2e..094ef573 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByID.ps1
@@ -17,24 +17,27 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [Parameter(Mandatory)]
+ [string] $Repo,
# The unique identifier of the release.
- [Parameter(
- Mandatory
- )]
+ [Parameter(Mandatory)]
[Alias('release_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
Method = 'GET'
}
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1
index db6b659f..c79018a1 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseByTagName.ps1
@@ -16,24 +16,27 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [Parameter(Mandatory)]
+ [string] $Repo,
# The name of the tag to get a release from.
- [Parameter(
- Mandatory
- )]
+ [Parameter(Mandatory)]
[Alias('tag_name')]
- [string] $Tag
+ [string] $Tag,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/tags/$Tag"
Method = 'GET'
}
diff --git a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1 b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1
index 013a812c..5c745e6e 100644
--- a/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1
+++ b/src/functions/private/Releases/Releases/Get-GitHubReleaseLatest.ps1
@@ -18,18 +18,22 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [Parameter(Mandatory)]
+ [string] $Repo,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/latest"
Method = 'GET'
}
@@ -37,5 +41,4 @@
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
-
}
diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1
index cdff8e23..825ca788 100644
--- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1
+++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkById.ps1
@@ -18,24 +18,29 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
+ [Parameter(Mandatory)]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [Parameter(Mandatory)]
+ [string] $Repo,
# The unique identifier of the autolink.
[Parameter(Mandatory)]
[Alias('autolink_id')]
[Alias('ID')]
- [int] $AutolinkId
+ [int] $AutolinkId,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId"
Method = 'GET'
}
diff --git a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1 b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1
index 3edebc52..213c514f 100644
--- a/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1
+++ b/src/functions/private/Repositories/Autolinks/Get-GitHubRepositoryAutolinkList.ps1
@@ -18,18 +18,23 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
+ [Parameter(Mandatory)]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
+ [Parameter(Mandatory)]
+ [string] $Repo,
+
+ # The context to run the command in.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/autolinks"
Method = 'GET'
}
diff --git a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1 b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1
index f8b3d881..2a60f615 100644
--- a/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1
+++ b/src/functions/private/Repositories/Fork/New-GitHubRepositoryAsFork.ps1
@@ -39,7 +39,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(Mandatory)]
[string] $Owner,
@@ -50,8 +50,8 @@
# The organization or person who will own the new repository.
# To create a new repository in an organization, the authenticated user must be a member of the specified organization.
- [Parameter()]
- [string] $Organization = (Get-GitHubConfig -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Organization,
# The name of the new repository.
[Parameter()]
@@ -60,34 +60,23 @@
# When forking from an existing repository, fork with only the default branch.
[Parameter()]
[Alias('default_branch_only')]
- [switch] $DefaultBranchOnly
+ [switch] $DefaultBranchOnly,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
if ([string]::IsNullorEmpty($Name)) {
- $Name = $ForkRepo
+ $Name = $Repo
}
-
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
- }
+ $body = @{
+ organization = $Organization
+ name = $Name
+ default_branch_only = $DefaultBranchOnly
}
-
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
- $body['default_branch_only'] = $DefaultBranchOnly
-
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/forks"
Method = 'POST'
Body = $body
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1
index fa20d132..25ef88e9 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubMyRepositories.ps1
@@ -56,7 +56,7 @@
#>
[CmdletBinding(DefaultParameterSetName = 'Type')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'Private function, not exposed to user.')]
- param (
+ param(
# Limit results to repositories with the specified visibility.
[Parameter(
ParameterSetName = 'Aff-Vis'
@@ -105,22 +105,20 @@
# Only show repositories updated before the given time.
[Parameter()]
- [datetime] $Before
+ [datetime] $Before,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)]"
- $paramDefaultValue = Get-Variable -Name $_.Key -ValueOnly -ErrorAction SilentlyContinue
- if (-not $PSBoundParameters.ContainsKey($_.Key) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)] - Adding default value"
- $PSBoundParameters[$_.Key] = $paramDefaultValue
- }
- Write-Verbose " - $($PSBoundParameters[$_.Key])"
+ $body = @{
+ type = $Type
+ sort = $Sort
+ direction = $Direction
+ per_page = $PerPage
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Affiliation', 'Since', 'Before'
-
if ($PSBoundParameters.ContainsKey('Affiliation')) {
$body['affiliation'] = $Affiliation -join ','
}
@@ -132,6 +130,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/repos'
Method = 'GET'
body = $body
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1
index b7f6c642..0fc01493 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryByName.ps1
@@ -21,18 +21,22 @@
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
- [Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [Parameter(Mandatory)]
+ [string] $Repo,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo"
Method = 'GET'
}
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1
index ab269579..a5d9ab78 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByID.ps1
@@ -22,25 +22,22 @@
#>
[CmdletBinding()]
- param (
+ param(
# A repository ID. Only return repositories with an ID greater than this ID.
[Parameter()]
- [int] $Since = 0
+ [int] $Since = 0,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)]"
- $paramDefaultValue = Get-Variable -Name $_.Key -ValueOnly -ErrorAction SilentlyContinue
- if (-not $PSBoundParameters.ContainsKey($_.Key) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)] - Adding default value"
- $PSBoundParameters[$_.Key] = $paramDefaultValue
- }
- Write-Verbose " - $($PSBoundParameters[$_.Key])"
+ $body = @{
+ since = $Since
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
-
$inputObject = @{
+ Context = $Context
APIEndpoint = '/repositories'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1
index 9e2f108a..9fb661b1 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByOrg.ps1
@@ -30,47 +30,46 @@
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [Parameter(Mandatory)]
+ [string] $Owner,
# Specifies the types of repositories you want returned.
[Parameter()]
- [validateSet('all', 'public', 'private', 'forks', 'sources', 'member')]
- [string] $type = 'all',
+ [ValidateSet('all', 'public', 'private', 'forks', 'sources', 'member')]
+ [string] $Type = 'all',
# The property to sort the results by.
[Parameter()]
- [validateSet('created', 'updated', 'pushed', 'full_name')]
+ [ValidateSet('created', 'updated', 'pushed', 'full_name')]
[string] $Sort = 'created',
# The order to sort by.
# Default: asc when using full_name, otherwise desc.
[Parameter()]
- [validateSet('asc', 'desc')]
+ [ValidateSet('asc', 'desc')]
[string] $Direction,
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)]"
- $paramDefaultValue = Get-Variable -Name $_.Key -ValueOnly -ErrorAction SilentlyContinue
- if (-not $PSBoundParameters.ContainsKey($_.Key) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)] - Adding default value"
- $PSBoundParameters[$_.Key] = $paramDefaultValue
- }
- Write-Verbose " - $($PSBoundParameters[$_.Key])"
+ $body = @{
+ sort = $Sort
+ type = $Type
+ direction = $Direction
+ per_page = $PerPage
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner'
-
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$Owner/repos"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1 b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1
index 2b00538b..a2077534 100644
--- a/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1
+++ b/src/functions/private/Repositories/Repositories/Get-GitHubRepositoryListByUser.ps1
@@ -27,7 +27,7 @@
#>
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -56,23 +56,22 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)]"
- $paramDefaultValue = Get-Variable -Name $_.Key -ValueOnly -ErrorAction SilentlyContinue
- if (-not $PSBoundParameters.ContainsKey($_.Key) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose "Parameter: [$($_.Key)] = [$($_.Value)] - Adding default value"
- $PSBoundParameters[$_.Key] = $paramDefaultValue
- }
- Write-Verbose " - $($PSBoundParameters[$_.Key])"
+ $body = @{
+ sort = $Sort
+ type = $Type
+ direction = $Direction
+ per_page = $PerPage
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Username'
-
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/repos"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1
index e5a59dbc..b2d938df 100644
--- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1
+++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryFromTemplate.ps1
@@ -37,7 +37,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the template repository. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('template_owner')]
@@ -50,9 +50,9 @@
# The organization or person who will own the new repository.
# To create a new repository in an organization, the authenticated user must be a member of the specified organization.
- [Parameter()]
+ [Parameter(Mandatory)]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the new repository.
[Parameter(Mandatory)]
@@ -70,28 +70,23 @@
# Either true to create a new private repository or false to create a new public one.
[Parameter()]
- [switch] $Private
+ [switch] $Private,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
- $paramName = $_.Key
- $paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
- $providedValue = $PSBoundParameters[$paramName]
- Write-Verbose "[$paramName]"
- Write-Verbose " - Default: [$paramDefaultValue]"
- Write-Verbose " - Provided: [$providedValue]"
- if (-not $PSBoundParameters.ContainsKey($paramName) -and ($null -ne $paramDefaultValue)) {
- Write-Verbose ' - Using default value'
- $PSBoundParameters[$paramName] = $paramDefaultValue
- } else {
- Write-Verbose ' - Using provided value'
- }
+ $body = @{
+ owner = $Owner
+ name = $Name
+ description = $Description
+ include_all_branches = $IncludeAllBranches
+ private = $Private
}
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'TemplateOwner', 'TemplateRepo' -RemoveTypes 'SwitchParameter'
-
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$TemplateOwner/$TemplateRepo/generate"
Method = 'POST'
Body = $body
diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1
index 1f8c969c..af7e2487 100644
--- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1
+++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryOrg.ps1
@@ -60,11 +60,11 @@ filter New-GitHubRepositoryOrg {
Justification = 'Parameter is used in dynamic parameter validation.'
)]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
- [Parameter()]
+ [Parameter(Mandatory)]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository.
[Parameter(Mandatory)]
@@ -179,7 +179,11 @@ filter New-GitHubRepositoryOrg {
[Parameter()]
[ValidateSet('PR_BODY', 'PR_TITLE', 'BLANK')]
[Alias('merge_commit_message')]
- [string] $MergeCommitMessage
+ [string] $MergeCommitMessage,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
dynamicparam {
@@ -246,6 +250,7 @@ filter New-GitHubRepositoryOrg {
Remove-HashtableEntry -Hashtable $body -NullOrEmptyValues
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$Owner/repos"
Method = 'POST'
Body = $body
diff --git a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1 b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1
index 907edfcc..04f0ae1d 100644
--- a/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1
+++ b/src/functions/private/Repositories/Repositories/New-GitHubRepositoryUser.ps1
@@ -57,7 +57,7 @@ filter New-GitHubRepositoryUser {
Justification = 'Parameter is used in dynamic parameter validation.'
)]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The name of the repository.
[Parameter(Mandatory)]
[string] $Name,
@@ -173,7 +173,11 @@ filter New-GitHubRepositoryUser {
[Parameter()]
[ValidateSet('PR_BODY', 'PR_TITLE', 'BLANK')]
[Alias('merge_commit_message')]
- [string] $MergeCommitMessage
+ [string] $MergeCommitMessage,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
dynamicparam {
@@ -241,6 +245,7 @@ filter New-GitHubRepositoryUser {
Remove-HashtableEntry -Hashtable $body -NullOrEmptyValues
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/repos'
Method = 'POST'
Body = $body
diff --git a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1
index 5afca493..05fc6d86 100644
--- a/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Block-GitHubUserByUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -25,10 +25,15 @@
ValueFromPipelineByPropertyName
)]
[Alias('login')]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/blocks/$Username"
Method = 'PUT'
}
diff --git a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1
index f061a7e1..2e039dd7 100644
--- a/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Get-GitHubBlockedUserByUser.ps1
@@ -16,16 +16,23 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/blocks'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1 b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1
index 5b7525e3..96683398 100644
--- a/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Test-GitHubBlockedUserByUser.ps1
@@ -19,7 +19,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -32,12 +32,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/blocks/$Username"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1 b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1
index 6192d8ea..eee6f5ed 100644
--- a/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1
+++ b/src/functions/private/Users/Blocking/Unblock-GitHubUserByUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -25,10 +25,15 @@
ValueFromPipelineByPropertyName
)]
[Alias('login')]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/blocks/$Username"
Method = 'DELETE'
}
diff --git a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1
index fe6b3739..ddf1fe00 100644
--- a/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1
+++ b/src/functions/private/Users/Emails/Get-GitHubUserAllEmail.ps1
@@ -18,16 +18,22 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
- )
+ [int] $PerPage = 30,
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
+ )
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/emails'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1 b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1
index fe3cd4d5..81804321 100644
--- a/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1
+++ b/src/functions/private/Users/Emails/Get-GitHubUserPublicEmail.ps1
@@ -20,16 +20,23 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Link to documentation.')]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/public_emails'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1
index 9c7af7ce..ffd7168f 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowersOfUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -30,13 +30,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'username'
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/followers"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1
index 7f60cde6..8ff7d5ac 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingMe.ps1
@@ -17,16 +17,23 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/following'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1
index a6a75fad..b86600ae 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserFollowingUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -30,13 +30,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'username'
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/following"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1 b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1
index 8948c5e3..536c2d80 100644
--- a/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1
+++ b/src/functions/private/Users/Followers/Get-GitHubUserMyFollowers.ps1
@@ -18,16 +18,23 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'Private function, not exposed to user.')]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/followers'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1
index 22be3366..0e4b864b 100644
--- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1
+++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByMe.ps1
@@ -18,16 +18,21 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/following/$Username"
Method = 'GET'
}
diff --git a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1 b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1
index 2fe83681..646f72cb 100644
--- a/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1
+++ b/src/functions/private/Users/Followers/Test-GitHubUserFollowedByUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -30,10 +30,15 @@
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $Follows
+ [string] $Follows,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/following/$Follows"
Method = 'GET'
}
diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1
index 458232ac..fe765f9d 100644
--- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1
+++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserGpgKeyForUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -28,13 +28,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'username'
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/gpg_keys"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1
index 55c9e609..6c27bfbb 100644
--- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1
+++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKey.ps1
@@ -19,16 +19,23 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/gpg_keys'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1 b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1
index 670d5eb2..d02b5208 100644
--- a/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1
+++ b/src/functions/private/Users/GPG-Keys/Get-GitHubUserMyGpgKeyById.ps1
@@ -19,16 +19,21 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The ID of the GPG key.
[Parameter(
Mandatory
)]
[Alias('gpg_key_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/gpg_keys/$ID"
Method = 'GET'
}
diff --git a/src/functions/private/Users/Get-GitHubAllUser.ps1 b/src/functions/private/Users/Get-GitHubAllUser.ps1
index 5e86f7a4..da9ac9b3 100644
--- a/src/functions/private/Users/Get-GitHubAllUser.ps1
+++ b/src/functions/private/Users/Get-GitHubAllUser.ps1
@@ -20,7 +20,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# A user ID. Only return users with an ID greater than this ID.
[Parameter()]
[int] $Since = 0,
@@ -28,12 +28,20 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ since = $Since
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/users'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Get-GitHubMyUser.ps1 b/src/functions/private/Users/Get-GitHubMyUser.ps1
index 8bcf609f..d26a76bf 100644
--- a/src/functions/private/Users/Get-GitHubMyUser.ps1
+++ b/src/functions/private/Users/Get-GitHubMyUser.ps1
@@ -19,9 +19,14 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
+ )
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user'
Method = 'GET'
}
diff --git a/src/functions/private/Users/Get-GitHubUserByName.ps1 b/src/functions/private/Users/Get-GitHubUserByName.ps1
index d60ca0d6..d514939f 100644
--- a/src/functions/private/Users/Get-GitHubUserByName.ps1
+++ b/src/functions/private/Users/Get-GitHubUserByName.ps1
@@ -28,7 +28,7 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -36,10 +36,15 @@
ValueFromPipelineByPropertyName
)]
[Alias('login')]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username"
Method = 'GET'
}
diff --git a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1
index 9f035a1e..ad5f906c 100644
--- a/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1
+++ b/src/functions/private/Users/Keys/Get-GitHubUserKeyForUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -28,13 +28,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'username'
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/keys"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1
index 3ab88f46..6eaa2a3a 100644
--- a/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1
+++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKey.ps1
@@ -19,16 +19,23 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/keys'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1 b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1
index 6db617b4..1b5f4abe 100644
--- a/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1
+++ b/src/functions/private/Users/Keys/Get-GitHubUserMyKeyById.ps1
@@ -19,16 +19,21 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The unique identifier of the key.
[Parameter(
Mandatory
)]
[Alias('key_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/keys/$ID"
Method = 'GET'
}
diff --git a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1 b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1
index 2573b342..0f471bb2 100644
--- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1
+++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKey.ps1
@@ -19,16 +19,23 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/ssh_signing_keys'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1 b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1
index 5620df3e..007e4a73 100644
--- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1
+++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserMySigningKeyById.ps1
@@ -20,16 +20,21 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The unique identifier of the SSH signing key.
[Parameter(
Mandatory
)]
[Alias('ssh_signing_key_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/ssh_signing_keys/$ID"
Method = 'GET'
}
diff --git a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1 b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1
index 87f0590f..40ad78c7 100644
--- a/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1
+++ b/src/functions/private/Users/SSH-Signing-Keys/Get-GitHubUserSigningKeyForUser.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -28,13 +28,19 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'username'
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/ssh_signing_keys"
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1
index 569e706f..84f6435c 100644
--- a/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1
+++ b/src/functions/private/Users/Social-Accounts/Get-GitHubMyUserSocials.ps1
@@ -17,16 +17,23 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'Private function, not exposed to user.')]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/social_accounts'
Method = 'GET'
Body = $body
diff --git a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1 b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1
index 12e0c421..81cc3180 100644
--- a/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1
+++ b/src/functions/private/Users/Social-Accounts/Get-GitHubUserSocialsByName.ps1
@@ -16,7 +16,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -24,10 +24,15 @@
ValueFromPipelineByPropertyName
)]
[Alias('login')]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/social_accounts"
Method = 'GET'
}
diff --git a/src/functions/private/Utilities/Casing/Convert-StringCasingStyle.ps1 b/src/functions/private/Utilities/Casing/Convert-StringCasingStyle.ps1
index 25a659f7..ea3d2058 100644
--- a/src/functions/private/Utilities/Casing/Convert-StringCasingStyle.ps1
+++ b/src/functions/private/Utilities/Casing/Convert-StringCasingStyle.ps1
@@ -24,7 +24,7 @@
#>
[OutputType([string])]
[CmdletBinding()]
- param (
+ param(
# The string to convert
[Parameter(
Mandatory,
diff --git a/src/functions/private/Utilities/Casing/Get-StringCasingStyle.ps1 b/src/functions/private/Utilities/Casing/Get-StringCasingStyle.ps1
index 49e4624e..ae95a259 100644
--- a/src/functions/private/Utilities/Casing/Get-StringCasingStyle.ps1
+++ b/src/functions/private/Utilities/Casing/Get-StringCasingStyle.ps1
@@ -58,7 +58,7 @@
#>
[OutputType([string])]
[CmdletBinding()]
- param (
+ param(
# The string to check the casing style of
[Parameter(
Mandatory,
diff --git a/src/functions/private/Utilities/Casing/Split-StringByCasingStyle.ps1 b/src/functions/private/Utilities/Casing/Split-StringByCasingStyle.ps1
index a3cd8d78..c32fa933 100644
--- a/src/functions/private/Utilities/Casing/Split-StringByCasingStyle.ps1
+++ b/src/functions/private/Utilities/Casing/Split-StringByCasingStyle.ps1
@@ -56,7 +56,7 @@
#>
[OutputType([string[]])]
[CmdletBinding()]
- param (
+ param(
# The string to split
[Parameter(
Mandatory,
diff --git a/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1 b/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1
index df8f4052..38968847 100644
--- a/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1
+++ b/src/functions/private/Utilities/Hashtable/ConvertFrom-HashTable.ps1
@@ -32,7 +32,7 @@
[OutputType([pscustomobject])]
[Alias('ConvertFrom-Dictionary')]
[CmdletBinding()]
- param (
+ param(
# The hashtable to be converted. The input takes any type of dictionary. The original dictionary is not modified.
[Parameter(
Mandatory,
diff --git a/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1 b/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1
index e61d573b..8b5e71f4 100644
--- a/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1
+++ b/src/functions/private/Utilities/Hashtable/ConvertTo-HashTable.ps1
@@ -34,7 +34,7 @@
[OutputType([hashtable])]
[Alias('ConvertTo-Dictionary')]
[CmdletBinding()]
- param (
+ param(
# The object to be converted. The input takes any type of object. The original object is not modified.
[Parameter(
Mandatory,
diff --git a/src/functions/private/Utilities/Hashtable/Join-Object.ps1 b/src/functions/private/Utilities/Hashtable/Join-Object.ps1
index 7f93a32a..18306e04 100644
--- a/src/functions/private/Utilities/Hashtable/Join-Object.ps1
+++ b/src/functions/private/Utilities/Hashtable/Join-Object.ps1
@@ -53,7 +53,7 @@
[OutputType(ParameterSetName = 'AsHashTable', [hashtable])]
[Alias('Merge-Object')]
[CmdletBinding(DefaultParameterSetName = '__DefaultSet')]
- param (
+ param(
# The main object to merge into. This object will be cloned, so the original object will not be modified.
[Parameter(
Mandatory,
diff --git a/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1 b/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1
index b35c7f79..0984f4f4 100644
--- a/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1
+++ b/src/functions/private/Utilities/Hashtable/Remove-HashtableEntry.ps1
@@ -25,7 +25,7 @@
Justification = 'Function does not change state.'
)]
[CmdletBinding()]
- param (
+ param(
# The hashtable to remove entries from.
[Parameter(
Mandatory,
diff --git a/src/functions/public/API/Invoke-GitHubAPI.ps1 b/src/functions/public/API/Invoke-GitHubAPI.ps1
index 7d7e0096..4b584561 100644
--- a/src/functions/public/API/Invoke-GitHubAPI.ps1
+++ b/src/functions/public/API/Invoke-GitHubAPI.ps1
@@ -23,7 +23,7 @@
Gets all open pull requests for the specified repository, filtered by the 'state' parameter, and using the specified 'Accept' header.
#>
[CmdletBinding(DefaultParameterSetName = 'ApiEndpoint')]
- param (
+ param(
# The HTTP method to be used for the API request. It can be one of the following: GET, POST, PUT, DELETE, or PATCH.
[Parameter()]
[Microsoft.PowerShell.Commands.WebRequestMethod] $Method = 'GET',
@@ -89,44 +89,36 @@
[string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- Write-Verbose 'Invoking GitHub API...'
+ Write-Debug 'Invoking GitHub API...'
$PSBoundParameters.GetEnumerator() | ForEach-Object {
- Write-Verbose " - $($_.Key): $($_.Value)"
+ Write-Debug " - $($_.Key): $($_.Value)"
}
- $contextObj = Get-GitHubContext -Name $Context
- Write-Verbose "Using GitHub context: $Context"
+ $contextObj = Get-GitHubContext -Context $Context
if (-not $contextObj) {
throw 'Log in using Connect-GitHub before running this command.'
}
+ Write-Debug "Context: [$Context]"
if ([string]::IsNullOrEmpty($ApiBaseUri)) {
- Write-Verbose 'Using default API base URI from context.'
- Write-Verbose $($contextObj.ApiBaseUri)
$ApiBaseUri = $contextObj.ApiBaseUri
}
- Write-Verbose "ApiBaseUri: $ApiBaseUri"
+ Write-Debug "ApiBaseUri : [$($contextObj.ApiBaseUri)]"
if ([string]::IsNullOrEmpty($ApiVersion)) {
- Write-Verbose 'Using default API version from context.'
- Write-Verbose $($contextObj.ApiVersion)
$ApiVersion = $contextObj.ApiVersion
}
- Write-Verbose "ApiVersion: $ApiVersion"
+ Write-Debug "ApiVersion : [$($contextObj.ApiVersion)]"
if ([string]::IsNullOrEmpty($TokenType)) {
- Write-Verbose 'Using default token type from context.'
- Write-Verbose $($contextObj.TokenType)
$TokenType = $contextObj.TokenType
}
- Write-Verbose "TokenType: $TokenType"
+ Write-Debug "TokenType : [$($contextObj.TokenType)]"
if ([string]::IsNullOrEmpty($Token)) {
- Write-Verbose 'Using default token from context.'
- Write-Verbose $($contextObj.Token)
$Token = $contextObj.Token
}
- Write-Verbose "Token: $Token"
+ Write-Debug "Token : [$($contextObj.Token)]"
switch ($tokenType) {
'ghu' {
@@ -154,16 +146,16 @@
}
$APICall = @{
- Uri = $URI
- Method = $Method
- Headers = $Headers
- Authentication = 'Bearer'
- Token = $Token
- ContentType = $ContentType
- FollowRelLink = $FollowRelLink
- InFile = $UploadFilePath
- OutFile = $DownloadFilePath
- HttpVersion = $HttpVersion
+ Uri = $URI
+ Method = [string]$Method
+ Headers = $Headers
+ Authentication = 'Bearer'
+ Token = $Token
+ ContentType = $ContentType
+ FollowRelLink = $FollowRelLink
+ InFile = $UploadFilePath
+ OutFile = $DownloadFilePath
+ HttpVersion = [string]$HttpVersion
}
$APICall | Remove-HashtableEntry -NullOrEmptyValues
@@ -182,21 +174,21 @@
}
try {
- Write-Verbose "----------------------------------"
- Write-Verbose "Request:"
+ Write-Verbose '----------------------------------'
+ Write-Verbose 'Request:'
$APICall | ConvertFrom-HashTable | Format-List | Out-String -Stream | ForEach-Object { Write-Verbose $_ }
- Write-Verbose "----------------------------------"
+ Write-Verbose '----------------------------------'
Invoke-RestMethod @APICall | ForEach-Object {
[pscustomobject]@{
- Request = $APICall
- Response = $_
+ Request = $APICall
+ Response = $_
}
}
} catch {
$failure = $_
$headers = @{}
foreach ($item in $failure.Exception.Response.Headers) {
- $headers[$item.Key] = ($item.Value).Trim() -join ", "
+ $headers[$item.Key] = ($item.Value).Trim() -join ', '
}
$headers = [pscustomobject]$headers
# Sort properties by name and display the object
@@ -214,13 +206,13 @@
$APICall.Headers = $APICall.Headers | ConvertTo-Json
$APICall.Method = $APICall.Method.ToString()
- Write-Error "----------------------------------"
- Write-Error "Error details:"
+ Write-Error '----------------------------------'
+ Write-Error 'Error details:'
$errorResult | Format-Table -AutoSize -HideTableHeaders | Out-String -Stream | ForEach-Object { Write-Error $_ }
- Write-Error "----------------------------------"
- Write-Debug "Response headers:"
+ Write-Error '----------------------------------'
+ Write-Debug 'Response headers:'
$headers | Out-String -Stream | ForEach-Object { Write-Debug $_ }
- Write-Debug "---------------------------"
+ Write-Debug '---------------------------'
throw $failure.Exception.Message
}
-}
\ No newline at end of file
+}
diff --git a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1
index ded382b8..22f6e6c4 100644
--- a/src/functions/public/Actions/Disable-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Disable-GitHubWorkflow.ps1
@@ -4,21 +4,45 @@
[Disable a workflow](https://docs.github.com/en/rest/actions/workflows#disable-a-workflow)
#>
[CmdletBinding()]
- param (
+ param(
+ # The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
+ # The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
+ # The ID of the workflow. You can also pass the workflow filename as a string.
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string[]] $ID
+ [string[]] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/disable"
Method = 'PUT'
}
diff --git a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1 b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1
index a1825870..db19b021 100644
--- a/src/functions/public/Actions/Enable-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Enable-GitHubWorkflow.ps1
@@ -4,21 +4,42 @@
[Enable a workflow](https://docs.github.com/en/rest/actions/workflows#enable-a-workflow)
#>
[CmdletBinding()]
- param (
+ param(
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string[]] $ID
+ [string[]] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/enable"
Method = 'PUT'
}
diff --git a/src/functions/public/Actions/Get-GitHubWorkflow.ps1 b/src/functions/public/Actions/Get-GitHubWorkflow.ps1
index 657690ec..e0453733 100644
--- a/src/functions/public/Actions/Get-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Get-GitHubWorkflow.ps1
@@ -22,25 +22,45 @@
[List repository workflows](https://docs.github.com/rest/actions/workflows?apiVersion=2022-11-28#list-repository-workflows)
#>
[CmdletBinding(DefaultParameterSetName = 'ByName')]
- param (
+ param(
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
$body = @{
per_page = $PerPage
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/actions/workflows"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1
index 60af3bb1..c6bf2912 100644
--- a/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Actions/Get-GitHubWorkflowRun.ps1
@@ -6,12 +6,12 @@
#>
[CmdletBinding(DefaultParameterSetName = 'Repo')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
- param (
+ param(
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
[Parameter(ParameterSetName = 'ByName')]
[string] $Name,
@@ -22,9 +22,29 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$body = @{
per_page = $PerPage
}
@@ -40,6 +60,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = $Uri
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1 b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1
index 1bcdec70..8e2a43dc 100644
--- a/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1
+++ b/src/functions/public/Actions/Get-GitHubWorkflowUsage.ps1
@@ -6,15 +6,6 @@
.DESCRIPTION
Long description
- .PARAMETER Owner
- Parameter description
-
- .PARAMETER Repo
- Parameter description
-
- .PARAMETER ID
- Parameter description
-
.EXAMPLE
An example
@@ -24,21 +15,42 @@
[CmdletBinding(
DefaultParameterSetName = 'ByName'
)]
- param (
+ param(
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string[]] $ID
+ [string[]] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
Method = 'GET'
APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/timing"
}
diff --git a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1
index 723e8d80..b8d999df 100644
--- a/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Actions/Remove-GitHubWorkflowRun.ps1
@@ -17,14 +17,14 @@
[Delete a workflow run](https://docs.github.com/rest/actions/workflow-runs#delete-a-workflow-run)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the workflow run.
[Parameter(
@@ -32,10 +32,31 @@
ValueFromPipelineByPropertyName
)]
[Alias('ID', 'run_id')]
- [string] $RunID
+ [string] $RunID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "repos/$Owner/$Repo/actions/runs/$RunID"
Method = 'DELETE'
}
diff --git a/src/functions/public/Actions/Start-GitHubWorkflow.ps1 b/src/functions/public/Actions/Start-GitHubWorkflow.ps1
index 1a50ddb7..d7fbb31e 100644
--- a/src/functions/public/Actions/Start-GitHubWorkflow.ps1
+++ b/src/functions/public/Actions/Start-GitHubWorkflow.ps1
@@ -18,14 +18,14 @@
[Create a workflow dispatch event](https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The ID of the workflow.
[Alias('workflow_id')]
@@ -44,15 +44,36 @@
# Input parameters for the workflow run. You can use the inputs and payload keys to pass custom data to your workflow.
[Parameter()]
- [hashtable] $Inputs = @{}
+ [hashtable] $Inputs = @{},
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$body = @{
ref = $Ref
inputs = $Inputs
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/actions/workflows/$ID/dispatches"
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1 b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1
index f4dc66dc..2cb69bc5 100644
--- a/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1
+++ b/src/functions/public/Actions/Start-GitHubWorkflowReRun.ps1
@@ -13,14 +13,14 @@
[Re-run a workflow](https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-workflow)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the workflow run.
[Alias('workflow_id')]
@@ -28,10 +28,31 @@
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
Method = 'POST'
APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/rerun"
}
diff --git a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1 b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1
index 181293df..9ee26f17 100644
--- a/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1
+++ b/src/functions/public/Actions/Stop-GitHubWorkflowRun.ps1
@@ -16,23 +16,43 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[alias('Cancel-GitHubWorkflowRun')]
- param (
+ param(
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
[Alias('workflow_id')]
[Parameter(
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
$inputObject = @{
+ Context = $Context
Method = 'POST'
APIEndpoint = "/repos/$Owner/$Repo/actions/runs/$ID/cancel"
}
diff --git a/src/functions/public/Apps/Get-GitHubApp.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1
similarity index 98%
rename from src/functions/public/Apps/Get-GitHubApp.ps1
rename to src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1
index ae61fe13..3cb68868 100644
--- a/src/functions/public/Apps/Get-GitHubApp.ps1
+++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubApp.ps1
@@ -24,6 +24,7 @@
[CmdletBinding()]
param(
# The context to run the command in.
+ [Parameter()]
[string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
diff --git a/src/functions/public/Apps/Get-GitHubAppInstallation.ps1 b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1
similarity index 74%
rename from src/functions/public/Apps/Get-GitHubAppInstallation.ps1
rename to src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1
index fc6cc514..3b5411fc 100644
--- a/src/functions/public/Apps/Get-GitHubAppInstallation.ps1
+++ b/src/functions/public/Apps/GitHub Apps/Get-GitHubAppInstallation.ps1
@@ -9,17 +9,23 @@
You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app)
to access this endpoint.
-
.EXAMPLE
- An example
+ Get-GitHubAppInstallation
+
+ List installations for the authenticated app.
.NOTES
[List installations for the authenticated app](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app)
#>
[CmdletBinding()]
- param()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
$inputObject = @{
+ Context = $Context
APIEndpoint = '/app/installations'
Method = 'GET'
}
diff --git a/src/functions/public/Apps/New-GitHubAppInstallationAccessToken.ps1 b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1
similarity index 94%
rename from src/functions/public/Apps/New-GitHubAppInstallationAccessToken.ps1
rename to src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1
index 5fa32da7..b499295a 100644
--- a/src/functions/public/Apps/New-GitHubAppInstallationAccessToken.ps1
+++ b/src/functions/public/Apps/GitHub Apps/New-GitHubAppInstallationAccessToken.ps1
@@ -46,7 +46,7 @@
Justification = 'No state is changed.'
)]
[CmdletBinding()]
- param (
+ param(
# The unique identifier of the installation.
# Example: '12345678'
[Parameter(
@@ -55,10 +55,15 @@
ValueFromPipelineByPropertyName
)]
[Alias('ID')]
- [int] $InstallationID
+ [int] $InstallationID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/app/installations/$InstallationID/access_tokens"
Method = 'Post'
}
diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1
new file mode 100644
index 00000000..a44adc10
--- /dev/null
+++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookConfiguration.ps1
@@ -0,0 +1,37 @@
+function Get-GitHubAppWebhookConfiguration {
+ <#
+ .SYNOPSIS
+ Get a webhook configuration for an app
+
+ .DESCRIPTION
+ Returns the webhook configuration for a GitHub App. For more information about configuring a webhook for your app, see
+ "[Creating a GitHubApp](/developers/apps/creating-a-github-app)."
+
+ You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app)
+ to access this endpoint.
+
+ .EXAMPLE
+ Get-GitHubAppWebhookConfiguration
+
+ Returns the webhook configuration for the authenticated app.
+
+ .NOTES
+ [Get a webhook configuration for an app](https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app)
+ #>
+ [CmdletBinding()]
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/app/hook/config'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+}
diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1
new file mode 100644
index 00000000..f08b9892
--- /dev/null
+++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1
@@ -0,0 +1,36 @@
+function Get-GitHubAppWebhookDelivery {
+ <#
+ .SYNOPSIS
+ List deliveries for an app webhook
+
+ .DESCRIPTION
+ Returns a list of webhook deliveries for the webhook configured for a GitHub App.
+
+ You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app)
+ to access this endpoint.
+
+ .EXAMPLE
+ Get-GitHubAppWebhookDelivery
+
+ Returns the webhook configuration for the authenticated app.
+
+ .NOTES
+ [Get a webhook configuration for an app](https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app)
+ #>
+ [CmdletBinding()]
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
+
+ $inputObject = @{
+ Context = $Context
+ APIEndpoint = '/app/hook/deliveries'
+ Method = 'GET'
+ }
+
+ Invoke-GitHubAPI @inputObject | ForEach-Object {
+ Write-Output $_.Response
+ }
+}
diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1
index 43fd1089..81853b73 100644
--- a/src/functions/public/Auth/Connect-GitHubAccount.ps1
+++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1
@@ -55,7 +55,7 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Is the CLI part of the module.')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Justification = 'The tokens are recieved as clear text. Mitigating exposure by removing variables and performing garbage collection.')]
[CmdletBinding(DefaultParameterSetName = 'UAT')]
- param (
+ param(
# Choose between authentication methods, either OAuthApp or GitHubApp.
# For more info about the types of authentication visit:
# [Differences between GitHub Apps and OAuth apps](https://docs.github.com/apps/oauth-apps/building-oauth-apps/differences-between-github-apps-and-oauth-apps)
diff --git a/src/functions/public/Auth/Context/Set-GitHubContext.ps1 b/src/functions/public/Auth/Context/Set-GitHubContext.ps1
index 779f1ead..73181784 100644
--- a/src/functions/public/Auth/Context/Set-GitHubContext.ps1
+++ b/src/functions/public/Auth/Context/Set-GitHubContext.ps1
@@ -15,7 +15,7 @@ function Set-GitHubContext {
General notes
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The Node ID of the context.
[Parameter()]
[string] $NodeID,
diff --git a/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1 b/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1
index 3d93779e..691e6ed7 100644
--- a/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1
+++ b/src/functions/public/Auth/Context/Set-GitHubDefaultContext.ps1
@@ -10,7 +10,7 @@
Set-GitHubDefaultContext -Context 'github.com/Octocat'
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The context to set as the default.
[Parameter(Mandatory)]
[Alias('Name')]
diff --git a/src/functions/public/Auth/ContextSetting/Set-GitHubContextSetting.ps1 b/src/functions/public/Auth/ContextSetting/Set-GitHubContextSetting.ps1
index 42f613c0..7dc7324c 100644
--- a/src/functions/public/Auth/ContextSetting/Set-GitHubContextSetting.ps1
+++ b/src/functions/public/Auth/ContextSetting/Set-GitHubContextSetting.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
function Set-GitHubContextSetting {
<#
@@ -20,7 +20,7 @@ function Set-GitHubContextSetting {
#>
[Alias('Set-GHConfig')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# Set the access token type.
[Parameter()]
[string] $TokenType,
diff --git a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1 b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1
index 331bbe84..1aa7800f 100644
--- a/src/functions/public/Branches/Get-GitHubRepoBranch.ps1
+++ b/src/functions/public/Branches/Get-GitHubRepoBranch.ps1
@@ -15,17 +15,38 @@
[List branches](https://docs.github.com/rest/branches/branches#list-branches)
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/branches"
Method = 'GET'
}
diff --git a/src/functions/public/Commands/Add-GitHubSystemPath.ps1 b/src/functions/public/Commands/Add-GitHubSystemPath.ps1
index 3183b203..02154c13 100644
--- a/src/functions/public/Commands/Add-GitHubSystemPath.ps1
+++ b/src/functions/public/Commands/Add-GitHubSystemPath.ps1
@@ -20,7 +20,7 @@
)]
[OutputType([void])]
[CmdletBinding()]
- param (
+ param(
[string]$Path
)
diff --git a/src/functions/public/Commands/Disable-GitHubCommand.ps1 b/src/functions/public/Commands/Disable-GitHubCommand.ps1
index aafb3231..bfc89d4f 100644
--- a/src/functions/public/Commands/Disable-GitHubCommand.ps1
+++ b/src/functions/public/Commands/Disable-GitHubCommand.ps1
@@ -28,7 +28,7 @@
)]
[OutputType([void])]
[CmdletBinding()]
- param (
+ param(
# The unique string to stop the processing of workflow commands
[Parameter(Mandatory)]
[string] $String
diff --git a/src/functions/public/Commands/Enable-GitHubCommand.ps1 b/src/functions/public/Commands/Enable-GitHubCommand.ps1
index d3d7f7e2..2fa7e2f0 100644
--- a/src/functions/public/Commands/Enable-GitHubCommand.ps1
+++ b/src/functions/public/Commands/Enable-GitHubCommand.ps1
@@ -27,7 +27,7 @@
)]
[OutputType([void])]
[CmdletBinding()]
- param (
+ param(
# The unique string to resume the processing of workflow commands
[Parameter(Mandatory)]
[string] $String
diff --git a/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1 b/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1
index f8ce4f10..38646ba4 100644
--- a/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1
+++ b/src/functions/public/Commands/Set-GitHubEnvironmentVariable.ps1
@@ -23,7 +23,7 @@
[OutputType([void])]
[Alias('Set-GitHubEnv')]
[CmdletBinding()]
- param (
+ param(
# Name of the variable
[Parameter(Mandatory)]
[string] $Name,
diff --git a/src/functions/public/Commands/Set-GitHubStepSummary.ps1 b/src/functions/public/Commands/Set-GitHubStepSummary.ps1
index b965fdc5..c987e526 100644
--- a/src/functions/public/Commands/Set-GitHubStepSummary.ps1
+++ b/src/functions/public/Commands/Set-GitHubStepSummary.ps1
@@ -32,7 +32,7 @@
[OutputType([void])]
[Alias('Summary')]
[CmdletBinding()]
- param (
+ param(
# Summary of the step
[Parameter(Mandatory)]
[AllowNull()]
diff --git a/src/functions/public/Commands/Write-GitHubDebug.ps1 b/src/functions/public/Commands/Write-GitHubDebug.ps1
index dd7c9699..4001415b 100644
--- a/src/functions/public/Commands/Write-GitHubDebug.ps1
+++ b/src/functions/public/Commands/Write-GitHubDebug.ps1
@@ -29,7 +29,7 @@
[OutputType([void])]
[Alias('Debug')]
[CmdletBinding()]
- param (
+ param(
# Message to write
[Parameter(Mandatory)]
[string] $Message
diff --git a/src/functions/public/Commands/Write-GitHubError.ps1 b/src/functions/public/Commands/Write-GitHubError.ps1
index 1dee78bc..de1743fd 100644
--- a/src/functions/public/Commands/Write-GitHubError.ps1
+++ b/src/functions/public/Commands/Write-GitHubError.ps1
@@ -25,7 +25,7 @@
[OutputType([void])]
[Alias('Error')]
[CmdletBinding()]
- param (
+ param(
# Message to write
[Parameter(Mandatory)]
[string] $Message,
diff --git a/src/functions/public/Commands/Write-GitHubNotice.ps1 b/src/functions/public/Commands/Write-GitHubNotice.ps1
index 7da5a0d8..51b3ac9e 100644
--- a/src/functions/public/Commands/Write-GitHubNotice.ps1
+++ b/src/functions/public/Commands/Write-GitHubNotice.ps1
@@ -25,7 +25,7 @@
[OutputType([void])]
[Alias('Notice')]
[CmdletBinding()]
- param (
+ param(
# Message to write
[Parameter(Mandatory)]
[string] $Message,
diff --git a/src/functions/public/Commands/Write-GitHubWarning.ps1 b/src/functions/public/Commands/Write-GitHubWarning.ps1
index 9346f5b6..c4fb8f50 100644
--- a/src/functions/public/Commands/Write-GitHubWarning.ps1
+++ b/src/functions/public/Commands/Write-GitHubWarning.ps1
@@ -25,7 +25,7 @@
[OutputType([void])]
[Alias('Warning')]
[CmdletBinding()]
- param (
+ param(
# Message to write
[Parameter(Mandatory)]
[string] $Message,
diff --git a/src/functions/public/Config/Get-GitHubConfig.ps1 b/src/functions/public/Config/Get-GitHubConfig.ps1
index 524579de..c5f0283e 100644
--- a/src/functions/public/Config/Get-GitHubConfig.ps1
+++ b/src/functions/public/Config/Get-GitHubConfig.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
function Get-GitHubConfig {
<#
@@ -15,7 +15,7 @@ function Get-GitHubConfig {
#>
[OutputType([void])]
[CmdletBinding()]
- param (
+ param(
# The name of the configuration to get.
[Parameter()]
[string] $Name
diff --git a/src/functions/public/Config/Remove-GitHubConfig.ps1 b/src/functions/public/Config/Remove-GitHubConfig.ps1
index 0389ce1d..62afa7ad 100644
--- a/src/functions/public/Config/Remove-GitHubConfig.ps1
+++ b/src/functions/public/Config/Remove-GitHubConfig.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
function Remove-GitHubConfig {
<#
@@ -14,7 +14,7 @@ function Remove-GitHubConfig {
Removes the 'DefaultUser' item in the GitHub module configuration.
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# Set the access token type.
[Parameter()]
[string] $Name
diff --git a/src/functions/public/Config/Set-GitHubConfig.ps1 b/src/functions/public/Config/Set-GitHubConfig.ps1
index 2be9e9a5..7d8f5215 100644
--- a/src/functions/public/Config/Set-GitHubConfig.ps1
+++ b/src/functions/public/Config/Set-GitHubConfig.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
+#Requires -Modules @{ ModuleName = 'Context'; RequiredVersion = '4.0.0' }
function Set-GitHubConfig {
<#
@@ -14,7 +14,7 @@ function Set-GitHubConfig {
Sets the value of DefaultUser to 'Octocat' in the GitHub module configuration.
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# Set the access token type.
[Parameter()]
[string] $Name,
diff --git a/src/functions/public/Emojis/Get-GitHubEmoji.ps1 b/src/functions/public/Emojis/Get-GitHubEmoji.ps1
index 49796e9d..dadaddd6 100644
--- a/src/functions/public/Emojis/Get-GitHubEmoji.ps1
+++ b/src/functions/public/Emojis/Get-GitHubEmoji.ps1
@@ -21,13 +21,18 @@
[Get emojis](https://docs.github.com/rest/reference/emojis#get-emojis)
#>
[CmdletBinding()]
- param (
+ param(
# The path to the directory where the emojis will be downloaded.
[Parameter()]
- [string] $Destination
+ [string] $Destination,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = '/emojis'
Method = 'GET'
}
@@ -37,7 +42,7 @@
}
if (Test-Path -Path $Destination) {
- $response.PSObject.Properties | ForEach-Object -Parallel {
+ $response.PSObject.Properties | ForEach-Object -ThrottleLimit ([System.Environment]::ProcessorCount) -Parallel {
Invoke-WebRequest -Uri $_.Value -OutFile "$using:Destination/$($_.Name).png"
}
} else {
diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1
index b973c046..a27b8e4b 100644
--- a/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1
+++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseInstallableOrganization.ps1
@@ -16,9 +16,15 @@
param(
# The enterprise slug or ID.
[Parameter(Mandatory)]
- [string] $Enterprise
+ [string] $Enterprise,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/enterprises/$Enterprise/apps/installable_organizations"
Method = 'GET'
}
diff --git a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1
index 286675c7..db7ae48c 100644
--- a/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1
+++ b/src/functions/public/Enterprise/Get-GitHubEnterpriseOrganization.ps1
@@ -7,12 +7,16 @@
Use this function to retrieve the list of organizations in a GitHub Enterprise instance.
.EXAMPLE
- Get-GitHubEnterpriseOrganization -EnterpriseSlug 'msx'
+ Get-GitHubEnterpriseOrganization -Enterprise 'msx'
#>
[CmdletBinding()]
param(
[Parameter(Mandatory)]
- [string] $EnterpriseSlug
+ [string] $Enterprise,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
# Define GraphQL query
@@ -37,7 +41,7 @@ query(`$enterpriseSlug: String!, `$first: Int = 100, `$after: String) {
# Initialize pagination variables
$variables = @{
- 'enterpriseSlug' = $EnterpriseSlug
+ 'enterpriseSlug' = $Enterprise
'first' = 100
'after' = $null
}
@@ -45,7 +49,7 @@ query(`$enterpriseSlug: String!, `$first: Int = 100, `$after: String) {
# Loop through pages to retrieve all organizations
do {
- $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables
+ $response = Invoke-GitHubGraphQLQuery -Query $query -Variables $variables -Context $Context
# Check for errors
if ($response.errors) {
Write-Error "Error: $($response.errors[0].message)"
diff --git a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1 b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1
index ea37d84a..fd51cbe9 100644
--- a/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1
+++ b/src/functions/public/Enterprise/Install-GitHubAppOnEnterpriseOrganization.ps1
@@ -34,7 +34,11 @@
# The names of the repositories to which the installation will be granted access.
[Parameter()]
- [string[]] $Repositories
+ [string[]] $Repositories,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$body = @{
@@ -45,6 +49,7 @@
$body | Remove-HashtableEntry -NullOrEmptyValues
$inputObject = @{
+ Context = $Context
APIEndpoint = "/enterprises/$Enterprise/apps/organizations/$Organization/installations"
Method = 'Post'
Body = $body
diff --git a/src/functions/public/Git/Set-GitHubGitConfig.ps1 b/src/functions/public/Git/Set-GitHubGitConfig.ps1
index fd9e3a48..d811360d 100644
--- a/src/functions/public/Git/Set-GitHubGitConfig.ps1
+++ b/src/functions/public/Git/Set-GitHubGitConfig.ps1
@@ -17,7 +17,7 @@
Sets the Git configuration for the GitHub context named 'MyContext'.
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The context to use for the API call. This is used to retrieve the necessary configuration settings.
[Parameter()]
[string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
diff --git a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1 b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1
index e8064fed..6f52b7f1 100644
--- a/src/functions/public/Gitignore/Get-GitHubGitignore.ps1
+++ b/src/functions/public/Gitignore/Get-GitHubGitignore.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' }
+#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' }
filter Get-GitHubGitignore {
<#
@@ -25,7 +25,11 @@ filter Get-GitHubGitignore {
#>
[CmdletBinding(DefaultParameterSetName = 'List')]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
dynamicparam {
$DynamicParamDictionary = New-DynamicParamDictionary
@@ -47,10 +51,10 @@ filter Get-GitHubGitignore {
$Name = $PSBoundParameters['Name']
switch ($PSCmdlet.ParameterSetName) {
'List' {
- Get-GitHubGitignoreList
+ Get-GitHubGitignoreList -Context $Context
}
'Name' {
- Get-GitHubGitignoreByName -Name $Name
+ Get-GitHubGitignoreByName -Name $Name -Context $Context
}
}
}
diff --git a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1 b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1
index 081c7aac..2c8531d3 100644
--- a/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1
+++ b/src/functions/public/GraphQL/Invoke-GitHubGraphQLQuery.ps1
@@ -12,7 +12,7 @@
.NOTES
[GitHub GraphQL API documentation](https://docs.github.com/graphql)
#>
- param (
+ param(
# The GraphQL query to execute.
[string] $Query,
@@ -20,6 +20,7 @@
[hashtable] $Variables,
# The context to run the command in.
+ [Parameter()]
[string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
diff --git a/src/functions/public/License/Get-GitHubLicense.ps1 b/src/functions/public/License/Get-GitHubLicense.ps1
index 5a4efc21..b45ee2d6 100644
--- a/src/functions/public/License/Get-GitHubLicense.ps1
+++ b/src/functions/public/License/Get-GitHubLicense.ps1
@@ -1,4 +1,4 @@
-#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' }
+#Requires -Modules @{ ModuleName = 'DynamicParams'; RequiredVersion = '1.1.8' }
filter Get-GitHubLicense {
<#
@@ -35,14 +35,18 @@ filter Get-GitHubLicense {
#>
[CmdletBinding(DefaultParameterSetName = 'List')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(ParameterSetName = 'Repository')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter(ParameterSetName = 'Repository')]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
dynamicparam {
@@ -61,17 +65,35 @@ filter Get-GitHubLicense {
return $DynamicParamDictionary
}
+ begin {
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+ }
+
process {
$Name = $PSBoundParameters['Name']
switch ($PSCmdlet.ParameterSetName) {
'List' {
- Get-GitHubLicenseList
+ Get-GitHubLicenseList -Context $Context
}
'Name' {
- Get-GitHubLicenseByName -Name $Name
+ Get-GitHubLicenseByName -Name $Name -Context $Context
}
'Repository' {
- Get-GitHubRepositoryLicense -Owner $Owner -Repo $Repo
+ Get-GitHubRepositoryLicense -Owner $Owner -Repo $Repo -Context $Context
}
}
}
diff --git a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1
index 38a8a2b8..9a71d9a3 100644
--- a/src/functions/public/Markdown/Get-GitHubMarkdown.ps1
+++ b/src/functions/public/Markdown/Get-GitHubMarkdown.ps1
@@ -4,7 +4,7 @@
[Render a Markdown document](https://docs.github.com/en/rest/markdown/markdown#render-a-markdown-document)
#>
[CmdletBinding()]
- param (
+ param(
[Parameter(
Mandatory,
ValueFromPipeline,
@@ -17,16 +17,21 @@
[string] $Mode,
[Parameter()]
- [string] $Context
+ [string] $RepoContext,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$body = @{
- context = $Context
+ context = $RepoContext
mode = $Mode
text = $Text
}
$inputObject = @{
+ Context = $Context
APIEndpoint = '/markdown'
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1 b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1
index 3fccb3a4..4a395f8d 100644
--- a/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1
+++ b/src/functions/public/Markdown/Get-GitHubMarkdownRaw.ps1
@@ -4,12 +4,17 @@
[Render a Markdown document in raw mode](https://docs.github.com/rest/reference/meta#github-api-root)
#>
[CmdletBinding()]
- param (
+ param(
[Parameter()]
- [string] $Text
+ [string] $Text,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = '/markdown/raw'
ContentType = 'text/plain'
Body = $Text
diff --git a/src/functions/public/Meta/Get-GitHubApiVersion.ps1 b/src/functions/public/Meta/Get-GitHubApiVersion.ps1
index 6d15a611..6ea0ee23 100644
--- a/src/functions/public/Meta/Get-GitHubApiVersion.ps1
+++ b/src/functions/public/Meta/Get-GitHubApiVersion.ps1
@@ -16,9 +16,14 @@
#>
[OutputType([string[]])]
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
$inputObject = @{
+ Context = $Context
ApiEndpoint = '/versions'
Method = 'GET'
}
diff --git a/src/functions/public/Meta/Get-GitHubMeta.ps1 b/src/functions/public/Meta/Get-GitHubMeta.ps1
index 2c55f3f9..1ad2fda3 100644
--- a/src/functions/public/Meta/Get-GitHubMeta.ps1
+++ b/src/functions/public/Meta/Get-GitHubMeta.ps1
@@ -24,9 +24,14 @@
#>
[OutputType([object])]
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
$inputObject = @{
+ Context = $Context
ApiEndpoint = '/meta'
Method = 'GET'
}
@@ -34,5 +39,4 @@
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
-
}
diff --git a/src/functions/public/Meta/Get-GitHubOctocat.ps1 b/src/functions/public/Meta/Get-GitHubOctocat.ps1
index a9b6f98c..928c67d3 100644
--- a/src/functions/public/Meta/Get-GitHubOctocat.ps1
+++ b/src/functions/public/Meta/Get-GitHubOctocat.ps1
@@ -21,12 +21,16 @@
#>
[OutputType([string])]
[CmdletBinding()]
- param (
+ param(
# The words to show in Octocat's speech bubble
[Parameter()]
[Alias('Say')]
[Alias('Saying')]
- [string] $S
+ [string] $S,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$body = @{
@@ -34,6 +38,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = '/octocat'
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Meta/Get-GitHubRoot.ps1 b/src/functions/public/Meta/Get-GitHubRoot.ps1
index 84b73cda..f67cb7a3 100644
--- a/src/functions/public/Meta/Get-GitHubRoot.ps1
+++ b/src/functions/public/Meta/Get-GitHubRoot.ps1
@@ -15,9 +15,14 @@
[GitHub API Root](https://docs.github.com/rest/meta/meta#github-api-root)
#>
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
$inputObject = @{
+ Context = $Context
APIEndpoint = '/'
Method = 'GET'
}
diff --git a/src/functions/public/Meta/Get-GitHubZen.ps1 b/src/functions/public/Meta/Get-GitHubZen.ps1
index 61366fa9..5e85146e 100644
--- a/src/functions/public/Meta/Get-GitHubZen.ps1
+++ b/src/functions/public/Meta/Get-GitHubZen.ps1
@@ -15,9 +15,14 @@
[Get the Zen of GitHub](https://docs.github.com/rest/meta/meta#get-the-zen-of-github)
#>
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
$inputObject = @{
+ Context = $Context
APIEndpoint = '/zen'
Method = 'GET'
}
@@ -25,5 +30,4 @@
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
-
}
diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1
index 52a85b79..3c2498cf 100644
--- a/src/functions/public/Organization/Get-GitHubOrganization.ps1
+++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1
@@ -35,7 +35,7 @@
[OutputType([pscustomobject])]
[CmdletBinding(DefaultParameterSetName = '__DefaultSet')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'All', Justification = 'Required for parameter set')]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -71,21 +71,25 @@
[Parameter(ParameterSetName = 'UserOrg')]
[Parameter(ParameterSetName = '__DefaultSet')]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
switch ($PSCmdlet.ParameterSetName) {
'__DefaultSet' {
- Get-GitHubMyOrganization -PerPage $PerPage | Get-GitHubOrganizationByName
+ Get-GitHubMyOrganization -PerPage $PerPage -Context $Context | Get-GitHubOrganizationByName -Context $Context
}
'NamedOrg' {
- Get-GitHubOrganizationByName -OrganizationName $OrganizationName
+ Get-GitHubOrganizationByName -OrganizationName $OrganizationName -Context $Context
}
'NamedUser' {
- Get-GitHubUserOrganization -Username $Username
+ Get-GitHubUserOrganization -Username $Username -Context $Context
}
'AllOrg' {
- Get-GitHubAllOrganization -Since $Since -PerPage $PerPage
+ Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context
}
}
}
diff --git a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1 b/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1
index fc43e9ed..bb939219 100644
--- a/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1
+++ b/src/functions/public/Organization/Get-GitHubOrganizationAppInstallation.ps1
@@ -18,7 +18,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -33,7 +33,11 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$body = @{
@@ -41,6 +45,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName/installations"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1
index b6eae6ba..5eea5d2b 100644
--- a/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1
+++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationMember.ps1
@@ -12,7 +12,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('Org')]
diff --git a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1 b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1
index 3f066590..770b853c 100644
--- a/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1
+++ b/src/functions/public/Organization/Members/Get-GitHubOrganizationPendingInvitation.ps1
@@ -13,7 +13,7 @@
[List pending organization invitations](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations)
#>
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('Org')]
diff --git a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1 b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1
index fa21f5c1..daaff737 100644
--- a/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1
+++ b/src/functions/public/Organization/Members/New-GitHubOrganizationInvitation.ps1
@@ -16,7 +16,7 @@
[Create an organization invitation](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('Org')]
diff --git a/src/functions/public/Organization/Remove-GitHubOrganization.ps1 b/src/functions/public/Organization/Remove-GitHubOrganization.ps1
index 76359e8f..6430f0c5 100644
--- a/src/functions/public/Organization/Remove-GitHubOrganization.ps1
+++ b/src/functions/public/Organization/Remove-GitHubOrganization.ps1
@@ -19,7 +19,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -29,10 +29,15 @@
[Alias('org')]
[Alias('owner')]
[Alias('login')]
- [string] $OrganizationName
+ [string] $OrganizationName,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName"
Method = 'DELETE'
}
diff --git a/src/functions/public/Organization/Set-GitHubOrganization.ps1 b/src/functions/public/Organization/Set-GitHubOrganization.ps1
index 44c5c455..3c2efc0c 100644
--- a/src/functions/public/Organization/Set-GitHubOrganization.ps1
+++ b/src/functions/public/Organization/Set-GitHubOrganization.ps1
@@ -36,7 +36,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
@@ -215,13 +215,18 @@
# are blocked from pushing a secret.
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('secret_scanning_push_protection_custom_link')]
- [string] $SecretScanningPushProtectionCustomLink
+ [string] $SecretScanningPushProtectionCustomLink,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntry -Hashtable $body -RemoveNames 'organization_name'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName"
Method = 'PATCH'
Body = $body
diff --git a/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1 b/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1
index c7bbf94b..a9b9a3c1 100644
--- a/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1
+++ b/src/functions/public/Organization/Set-GitHubOrganizationSecurityFeature.ps1
@@ -24,7 +24,7 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long link in notes.')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('org')]
@@ -66,7 +66,11 @@
'default',
'extended'
)]
- [string] $QuerySuite
+ [string] $QuerySuite,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$body = @{
@@ -74,6 +78,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/orgs/$OrganizationName/$SecurityProduct/$Enablement"
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1 b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1
index 0d1339d1..286fd980 100644
--- a/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1
+++ b/src/functions/public/Rate-Limit/Get-GitHubRateLimit.ps1
@@ -33,9 +33,14 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
- param ()
+ param(
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
+ )
$inputObject = @{
+ Context = $Context
APIEndpoint = '/rate_limit'
Method = 'GET'
}
diff --git a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1
index f2086ee5..389a5026 100644
--- a/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Add-GitHubReleaseAsset.ps1
@@ -46,14 +46,14 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the release.
[Parameter(Mandatory)]
@@ -75,9 +75,29 @@
# The path to the asset file.
[Parameter(Mandatory)]
[alias('fullname')]
- [string] $FilePath
+ [string] $FilePath,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
# If name is not provided, use the name of the file
if (!$Name) {
$Name = (Get-Item $FilePath).Name
diff --git a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1
index 90bb38cf..4fc35ef0 100644
--- a/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Get-GitHubReleaseAsset.ps1
@@ -22,14 +22,14 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the asset.
[Parameter(
@@ -45,14 +45,34 @@
ParameterSetName = 'ReleaseID'
)]
[Alias('release_id')]
- [string] $ReleaseID
+ [string] $ReleaseID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
if ($ReleaseID) {
- Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repo $Repo -ReleaseID $ReleaseID
+ Get-GitHubReleaseAssetByReleaseID -Owner $Owner -Repo $Repo -ReleaseID $ReleaseID -Context $Context
}
if ($ID) {
- Get-GitHubReleaseAssetByID -Owner $Owner -Repo $Repo -ID $ID
+ Get-GitHubReleaseAssetByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context
}
}
diff --git a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1
index 75bbcf0e..007c3081 100644
--- a/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1
@@ -16,22 +16,43 @@
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the asset.
[Parameter(Mandatory)]
[Alias('asset_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
Method = 'DELETE'
}
diff --git a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1 b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1
index 3bfb3c3b..419413d5 100644
--- a/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1
+++ b/src/functions/public/Releases/Assets/Set-GitHubReleaseAsset.ps1
@@ -16,14 +16,14 @@
[Update a release asset](https://docs.github.com/rest/releases/assets#update-a-release-asset)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the asset.
[Parameter(Mandatory)]
@@ -41,14 +41,34 @@
# State of the release asset.
[Parameter()]
[ValidateSet('uploaded', 'open')]
- [string] $State
+ [string] $State,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo', 'ID'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/assets/$ID"
Method = 'PATCH'
Body = $requestBody
@@ -59,5 +79,4 @@
Write-Output $_.Response
}
}
-
}
diff --git a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1
index 038070ed..fb2de26e 100644
--- a/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/Get-GitHubRelease.ps1
@@ -35,14 +35,14 @@
#>
[CmdletBinding(DefaultParameterSetName = 'All')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'Latest', Justification = 'Required for parameter set')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The number of results per page (max 100).
[Parameter(ParameterSetName = 'All')]
@@ -70,14 +70,42 @@
ParameterSetName = 'ID'
)]
[Alias('release_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
switch ($PSCmdlet.ParameterSetName) {
- 'All' { Get-GitHubReleaseAll -Owner $Owner -Repo $Repo -PerPage $PerPage }
- 'Latest' { Get-GitHubReleaseLatest -Owner $Owner -Repo $Repo }
- 'Tag' { Get-GitHubReleaseByTagName -Owner $Owner -Repo $Repo -Tag $Tag }
- 'ID' { Get-GitHubReleaseByID -Owner $Owner -Repo $Repo -ID $ID }
+ 'All' {
+ Get-GitHubReleaseAll -Owner $Owner -Repo $Repo -PerPage $PerPage -Context $Context
+ }
+ 'Latest' {
+ Get-GitHubReleaseLatest -Owner $Owner -Repo $Repo -Context $Context
+ }
+ 'Tag' {
+ Get-GitHubReleaseByTagName -Owner $Owner -Repo $Repo -Tag $Tag -Context $Context
+ }
+ 'ID' {
+ Get-GitHubReleaseByID -Owner $Owner -Repo $Repo -ID $ID -Context $Context
+ }
}
}
diff --git a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1
index a3523734..3f4aabaa 100644
--- a/src/functions/public/Releases/Releases/New-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/New-GitHubRelease.ps1
@@ -22,14 +22,14 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The name of the tag.
[Parameter(Mandatory)]
@@ -75,9 +75,29 @@
[Parameter()]
[Alias('make_latest')]
[ValidateSet('true', 'false', 'legacy')]
- [string] $MakeLatest = 'true'
+ [string] $MakeLatest = 'true',
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$requestBody = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntry -Hashtable $requestBody -RemoveNames 'Owner', 'Repo', 'GenerateReleaseNotes', 'Draft', 'Prerelease'
$requestBody = Join-Object -AsHashtable -Main $requestBody -Overrides @{
@@ -88,6 +108,7 @@
Remove-HashtableEntry -Hashtable $requestBody -NullOrEmptyValues
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases"
Method = 'POST'
Body = $requestBody
@@ -98,5 +119,4 @@
Write-Output $_.Response
}
}
-
}
diff --git a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1 b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1
index 07e64114..6c5cfb2d 100644
--- a/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1
+++ b/src/functions/public/Releases/Releases/New-GitHubReleaseNote.ps1
@@ -56,14 +56,14 @@
[Alias('Generate-GitHubReleaseNotes')]
[Alias('New-GitHubReleaseNotes')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The tag name for the release. This can be an existing tag or a new one.
[Parameter(Mandatory)]
@@ -89,10 +89,29 @@
# If that is not present, the default configuration will be used.
[Parameter()]
[Alias('configuration_file_path')]
- [string] $ConfigurationFilePath
+ [string] $ConfigurationFilePath,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo'
@@ -107,5 +126,4 @@
Write-Output $_.Response
}
}
-
}
diff --git a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1
index 6a29a900..feb1f0e3 100644
--- a/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/Remove-GitHubRelease.ps1
@@ -17,24 +17,45 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the release.
[Parameter(
Mandatory
)]
[Alias('release_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
Method = 'DELETE'
}
diff --git a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1 b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1
index 2993b6f0..190f065b 100644
--- a/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1
+++ b/src/functions/public/Releases/Releases/Set-GitHubRelease.ps1
@@ -17,14 +17,14 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the release.
[Parameter(Mandatory)]
@@ -72,9 +72,29 @@
[Parameter()]
[Alias('make_latest')]
[ValidateSet('true', 'false', 'legacy')]
- [string] $MakeLatest = 'true'
+ [string] $MakeLatest = 'true',
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$requestBody = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntry -Hashtable $requestBody -RemoveNames 'Owner', 'Repo', 'Draft', 'Prerelease'
$requestBody = Join-Object -AsHashtable -Main $requestBody -Overrides @{
@@ -83,6 +103,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/releases/$ID"
Method = 'PATCH'
Body = $requestBody
@@ -93,5 +114,4 @@
Write-Output $_.Response
}
}
-
}
diff --git a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1
index d9c43dd2..82123da7 100644
--- a/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1
+++ b/src/functions/public/Repositories/Autolinks/Get-GitHubRepositoryAutolink.ps1
@@ -24,15 +24,15 @@
#>
[Alias('Get-GitHubRepositoryAutolinks')]
[CmdletBinding(DefaultParameterSetName = 'Default')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the autolink.
[Parameter(
@@ -41,15 +41,35 @@
)]
[Alias('autolink_id')]
[Alias('ID')]
- [int] $AutolinkId
+ [int] $AutolinkId,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
switch ($PSCmdlet.ParameterSetName) {
'ById' {
- Get-GitHubRepositoryAutolinkById -Owner $Owner -Repo $Repo -ID $AutolinkId
+ Get-GitHubRepositoryAutolinkById -Owner $Owner -Repo $Repo -ID $AutolinkId -Context $Context
}
default {
- Get-GitHubRepositoryAutolinkList -Owner $Owner -Repo $Repo
+ Get-GitHubRepositoryAutolinkList -Owner $Owner -Repo $Repo -Context $Context
}
}
}
diff --git a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1
index e48a91dc..06e27dab 100644
--- a/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1
+++ b/src/functions/public/Repositories/Autolinks/New-GitHubRepositoryAutolink.ps1
@@ -18,7 +18,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(Mandatory)]
[string] $Owner,
@@ -41,9 +41,29 @@
# characters A-Z (case insensitive), 0-9, and -. If false, this autolink reference only matches numeric characters.
[Parameter()]
[Alias('is_alphanumeric')]
- [bool] $IsAlphanumeric = $true
+ [bool] $IsAlphanumeric = $true,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
$paramName = $_.Key
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
@@ -63,6 +83,7 @@
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/autolinks"
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1 b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1
index ef7b62e2..0d9436a8 100644
--- a/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1
+++ b/src/functions/public/Repositories/Autolinks/Remove-GitHubRepositoryAutolink.ps1
@@ -19,7 +19,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(Mandatory)]
[string] $Owner,
@@ -32,10 +32,31 @@
[Parameter(Mandatory)]
[Alias('autolink_id')]
[Alias('ID')]
- [int] $AutolinkId
+ [int] $AutolinkId,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/autolinks/$AutolinkId"
Method = 'DELETE'
Body = $body
diff --git a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1 b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1
index 7dff0bc0..3999107b 100644
--- a/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1
+++ b/src/functions/public/Repositories/CustomProperties/Get-GitHubRepositoryCustomProperty.ps1
@@ -20,18 +20,39 @@
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[OutputType([pscustomobject])]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/properties/values"
Method = 'GET'
}
diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
index 580c24b4..8cb480f9 100644
--- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
+++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
@@ -19,18 +19,39 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting"
Method = 'DELETE'
}
diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1
index cd6158d9..8d6b36be 100644
--- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1
+++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositorySecurityFix.ps1
@@ -19,18 +19,39 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[Alias('Disable-GitHubRepositorySecurityFixes')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
Method = 'DELETE'
}
diff --git a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1
index 0b9eb8af..d6c53c3b 100644
--- a/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1
+++ b/src/functions/public/Repositories/Repositories/Disable-GitHubRepositoryVulnerabilityAlert.ps1
@@ -18,18 +18,39 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[Alias('Disable-GitHubRepositoryVulnerabilityAlerts')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
Method = 'DELETE'
}
diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
index 0889ca16..822f8b3a 100644
--- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
+++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryPrivateVulnerabilityReporting.ps1
@@ -19,18 +19,39 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/private-vulnerability-reporting"
Method = 'PUT'
}
diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1
index 66b608b7..aaa759be 100644
--- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1
+++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositorySecurityFix.ps1
@@ -19,18 +19,39 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[Alias('Enable-GitHubRepositorySecurityFixes')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
Method = 'PUT'
}
diff --git a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1
index 34853a65..cf9bd202 100644
--- a/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1
+++ b/src/functions/public/Repositories/Repositories/Enable-GitHubRepositoryVulnerabilityAlert.ps1
@@ -19,18 +19,39 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[Alias('Enable-GitHubRepositoryVulnerabilityAlerts')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
Method = 'PUT'
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1
index 26ff6395..1d11baac 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepository.ps1
@@ -49,7 +49,7 @@ filter Get-GitHubRepository {
[List repositories for a user](https://docs.github.com/rest/repos/repos#list-repositories-for-a-user)
#>
[CmdletBinding(DefaultParameterSetName = 'MyRepos_Type')]
- param (
+ param(
#Limit results to repositories with the specified visibility.
[Parameter(ParameterSetName = 'MyRepos_Aff-Vis')]
[ValidateSet('all', 'public', 'private')]
@@ -82,14 +82,14 @@ filter Get-GitHubRepository {
# The account owner of the repository. The name is not case sensitive.
[Parameter(ParameterSetName = 'ByName')]
[Parameter(ParameterSetName = 'ListByOrg')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter(
Mandatory,
ParameterSetName = 'ByName'
)]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The handle for the GitHub user account.
[Parameter(
@@ -122,8 +122,11 @@ filter Get-GitHubRepository {
[Parameter(ParameterSetName = 'ListByOrg')]
[Parameter(ParameterSetName = 'ListByUser')]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
dynamicparam {
@@ -159,12 +162,31 @@ filter Get-GitHubRepository {
begin {
$Type = $PSBoundParameters['Type']
+
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
}
process {
+ $params = @{
+ Context = $Context
+ }
switch ($PSCmdlet.ParameterSetName) {
'MyRepos_Type' {
- $params = @{
+ $params += @{
Type = $Type
Sort = $Sort
Direction = $Direction
@@ -176,7 +198,7 @@ filter Get-GitHubRepository {
Get-GitHubMyRepositories @params
}
'MyRepos_Aff-Vis' {
- $params = @{
+ $params += @{
Visibility = $Visibility
Affiliation = $Affiliation
Sort = $Sort
@@ -189,7 +211,7 @@ filter Get-GitHubRepository {
Get-GitHubMyRepositories @params
}
'ByName' {
- $params = @{
+ $params += @{
Owner = $Owner
Repo = $Repo
}
@@ -197,14 +219,14 @@ filter Get-GitHubRepository {
Get-GitHubRepositoryByName @params
}
'ListByID' {
- $params = @{
+ $params += @{
Since = $SinceID
}
Remove-HashtableEntry -Hashtable $params -NullOrEmptyValues
Get-GitHubRepositoryListByID @params
}
'ListByOrg' {
- $params = @{
+ $params += @{
Owner = $Owner
Type = $Type
Sort = $Sort
@@ -215,7 +237,7 @@ filter Get-GitHubRepository {
Get-GitHubRepositoryListByOrg @params
}
'ListByUser' {
- $params = @{
+ $params += @{
Username = $Username
Type = $Type
Sort = $Sort
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1
index 690710b7..be051d26 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1
@@ -50,15 +50,15 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The direction to sort the results by.
[Parameter()]
@@ -102,9 +102,29 @@
[Parameter()]
[ValidateSet('push', 'force_push', 'branch_creation', 'branch_deletion', 'pr_merge', 'merge_queue_merge')]
[Alias('activity_type')]
- [string] $ActivityType
+ [string] $ActivityType,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
$paramName = $_.Key
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
@@ -124,6 +144,7 @@
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/activity"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1
index 9d3fff27..0045ee06 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryCodeownersError.ps1
@@ -20,22 +20,42 @@
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# A branch, tag or commit name used to determine which version of the CODEOWNERS file to use.
# Default: the repository's default branch (e.g. main)
[Parameter()]
- [string] $Ref
+ [string] $Ref,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
$paramName = $_.Key
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
@@ -55,6 +75,7 @@
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/codeowners/errors"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1
index 7e647783..51990e10 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryContributor.ps1
@@ -21,15 +21,15 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# Wether to include anonymous contributors in results.
[Parameter()]
@@ -38,13 +38,34 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/contributors"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1
index 35f2a267..4070890d 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryFork.ps1
@@ -16,15 +16,15 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The direction to sort the results by.
[Parameter()]
@@ -35,9 +35,29 @@
[Parameter()]
[ValidateRange(1, 100)]
[Alias('per_page')]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
$paramName = $_.Key
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
@@ -57,6 +77,7 @@
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/forks"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1
index ee26ec37..1a7e5236 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryLanguage.ps1
@@ -18,18 +18,39 @@
#>
[CmdletBinding()]
[Alias('Get-GitHubRepositoryLanguages')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/languages"
Method = 'GET'
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1
index 78005111..65a0b886 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositorySecurityFix.ps1
@@ -20,18 +20,39 @@
[Alias('Get-GitHubRepoSecurityFixes')]
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/automated-security-fixes"
Method = 'GET'
}
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1
index 264f51b3..4bb24411 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTag.ps1
@@ -17,26 +17,48 @@
#>
[CmdletBinding()]
[Alias('Get-GitHubRepositoryTags')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/tags"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1
index 1b0d53e8..1566894b 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTeam.ps1
@@ -25,26 +25,48 @@
#>
[CmdletBinding()]
[Alias('Get-GitHubRepositoryTeams')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/teams"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1
index 86139402..60180df9 100644
--- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1
+++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryTopic.ps1
@@ -13,26 +13,48 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
+ $body = @{
+ per_page = $PerPage
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/topics"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1
index bbd1cf1c..0aae8a88 100644
--- a/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Move-GitHubRepository.ps1
@@ -21,15 +21,15 @@
#>
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The username or organization name the repository will be transferred to.
[Parameter(Mandatory)]
@@ -44,9 +44,29 @@
# ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories.
[Parameter()]
[Alias('team_ids')]
- [int[]] $TeamIds
+ [int[]] $TeamIds,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
$paramName = $_.Key
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
@@ -66,6 +86,7 @@
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/transfer"
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1
index 1f9e16f6..000f7e28 100644
--- a/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/New-GitHubRepository.ps1
@@ -108,12 +108,12 @@ filter New-GitHubRepository {
SupportsShouldProcess,
DefaultParameterSetName = 'user'
)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(ParameterSetName = 'org')]
[Parameter(ParameterSetName = 'fork')]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository.
[Parameter(ParameterSetName = 'fork')]
@@ -323,6 +323,18 @@ filter New-GitHubRepository {
}
begin {
+
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
$GitignoreTemplate = $PSBoundParameters['GitignoreTemplate']
$LicenseTemplate = $PSBoundParameters['LicenseTemplate']
}
@@ -330,6 +342,7 @@ filter New-GitHubRepository {
process {
if ($PSCmdlet.ParameterSetName -in 'user', 'org') {
$params = @{
+ Context = $Context
Owner = $Owner
Name = $Name
Description = $Description
@@ -372,6 +385,7 @@ filter New-GitHubRepository {
'template' {
if ($PSCmdlet.ShouldProcess("repository [$Owner/$Name] from template [$TemplateOwner/$TemplateRepo]", 'Create')) {
$params = @{
+ Context = $Context
TemplateOwner = $TemplateOwner
TemplateRepo = $TemplateRepo
Owner = $Owner
@@ -390,6 +404,7 @@ filter New-GitHubRepository {
}
if ($PSCmdlet.ShouldProcess("repository [$Owner/$Name] as fork from [$ForkOwner/$ForkRepo]", 'Create')) {
$params = @{
+ Context = $Context
Owner = $ForkOwner
Repo = $ForkRepo
Organization = $Owner
diff --git a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1
index 6c170861..bff41ed0 100644
--- a/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Remove-GitHubRepository.ps1
@@ -18,7 +18,7 @@
[Delete a repository](https://docs.github.com/rest/repos/repos#delete-a-repository)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('org')]
@@ -27,10 +27,15 @@
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter(Mandatory)]
- [string] $Repo
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo"
Method = 'DELETE'
}
@@ -40,5 +45,4 @@
Write-Output $_.Response
}
}
-
}
diff --git a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1 b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1
index 84321e3c..e987ebcf 100644
--- a/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1
+++ b/src/functions/public/Repositories/Repositories/Set-GitHubRepositoryTopic.ps1
@@ -15,28 +15,48 @@
[Replace all repository topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The number of results per page (max 100).
[Parameter()]
[Alias('Topics')]
- [string[]] $Names = @()
+ [string[]] $Names = @(),
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
- Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
- $body.names = $body.names | ForEach-Object { $_.ToLower() }
+ $body = @{
+ names = $Names | ForEach-Object { $_.ToLower() }
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/topics"
Method = 'PUT'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1 b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1
index 1351cf4e..cc8574e0 100644
--- a/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1
+++ b/src/functions/public/Repositories/Repositories/Start-GitHubRepositoryEvent.ps1
@@ -42,15 +42,15 @@
#>
[CmdletBinding(SupportsShouldProcess)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# A custom webhook event name. Must be 100 characters or fewer.
[Parameter(Mandatory)]
@@ -61,9 +61,29 @@
# The maximum number of top-level properties is 10.
[Parameter()]
[Alias('client_payload')]
- [object] $ClientPayload
+ [object] $ClientPayload,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
$paramName = $_.Key
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
@@ -83,6 +103,7 @@
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/dispatches"
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1 b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1
index dfb8ace3..341eaf7d 100644
--- a/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1
+++ b/src/functions/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1
@@ -20,18 +20,39 @@
[OutputType([bool])]
[CmdletBinding()]
[Alias('Test-GitHubRepositoryVulnerabilityAlerts')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts"
Method = 'GET'
}
diff --git a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1 b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1
index 5df97140..1c87bd49 100644
--- a/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1
+++ b/src/functions/public/Repositories/Repositories/Update-GitHubRepository.ps1
@@ -24,15 +24,15 @@
[Update a repository](https://docs.github.com/rest/repos/repos#update-a-repository)
#>
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The name of the repository.
[Parameter()]
@@ -169,9 +169,29 @@
# or false to not require contributors to sign off on web-based commits.
[Parameter()]
[Alias('web_commit_signoff_required')]
- [switch] $WebCommitSignoffRequired
+ [switch] $WebCommitSignoffRequired,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$body = @{
name = $Name
description = $Description
@@ -217,6 +237,7 @@
Remove-HashtableEntry -Hashtable $body -NullOrEmptyValues
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo"
Method = 'PATCH'
Body = $body
diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1
index b9bd1f72..80a72b6a 100644
--- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1
+++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuite.ps1
@@ -33,15 +33,15 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
[CmdletBinding(DefaultParameterSetName = 'Default')]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The name of the ref. Cannot contain wildcard characters.
# When specified, only rule evaluations triggered for this ref will be returned.
@@ -74,14 +74,38 @@
Mandatory,
ParameterSetName = 'ById'
)]
- [int] $RuleSuiteId
+ [int] $RuleSuiteId,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
+ $params = @{
+ Context = $Context
+ Owner = $Owner
+ Repo = $Repo
+ }
+
switch ($PSCmdlet.ParameterSetName) {
'Default' {
- $params = @{
- Owner = $Owner
- Repo = $Repo
+ $params += @{
Ref = $Ref
TimePeriod = $TimePeriod
ActorName = $ActorName
@@ -91,9 +115,7 @@
Get-GitHubRepositoryRuleSuiteList @params
}
'ById' {
- $params = @{
- Owner = $Owner
- Repo = $Repo
+ $params += @{
RuleSuiteId = $RuleSuiteId
}
Get-GitHubRepositoryRuleSuiteById @params
diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1
index 2e7e0830..c127ec53 100644
--- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1
+++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteById.ps1
@@ -18,23 +18,43 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the rule suite result. To get this ID, you can use GET /repos/ { owner }/ { repo }/rulesets/rule-suites for repositories and GET /orgs/ { org }/rulesets/rule-suites for organizations.
[Parameter(Mandatory)]
- [int] $RuleSuiteId
+ [int] $RuleSuiteId,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites/$RuleSuiteId"
Method = 'GET'
}
diff --git a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1 b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1
index 1168ce9c..dbad5568 100644
--- a/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1
+++ b/src/functions/public/Repositories/RuleSuite/Get-GitHubRepositoryRuleSuiteList.ps1
@@ -27,15 +27,15 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The name of the ref. Cannot contain wildcard characters.
# When specified, only rule evaluations triggered for this ref will be returned.
@@ -61,9 +61,29 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$PSCmdlet.MyInvocation.MyCommand.Parameters.GetEnumerator() | ForEach-Object {
$paramName = $_.Key
$paramDefaultValue = Get-Variable -Name $paramName -ValueOnly -ErrorAction SilentlyContinue
@@ -82,8 +102,8 @@
$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
Remove-HashtableEntry -Hashtable $body -RemoveNames 'Owner', 'Repo' -RemoveTypes 'SwitchParameter'
-
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/rulesets/rule-suites"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1
index ad089c4a..70d4ad1a 100644
--- a/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1
+++ b/src/functions/public/Repositories/Tags/Get-GitHubRepositoryTagProtection.ps1
@@ -19,18 +19,39 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/tags/protection"
Method = 'GET'
}
diff --git a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1
index df107bb7..1daf0c8d 100644
--- a/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1
+++ b/src/functions/public/Repositories/Tags/New-GitHubRepositoryTagProtection.ps1
@@ -17,24 +17,47 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# An optional glob pattern to match against when enforcing tag protection.
[Parameter(Mandatory)]
- [string] $Pattern
+ [string] $Pattern,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body['pattern'] = $Pattern
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
+ $body = @{
+ pattern = $Pattern
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/tags/protection"
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1 b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1
index 414af87f..dc555bf9 100644
--- a/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1
+++ b/src/functions/public/Repositories/Tags/Remove-GitHubRepositoryTagProtection.ps1
@@ -18,22 +18,43 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The account owner of the repository. The name is not case sensitive.
[Parameter()]
[Alias('org')]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo),
+ [string] $Repo,
# The unique identifier of the tag protection.
[Parameter(Mandatory)]
- [int] $TagProtectionId
+ [int] $TagProtectionId,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/tags/protection/$TagProtectionId"
Method = 'DELETE'
}
diff --git a/src/functions/public/Teams/Get-GitHubRepoTeam.ps1 b/src/functions/public/Teams/Get-GitHubRepoTeam.ps1
index b827a812..12e17d53 100644
--- a/src/functions/public/Teams/Get-GitHubRepoTeam.ps1
+++ b/src/functions/public/Teams/Get-GitHubRepoTeam.ps1
@@ -1,20 +1,41 @@
-filter Get-GitHubRepoTeam {
+filter Get-GitHubRepoTeam {
<#
.NOTES
[List repository teams](https://docs.github.com/rest/reference/repos#get-a-repository)
#>
[CmdletBinding()]
- param (
+ param(
[Parameter()]
- [string] $Owner = (Get-GitHubContextSetting -Name Owner),
+ [string] $Owner,
[Parameter()]
- [string] $Repo = (Get-GitHubContextSetting -Name Repo)
+ [string] $Repo,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
+ if ([string]::IsNullOrEmpty($Repo)) {
+ $Repo = $contextObj.Repo
+ }
+ Write-Debug "Repo : [$($contextObj.Repo)]"
+
$inputObject = @{
- Method = 'Get'
+ Context = $Context
APIEndpoint = "/repos/$Owner/$Repo/teams"
+ Method = 'Get'
}
Invoke-GitHubAPI @inputObject | ForEach-Object {
diff --git a/src/functions/public/Teams/Get-GitHubTeamByName.ps1 b/src/functions/public/Teams/Get-GitHubTeamByName.ps1
index 39e87bfa..fa25a33c 100644
--- a/src/functions/public/Teams/Get-GitHubTeamByName.ps1
+++ b/src/functions/public/Teams/Get-GitHubTeamByName.ps1
@@ -15,7 +15,7 @@
#>
[OutputType([void])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('Org')]
@@ -31,10 +31,21 @@
[string] $Context = (Get-GitHubConfig -Name DefaultContext)
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
$inputObject = @{
Context = $Context
- Method = 'Get'
APIEndpoint = "/orgs/$Organization/teams/$Name"
+ Method = 'Get'
}
Invoke-GitHubAPI @inputObject | ForEach-Object {
diff --git a/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1 b/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1
index d3fa493a..41510bbc 100644
--- a/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1
+++ b/src/functions/public/Teams/Get-GitHubTeamListByOrg.ps1
@@ -14,7 +14,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('Org')]
@@ -25,10 +25,21 @@
[string] $Context = (Get-GitHubConfig -Name DefaultContext)
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
$inputObject = @{
Context = $Context
- Method = 'Get'
APIEndpoint = "/orgs/$Organization/teams"
+ Method = 'Get'
}
Invoke-GitHubAPI @inputObject | ForEach-Object {
diff --git a/src/functions/public/Teams/New-GitHubTeam.ps1 b/src/functions/public/Teams/New-GitHubTeam.ps1
index 1090f065..866b585f 100644
--- a/src/functions/public/Teams/New-GitHubTeam.ps1
+++ b/src/functions/public/Teams/New-GitHubTeam.ps1
@@ -84,6 +84,17 @@
[string] $Context = (Get-GitHubConfig -Name DefaultContext)
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
$body = @{
name = $Name
description = $Description
@@ -94,14 +105,13 @@
permission = $Permission
parent_team_id = $ParentTeamID -eq 0 ? $null : $ParentTeamID
}
-
$body | Remove-HashtableEntry -NullOrEmptyValues
$inputObject = @{
Context = $Context
+ APIEndpoint = "/orgs/$Organization/teams"
Method = 'POST'
Body = $body
- APIEndpoint = "/orgs/$Organization/teams"
}
if ($PSCmdlet.ShouldProcess("'$Name' in '$Organization'", 'Create team')) {
diff --git a/src/functions/public/Teams/Remove-GitHubTeam.ps1 b/src/functions/public/Teams/Remove-GitHubTeam.ps1
index 49ddc5ca..3b6c8e44 100644
--- a/src/functions/public/Teams/Remove-GitHubTeam.ps1
+++ b/src/functions/public/Teams/Remove-GitHubTeam.ps1
@@ -15,7 +15,7 @@
#>
[OutputType([void])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('Org')]
@@ -31,6 +31,17 @@
[string] $Context = (Get-GitHubConfig -Name DefaultContext)
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
$inputObject = @{
Context = $Context
Method = 'Delete'
diff --git a/src/functions/public/Teams/Update-GitHubTeam.ps1 b/src/functions/public/Teams/Update-GitHubTeam.ps1
index 7a9d1d17..54373eed 100644
--- a/src/functions/public/Teams/Update-GitHubTeam.ps1
+++ b/src/functions/public/Teams/Update-GitHubTeam.ps1
@@ -24,7 +24,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(Mandatory)]
[Alias('Org')]
@@ -78,6 +78,17 @@
[string] $Context = (Get-GitHubConfig -Name DefaultContext)
)
+ $contextObj = Get-GitHubContext -Context $Context
+ if (-not $contextObj) {
+ throw 'Log in using Connect-GitHub before running this command.'
+ }
+ Write-Debug "Context: [$Context]"
+
+ if ([string]::IsNullOrEmpty($Owner)) {
+ $Owner = $contextObj.Owner
+ }
+ Write-Debug "Owner : [$($contextObj.Owner)]"
+
$body = @{
name = $NewName
description = $Description
@@ -86,13 +97,12 @@
permission = $Permission
parent_team_id = $ParentTeamID
}
-
$body | Remove-HashtableEntry -NullOrEmptyValues
$inputObject = @{
Context = $Context
- Method = 'Patch'
APIEndpoint = "/orgs/$Organization/teams/$Name"
+ Method = 'Patch'
Body = $body
}
diff --git a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1
index e7f2b696..0b6a6625 100644
--- a/src/functions/public/Users/Blocking/Block-GitHubUser.ps1
+++ b/src/functions/public/Users/Blocking/Block-GitHubUser.ps1
@@ -25,7 +25,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -42,13 +42,16 @@
)]
[Alias('org')]
[Alias('owner')]
- [string] $OrganizationName
+ [string] $OrganizationName,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($OrganizationName) {
- Block-GitHubUserByOrganization -OrganizationName $OrganizationName -Username $Username
+ Block-GitHubUserByOrganization -OrganizationName $OrganizationName -Username $Username -Context $Context
} else {
- Block-GitHubUserByUser -Username $Username
+ Block-GitHubUserByUser -Username $Username -Context $Context
}
-
}
diff --git a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1
index 9f4da98f..26105167 100644
--- a/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1
+++ b/src/functions/public/Users/Blocking/Get-GitHubBlockedUser.ps1
@@ -22,7 +22,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The organization name. The name is not case sensitive.
[Parameter(
ValueFromPipeline,
@@ -36,13 +36,17 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($OrganizationName) {
- Get-GitHubBlockedUserByOrganization -OrganizationName $OrganizationName -PerPage $PerPage
+ Get-GitHubBlockedUserByOrganization -OrganizationName $OrganizationName -PerPage $PerPage -Context $Context
} else {
- Get-GitHubBlockedUserByUser -PerPage $PerPage
+ Get-GitHubBlockedUserByUser -PerPage $PerPage -Context $Context
}
}
diff --git a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1 b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1
index 3577f405..1f1d43ee 100644
--- a/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1
+++ b/src/functions/public/Users/Blocking/Test-GitHubBlockedUser.ps1
@@ -26,7 +26,7 @@
[OutputType([bool])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -48,13 +48,17 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($OrganizationName) {
- Test-GitHubBlockedUserByOrganization -OrganizationName $OrganizationName -Username $Username -PerPage $PerPage
+ Test-GitHubBlockedUserByOrganization -OrganizationName $OrganizationName -Username $Username -PerPage $PerPage -Context $Context
} else {
- Test-GitHubBlockedUserByUser -Username $Username -PerPage $PerPage
+ Test-GitHubBlockedUserByUser -Username $Username -PerPage $PerPage -Context $Context
}
}
diff --git a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1 b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1
index 6b132aa1..09799310 100644
--- a/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1
+++ b/src/functions/public/Users/Blocking/Unblock-GitHubUser.ps1
@@ -24,7 +24,7 @@
#>
[OutputType([bool])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -41,12 +41,16 @@
)]
[Alias('org')]
[Alias('owner')]
- [string] $OrganizationName
+ [string] $OrganizationName,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($OrganizationName) {
- Unblock-GitHubUserByOrganization -OrganizationName $OrganizationName -Username $Username
+ Unblock-GitHubUserByOrganization -OrganizationName $OrganizationName -Username $Username -Context $Context
} else {
- Unblock-GitHubUserByUser -Username $Username
+ Unblock-GitHubUserByUser -Username $Username -Context $Context
}
}
diff --git a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1
index 633e717e..0532b38f 100644
--- a/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1
+++ b/src/functions/public/Users/Emails/Add-GitHubUserEmail.ps1
@@ -17,7 +17,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# Adds one or more email addresses to your GitHub account.
# Must contain at least one email address.
# Note: Alternatively, you can pass a single email address or an array of emails addresses directly,
@@ -27,12 +27,19 @@
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
- [string[]] $Emails
+ [string[]] $Emails,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ emails = $Emails
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/emails'
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1
index 118d09e6..c3ab6272 100644
--- a/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1
+++ b/src/functions/public/Users/Emails/Get-GitHubUserEmail.ps1
@@ -26,20 +26,23 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
- param (
+ param(
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
[int] $PerPage = 30,
[Parameter()]
- [switch] $Public
+ [switch] $Public,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($Public) {
- Get-GitHubUserPublicEmail -PerPage $PerPage
+ Get-GitHubUserPublicEmail -PerPage $PerPage -Context $Context
} else {
- Get-GitHubUserAllEmail -PerPage $PerPage
+ Get-GitHubUserAllEmail -PerPage $PerPage -Context $Context
}
-
}
diff --git a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1 b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1
index 24e927ba..b36e51e2 100644
--- a/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1
+++ b/src/functions/public/Users/Emails/Remove-GitHubUserEmail.ps1
@@ -18,19 +18,26 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# Email addresses associated with the GitHub user account.
[Parameter(
Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
- [string[]] $Emails
+ [string[]] $Emails,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ emails = $Emails
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/emails'
Method = 'DELETE'
Body = $body
diff --git a/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1 b/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1
index 1627fdf9..151559cd 100644
--- a/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1
+++ b/src/functions/public/Users/Emails/Set-GitHubUserEmailVisibility.ps1
@@ -23,7 +23,7 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# Denotes whether an email is publicly visible.
[Parameter(
Mandatory,
@@ -31,12 +31,19 @@
ValueFromPipelineByPropertyName
)]
[ValidateSet('public', 'private')]
- [string] $Visibility
+ [string] $Visibility,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ visibility = $Visibility
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/email/visibility'
Method = 'PATCH'
Body = $body
diff --git a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1
index a8d6f07b..c31d9d6b 100644
--- a/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Add-GitHubUserFollowing.ps1
@@ -20,17 +20,22 @@
[OutputType([pscustomobject])]
[Alias('Follow-GitHubUser')]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/following/$Username"
Method = 'PUT'
}
diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1
index 0624f6df..081ca315 100644
--- a/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1
+++ b/src/functions/public/Users/Followers/Get-GitHubUserFollower.ps1
@@ -22,7 +22,7 @@
[OutputType([pscustomobject])]
[Alias('Get-GitHubUserMyFollowers')]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
ValueFromPipeline,
@@ -34,13 +34,16 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($Username) {
- Get-GitHubUserFollowersOfUser -Username $Username -PerPage $PerPage
+ Get-GitHubUserFollowersOfUser -Username $Username -PerPage $PerPage -Context $Context
} else {
- Get-GitHubUserMyFollowers -PerPage $PerPage
+ Get-GitHubUserMyFollowers -PerPage $PerPage -Context $Context
}
-
}
diff --git a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1
index 001edd33..7ff8c5a1 100644
--- a/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Get-GitHubUserFollowing.ps1
@@ -23,7 +23,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
ValueFromPipeline,
@@ -35,13 +35,16 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($Username) {
- Get-GitHubUserFollowingUser -Username $Username -PerPage $PerPage
+ Get-GitHubUserFollowingUser -Username $Username -PerPage $PerPage -Context $Context
} else {
- Get-GitHubUserFollowingMe -PerPage $PerPage
+ Get-GitHubUserFollowingMe -PerPage $PerPage -Context $Context
}
-
}
diff --git a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1
index 3c92b5e5..017b3846 100644
--- a/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Remove-GitHubUserFollowing.ps1
@@ -17,17 +17,22 @@
[OutputType([pscustomobject])]
[Alias('Unfollow-GitHubUser')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
- [string] $Username
+ [string] $Username,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/following/$Username"
Method = 'DELETE'
}
diff --git a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1 b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1
index e1a3000c..939ea704 100644
--- a/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1
+++ b/src/functions/public/Users/Followers/Test-GitHubUserFollowing.ps1
@@ -27,7 +27,7 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[Alias('Test-GitHubUserFollows')]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account we want to check if is being followed.
[Parameter(
Mandatory,
@@ -41,14 +41,17 @@
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $Username
+ [string] $Username,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($Username) {
- Test-GitHubUserFollowedByUser -Username $Username -Follows $Follows
+ Test-GitHubUserFollowedByUser -Username $Username -Follows $Follows -Context $Context
} else {
- Test-GitHubUserFollowedByMe -Username $Follows
+ Test-GitHubUserFollowedByMe -Username $Follows -Context $Context
}
}
diff --git a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1
index 29d8f3ec..ed9248ae 100644
--- a/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1
+++ b/src/functions/public/Users/GPG-Keys/Add-GitHubUserGpgKey.ps1
@@ -25,7 +25,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# A descriptive name for the new key.
[Parameter(
Mandatory,
@@ -40,13 +40,20 @@
ValueFromPipelineByPropertyName
)]
[Alias('armored_public_key')]
- [string] $ArmoredPublicKey
+ [string] $ArmoredPublicKey,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ name = $Name
+ armored_public_key = $ArmoredPublicKey
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/gpg_keys'
Method = 'POST'
Body = $body
@@ -55,5 +62,4 @@
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
-
}
diff --git a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1
index 7e9e363f..79f44558 100644
--- a/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1
+++ b/src/functions/public/Users/GPG-Keys/Get-GitHubUserGpgKey.ps1
@@ -27,7 +27,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -47,16 +47,20 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($Username) {
- Get-GitHubUserGpgKeyForUser -Username $Username -PerPage $PerPage
+ Get-GitHubUserGpgKeyForUser -Username $Username -PerPage $PerPage -Context $Context
} else {
if ($ID) {
- Get-GitHubUserMyGpgKeyById -ID $ID
+ Get-GitHubUserMyGpgKeyById -ID $ID -Context $Context
} else {
- Get-GitHubUserMyGpgKey -PerPage $PerPage
+ Get-GitHubUserMyGpgKey -PerPage $PerPage -Context $Context
}
}
}
diff --git a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1 b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1
index 2e344f90..e7950537 100644
--- a/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1
+++ b/src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1
@@ -19,16 +19,21 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The ID of the GPG key.
[Parameter(
Mandatory
)]
[Alias('gpg_key_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/gpg_keys/$ID"
Method = 'DELETE'
}
diff --git a/src/functions/public/Users/Get-GitHubUser.ps1 b/src/functions/public/Users/Get-GitHubUser.ps1
index e4425d6f..9bf6a698 100644
--- a/src/functions/public/Users/Get-GitHubUser.ps1
+++ b/src/functions/public/Users/Get-GitHubUser.ps1
@@ -33,7 +33,7 @@
Justification = 'Parameter is used in dynamic parameter validation.'
)]
[CmdletBinding(DefaultParameterSetName = '__DefaultSet')]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -56,24 +56,28 @@
# The number of results per page (max 100).
[Parameter(ParameterSetName = 'AllUsers')]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
switch ($PSCmdlet.ParameterSetName) {
'__DefaultSet' {
- $user = Get-GitHubMyUser
- $social_accounts = Get-GitHubMyUserSocials
+ $user = Get-GitHubMyUser -Context $Context
+ $social_accounts = Get-GitHubMyUserSocials -Context $Context
$user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force
$user
}
'NamedUser' {
- $user = Get-GitHubUserByName -Username $Username
- $social_accounts = Get-GitHubUserSocialsByName -Username $Username
+ $user = Get-GitHubUserByName -Username $Username -Context $Context
+ $social_accounts = Get-GitHubUserSocialsByName -Username $Username -Context $Context
$user | Add-Member -MemberType NoteProperty -Name 'social_accounts' -Value $social_accounts -Force
$user
}
'AllUsers' {
- Get-GitHubAllUsers -Since $Since -PerPage $PerPage
+ Get-GitHubAllUsers -Since $Since -PerPage $PerPage -Context $Context
}
}
}
diff --git a/src/functions/public/Users/Get-GitHubUserCard.ps1 b/src/functions/public/Users/Get-GitHubUserCard.ps1
index 92e94413..1fcacd12 100644
--- a/src/functions/public/Users/Get-GitHubUserCard.ps1
+++ b/src/functions/public/Users/Get-GitHubUserCard.ps1
@@ -24,18 +24,24 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
[Parameter(
Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
[string] $Username,
+
[Parameter()]
[ValidateSet('organization', 'repository', 'issue', 'pull_request')]
[string] $SubjectType,
+
+ [Parameter()]
+ [int] $SubjectID = '',
+
+ # The context to run the command in.
[Parameter()]
- [int] $SubjectID = ''
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$body = @{
@@ -44,6 +50,7 @@
}
$inputObject = @{
+ Context = $Context
APIEndpoint = "/users/$Username/hovercard"
Method = 'GET'
Body = $body
diff --git a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1
index 40bb6b85..d283b36a 100644
--- a/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1
+++ b/src/functions/public/Users/Keys/Add-GitHubUserKey.ps1
@@ -20,7 +20,7 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')]
[CmdletBinding()]
- param (
+ param(
# A descriptive name for the new key.
[Parameter(
ValueFromPipeline,
@@ -34,13 +34,20 @@
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $Key
+ [string] $Key,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ title = $Title
+ key = $Key
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/keys'
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1
index 82ca726b..6b43959d 100644
--- a/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1
+++ b/src/functions/public/Users/Keys/Get-GitHubUserKey.ps1
@@ -30,7 +30,7 @@
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -50,16 +50,20 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($Username) {
- Get-GitHubUserKeyForUser -Username $Username -PerPage $PerPage
+ Get-GitHubUserKeyForUser -Username $Username -PerPage $PerPage -Context $Context
} else {
if ($ID) {
- Get-GitHubUserMyKeyById -ID $ID
+ Get-GitHubUserMyKeyById -ID $ID -Context $Context
} else {
- Get-GitHubUserMyKey -PerPage $PerPage
+ Get-GitHubUserMyKey -PerPage $PerPage -Context $Context
}
}
}
diff --git a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1 b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1
index 929444ea..5e36121c 100644
--- a/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1
+++ b/src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1
@@ -20,16 +20,21 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The unique identifier of the key.
[Parameter(
Mandatory
)]
[Alias('key_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/keys/$ID"
Method = 'DELETE'
}
diff --git a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1
index 78e100cf..33917a42 100644
--- a/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1
+++ b/src/functions/public/Users/SSH-Signing-Keys/Add-GitHubUserSigningKey.ps1
@@ -21,7 +21,7 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')]
[OutputType([pscustomobject])]
[CmdletBinding()]
- param (
+ param(
# A descriptive name for the new key.
[Parameter(
ValueFromPipeline,
@@ -36,13 +36,20 @@
Mandatory,
ValueFromPipelineByPropertyName
)]
- [string] $Key
+ [string] $Key,
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ title = $Title
+ key = $Key
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/ssh_signing_keys'
Method = 'POST'
Body = $body
diff --git a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1
index 44ef4ff2..c9f11eb0 100644
--- a/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1
+++ b/src/functions/public/Users/SSH-Signing-Keys/Get-GitHubUserSigningKey.ps1
@@ -30,7 +30,7 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding()]
- param (
+ param(
# The handle for the GitHub user account.
[Parameter(
Mandatory,
@@ -50,16 +50,20 @@
# The number of results per page (max 100).
[Parameter()]
[ValidateRange(1, 100)]
- [int] $PerPage = 30
+ [int] $PerPage = 30,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
if ($Username) {
- Get-GitHubUserSigningKeyForUser -Username $Username -PerPage $PerPage
+ Get-GitHubUserSigningKeyForUser -Username $Username -PerPage $PerPage -Context $Context
} else {
if ($ID) {
- Get-GitHubUserMySigningKeyById -ID $ID
+ Get-GitHubUserMySigningKeyById -ID $ID -Context $Context
} else {
- Get-GitHubUserMySigningKey -PerPage $PerPage
+ Get-GitHubUserMySigningKey -PerPage $PerPage -Context $Context
}
}
}
diff --git a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1 b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1
index a72cacdb..78aedde9 100644
--- a/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1
+++ b/src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1
@@ -21,16 +21,21 @@
[OutputType([pscustomobject])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The unique identifier of the SSH signing key.
[Parameter(
Mandatory
)]
[Alias('ssh_signing_key_id')]
- [string] $ID
+ [string] $ID,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
$inputObject = @{
+ Context = $Context
APIEndpoint = "/user/ssh_signing_keys/$ID"
Method = 'DELETE'
}
@@ -40,5 +45,4 @@
Write-Output $_.Response
}
}
-
}
diff --git a/src/functions/public/Users/Set-GitHubUser.ps1 b/src/functions/public/Users/Set-GitHubUser.ps1
index 8fdabce5..023e7bce 100644
--- a/src/functions/public/Users/Set-GitHubUser.ps1
+++ b/src/functions/public/Users/Set-GitHubUser.ps1
@@ -29,7 +29,7 @@
[OutputType([void])]
[Alias('Update-GitHubUser')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# The new name of the user.
[Parameter()]
[string] $Name,
@@ -60,15 +60,29 @@
# The new short biography of the user.
[Parameter()]
- [string] $Bio
+ [string] $Bio,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ name = $Name
+ email = $Email
+ blog = $Blog
+ twitter_username = $TwitterUsername
+ company = $Company
+ location = $Location
+ hireable = $Hireable
+ bio = $Bio
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user'
- Body = $body
Method = 'PATCH'
+ Body = $body
}
if ($PSCmdlet.ShouldProcess('authenticated user', 'Set')) {
diff --git a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1
index bbb91db2..76062bb0 100644
--- a/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1
+++ b/src/functions/public/Users/Social-Accounts/Add-GitHubUserSocial.ps1
@@ -18,16 +18,23 @@
[Alias('Add-GitHubUserSocials')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links for documentation.')]
[CmdletBinding()]
- param (
+ param(
# Full URLs for the social media profiles to add.
[Parameter(Mandatory)]
[Alias('account_urls')]
- [string[]] $AccountUrls
+ [string[]] $AccountUrls,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ account_urls = $AccountUrls
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/social_accounts'
Body = $body
Method = 'POST'
diff --git a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1 b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1
index 9454690c..f0df0d89 100644
--- a/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1
+++ b/src/functions/public/Users/Social-Accounts/Remove-GitHubUserSocial.ps1
@@ -19,16 +19,23 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
[Alias('Remove-GitHubUserSocials')]
[CmdletBinding(SupportsShouldProcess)]
- param (
+ param(
# Full URLs for the social media profiles to add.
[Parameter(Mandatory)]
[Alias('account_urls')]
- [string[]] $AccountUrls
+ [string[]] $AccountUrls,
+
+ # The context to run the command in.
+ [Parameter()]
+ [string] $Context = (Get-GitHubConfig -Name 'DefaultContext')
)
- $body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case
+ $body = @{
+ account_urls = $AccountUrls
+ }
$inputObject = @{
+ Context = $Context
APIEndpoint = '/user/social_accounts'
Body = $body
Method = 'DELETE'
diff --git a/tools/utilities/GHAPI.ps1 b/tools/utilities/GHAPI.ps1
index 22de92de..83080479 100644
--- a/tools/utilities/GHAPI.ps1
+++ b/tools/utilities/GHAPI.ps1
@@ -1,4 +1,4 @@
-# API Authorization
+# API Authorization
# https://docs.github.com/en/rest/overview/other-authentication-methods
@@ -13,7 +13,7 @@ $GHAPIBaseURI = 'https://api.github.com'
Function Get-GHActionRun {
[CmdletBinding()]
- param ()
+ param()
# API Reference
# https://docs.github.com/en/rest/reference/actions#list-workflow-runs-for-a-repository
diff --git a/tools/utilities/GitHubAPI.ps1 b/tools/utilities/GitHubAPI.ps1
index ec29aa6b..483070ac 100644
--- a/tools/utilities/GitHubAPI.ps1
+++ b/tools/utilities/GitHubAPI.ps1
@@ -21,7 +21,7 @@ $response = Invoke-RestMethod -Uri $APIDocURI -Method Get
# @{n = 'PUT'; e = { (($_.value.psobject.Properties.Name) -contains 'PUT') } }, `
# @{n = 'PATCH'; e = { (($_.value.psobject.Properties.Name) -contains 'PATCH') } } | Format-Table
-$path = '/orgs/{org}/teams'
+$path = '/app/hook/deliveries'
$method = 'get'
$response.paths.$path.$method
$response.paths.$path.$method.tags | clip # -> Namespace/foldername
@@ -41,75 +41,3 @@ $response.paths.$path.$method.responses.'200'.content.'application/json'.schema
$response.paths.$path.$method.responses.'200'.content.'application/json'.schema.items # -> OutputType
$response.components.schemas.'issue-comment' | ConvertTo-Json
-
-function Find-APIMethod {
- <#
- .SYNOPSIS
- Find API methods in a directory
- #>
- param (
- [Parameter(Mandatory)]
- [string] $SearchDirectory,
-
- [Parameter(Mandatory)]
- [string] $Method,
-
- [Parameter(Mandatory)]
- [string] $Path
- )
-
- $pathPattern = $Path -replace '\{[^}]+\}', '.+'
- $methodPattern = "Method\s*=\s*'$method'"
- Get-ChildItem -Path $SearchDirectory -Recurse -Filter *.ps1 | ForEach-Object {
- $filePath = $_.FullName
- $stringMatches = Select-String -Path $filePath -Pattern $pathPattern -AllMatches
- if ($stringMatches.Count -gt 0) {
- $putMatches = Select-String -Path $filePath -Pattern $methodPattern -AllMatches
- foreach ($match in $stringMatches) {
- foreach ($putMatch in $putMatches) {
- Write-Verbose "Match found in file: $filePath"
- Write-Verbose "API Endpoint: $($match.Matches.Value) near line $($match.LineNumber)"
- Write-Verbose "Method: $($putMatch.Matches.Value) near line $($putMatch.LineNumber)"
- return $true
- }
- }
- }
- }
- return $false
-}
-
-# Get a list of all
-$functions = 0
-$coveredFunctions = 0
-$paths = [System.Collections.Generic.List[pscustomobject]]::new()
-$SearchDirectory = 'C:\Repos\GitHub\PSModule\Module\GitHub\src'
-$response.paths.PSObject.Properties | ForEach-Object {
- $path = $_.Name
- $object = [pscustomobject]@{
- Path = $path
- DELETE = ''
- GET = ''
- PATCH = ''
- POST = ''
- PUT = ''
- }
- $_.Value.psobject.Properties.Name | ForEach-Object {
- $method = $_.ToUpper()
- $found = Find-APIMethod -SearchDirectory $SearchDirectory -Method $method -Path $path
- $object.$method = $found -contains $true ? ':white_check_mark:' : ':x:'
- if ($found) {
- $coveredFunctions++
- }
- $functions++
- }
- $paths.Add($object)
-}
-$paths | New-MDTable | clip
-
-# Output the context of $paths to a markdown table and into the Coverage.md file
-$paths | New-MDTable | Out-File -FilePath '.\Coverage.md'
-
-"Available functions: $functions"
-"Covered functions: $coveredFunctions"
-"Missing function: $($functions - $coveredFunctions)"
-"Coverage: $([math]::Round(($coveredFunctions / $functions) * 100, 2))%"