diff --git a/examples/Apps/AppManagement.ps1 b/examples/Apps/AppManagement.ps1 index 041d19f19..677f9e0c3 100644 --- a/examples/Apps/AppManagement.ps1 +++ b/examples/Apps/AppManagement.ps1 @@ -2,7 +2,7 @@ $appIDs = @( 'Iv1.f26b61bc99e69405' ) -$orgs = Get-GitHubAppInstallableOrganization -Enterprise 'msx' +$orgs = Get-GitHubOrganization -Enterprise 'msx' foreach ($org in $orgs) { foreach ($appID in $appIDs) { Install-GitHubAppOnEnterpriseOrganization -Enterprise msx -Organization $org.login -ClientID $appID -RepositorySelection all diff --git a/examples/Apps/EnterpriseApps.ps1 b/examples/Apps/EnterpriseApps.ps1 index 69de8c402..f06cbfaa7 100644 --- a/examples/Apps/EnterpriseApps.ps1 +++ b/examples/Apps/EnterpriseApps.ps1 @@ -20,7 +20,7 @@ filter Install-GithubApp { ) process { - $installableOrgs = Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Debug -Verbose + $installableOrgs = Get-GitHubOrganization -Enterprise $Enterprise -Debug -Verbose $orgs = $installableOrgs | Where-Object { $_.login -like $organization } foreach ($org in $orgs) { foreach ($appIDitem in $AppID) { diff --git a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 similarity index 87% rename from src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 rename to src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 index 7b3e271ea..f94b2b2ec 100644 --- a/src/functions/public/Apps/GitHub App/Get-GitHubAppInstallableOrganization.ps1 +++ b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppInstallableOrganization.ps1 @@ -27,9 +27,8 @@ [System.Nullable[int]] $PerPage, # The context to run the command in. Used to get the details for the API call. - # Can be either a string or a GitHubContext object. - [Parameter()] - [object] $Context = (Get-GitHubContext) + [Parameter(Mandatory)] + [object] $Context ) begin { @@ -49,7 +48,7 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubOrganization]::new($_.Response) } } @@ -57,5 +56,3 @@ Write-Debug "[$stackPath] - End" } } - -#SkipTest:FunctionTest:Will add a test for this function in a future PR diff --git a/src/functions/public/Organization/Get-GitHubOrganization.ps1 b/src/functions/public/Organization/Get-GitHubOrganization.ps1 index 9dd44759a..ca19008c8 100644 --- a/src/functions/public/Organization/Get-GitHubOrganization.ps1 +++ b/src/functions/public/Organization/Get-GitHubOrganization.ps1 @@ -12,22 +12,27 @@ .EXAMPLE Get-GitHubOrganization - List organizations for the authenticated user. + List all organizations for the authenticated user. .EXAMPLE Get-GitHubOrganization -Username 'octocat' - List public organizations for the user 'octocat'. + List public organizations for a specific user. .EXAMPLE Get-GitHubOrganization -All -Since 142951047 - List organizations, starting with PSModule. + List all organizations made after an ID. .EXAMPLE Get-GitHubOrganization -Name 'PSModule' - Get the organization 'PSModule'. + Get a specific organization. + + .EXAMPLE + Get-GitHubOrganization -Enterprise 'msx' + + Get the organizations belonging to an Enterprise. .OUTPUTS GitHubOrganization @@ -36,13 +41,13 @@ https://psmodule.io/GitHub/Functions/Organization/Get-GitHubOrganization #> [OutputType([GitHubOrganization])] - [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] + [CmdletBinding(DefaultParameterSetName = 'List all organizations for the authenticated user')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'All', Justification = 'Required for parameter set')] param( # The organization name. The name is not case sensitive. [Parameter( Mandatory, - ParameterSetName = 'NamedOrg', + ParameterSetName = 'Get a specific organization', ValueFromPipeline, ValueFromPipelineByPropertyName )] @@ -51,27 +56,34 @@ # The handle for the GitHub user account. [Parameter( Mandatory, - ParameterSetName = 'NamedUser', + ParameterSetName = 'List public organizations for a specific user', ValueFromPipelineByPropertyName )] [Alias('User')] [string] $Username, + # The Enterprise slug to get organizations from. + [Parameter( + Mandatory, + ParameterSetName = 'Get the organizations belonging to an Enterprise', + ValueFromPipelineByPropertyName + )] + [string] $Enterprise, + # List all organizations. Use '-Since' to start at a specific organization ID. [Parameter( Mandatory, - ParameterSetName = 'AllOrg' + ParameterSetName = 'List all organizations on the tenant' )] [switch] $All, # A organization ID. Only return organizations with an ID greater than this ID. - [Parameter(ParameterSetName = 'AllOrg')] + [Parameter(ParameterSetName = 'List all organizations on the tenant')] [int] $Since = 0, # The number of results per page (max 100). - [Parameter(ParameterSetName = 'AllOrg')] - [Parameter(ParameterSetName = 'UserOrg')] - [Parameter(ParameterSetName = '__AllParameterSets')] + [Parameter(ParameterSetName = 'List all organizations on the tenant')] + [Parameter(ParameterSetName = 'List all organizations for the authenticated user')] [System.Nullable[int]] $PerPage, # The context to run the command in. Used to get the details for the API call. @@ -89,13 +101,16 @@ process { switch ($PSCmdlet.ParameterSetName) { - 'NamedOrg' { + 'Get a specific organization' { Get-GitHubOrganizationByName -Name $Name -Context $Context } - 'NamedUser' { + 'List public organizations for a specific user' { Get-GitHubUserOrganization -Username $Username -Context $Context } - 'AllOrg' { + 'Get the organizations belonging to an Enterprise' { + Get-GitHubAppInstallableOrganization -Enterprise $Enterprise -Context $Context + } + 'List all organizations on the tenant' { Get-GitHubAllOrganization -Since $Since -PerPage $PerPage -Context $Context } default {