Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
c19d7e4
set paging to 30 (as default)
MariusStorhaug Sep 29, 2023
eb23550
Add function to get a named org
MariusStorhaug Sep 29, 2023
239fa87
Add function to get list of orgs
MariusStorhaug Sep 29, 2023
5eca5b8
Added a param to GHAPI to declare or add, add is default
MariusStorhaug Sep 29, 2023
ca50d05
Added function to get a list of all orgs
MariusStorhaug Sep 29, 2023
5c06c66
Add function to remove a github org
MariusStorhaug Sep 29, 2023
8be249b
Add function to update/set a github org
MariusStorhaug Sep 29, 2023
76af203
Add function to get a named org
MariusStorhaug Sep 29, 2023
240ed80
Add function to get all apps installed in an org
MariusStorhaug Sep 29, 2023
e570a91
Add function to get organizations
MariusStorhaug Sep 29, 2023
e236d0c
fix type on api
MariusStorhaug Sep 29, 2023
9441dcb
Add function to set org sec features
MariusStorhaug Sep 29, 2023
ff17b1d
Add function to get app installations on org
MariusStorhaug Sep 29, 2023
972335c
Fix api script
MariusStorhaug Sep 29, 2023
48901a3
Fix naming collision
MariusStorhaug Sep 29, 2023
e4720c0
fix for org
MariusStorhaug Sep 29, 2023
4ea3054
Get details by default for personal orgs
MariusStorhaug Sep 29, 2023
631e353
Fix piping
MariusStorhaug Sep 29, 2023
f1c7fd6
Enable pipeline streaming
MariusStorhaug Sep 29, 2023
f018c7f
Fix param collision
MariusStorhaug Sep 29, 2023
b8a30c9
Fix name in set-org
MariusStorhaug Sep 29, 2023
ccb49fe
Fix set-orgsecfeat to post
MariusStorhaug Sep 29, 2023
822b0c6
Fix for connect-acc
MariusStorhaug Sep 29, 2023
5468bd0
Adding status code and responseheader to api response
MariusStorhaug Sep 30, 2023
4390940
Add paging to app installation
MariusStorhaug Sep 30, 2023
f0f4394
add assert blocked user on org
MariusStorhaug Sep 30, 2023
43404fb
add function to get blocked users in an org
MariusStorhaug Sep 30, 2023
fbb7be8
Test file updates
MariusStorhaug Sep 30, 2023
4260f3e
Add statusCode + responseheaders to return
MariusStorhaug Sep 30, 2023
212f7d2
remove write outputs
MariusStorhaug Sep 30, 2023
c1632fb
TODO add sorting on get-config
MariusStorhaug Sep 30, 2023
b804059
Troubleshoot statuscode and responseheaders
MariusStorhaug Sep 30, 2023
6517f15
Add new hashtable and object functions
MariusStorhaug Sep 30, 2023
9de3991
Remove Join-Hashtable using Join-Object -AsHashtable
MariusStorhaug Sep 30, 2023
4c58ce8
Fixes for ghorg
MariusStorhaug Sep 30, 2023
09f45a9
Fix streaming
MariusStorhaug Sep 30, 2023
7518e71
Test body as object
MariusStorhaug Sep 30, 2023
8be1070
fix json output
MariusStorhaug Sep 30, 2023
01daa27
Add return for statuscode and responseheader
MariusStorhaug Sep 30, 2023
90faf56
Pack response with status and header
MariusStorhaug Sep 30, 2023
23ce34a
set all to filter and pass response
MariusStorhaug Sep 30, 2023
42bf846
fix error
MariusStorhaug Sep 30, 2023
7ce1db5
Fix timer of accesstoken remaining
MariusStorhaug Sep 30, 2023
8ee0513
Fix set user and org
MariusStorhaug Sep 30, 2023
3c55306
Fix some testing
MariusStorhaug Sep 30, 2023
01dbd88
Fix octo example to a working one
MariusStorhaug Sep 30, 2023
32c8298
Fix for token expir
MariusStorhaug Sep 30, 2023
4a36edb
Fix acctok timer
MariusStorhaug Sep 30, 2023
1496e17
Fix hashtable and set org+user
MariusStorhaug Sep 30, 2023
4b3161d
Added casing utilities
MariusStorhaug Oct 1, 2023
701e95f
Moved hashtable and object functions
MariusStorhaug Oct 1, 2023
108daf2
Update Set org and user to use casing for params
MariusStorhaug Oct 1, 2023
705c836
UPdate convertion
MariusStorhaug Oct 1, 2023
2e64045
Fix hashtable values to lower
MariusStorhaug Oct 1, 2023
d3320ff
fix
MariusStorhaug Oct 1, 2023
65d2186
Use UTF 8 to support icons + Store request, so it is available from c…
MariusStorhaug Oct 1, 2023
7492974
Fix for user section
MariusStorhaug Oct 1, 2023
15ec1b1
dont select lang for docs
MariusStorhaug Oct 1, 2023
60a7f15
Use errorhandling to get correct errorcode from assert
MariusStorhaug Oct 1, 2023
5d8b50e
Add some user commands
MariusStorhaug Oct 1, 2023
3a4d93a
version bump
MariusStorhaug Oct 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GitHub/GitHub.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Author = 'Marius Storhaug'

# Version number of this module
ModuleVersion = '0.1.1'
ModuleVersion = '0.2.0'

# Description of the functionality provided by this module
Description = 'GitHub PowerShell Module'
Expand Down
6 changes: 3 additions & 3 deletions src/GitHub/en_US/about_Auth.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ KEYWORDS

SEE ALSO
For more information on the Device Flow visit:
- https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
- https://docs.github.com/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app

For information about scopes and other authentication methods on GitHub:
- https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
- https://docs.github.com/en/rest/overview/other-authentication-methods#authenticating-for-saml-sso
- https://docs.github.com/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
- https://docs.github.com/rest/overview/other-authentication-methods#authenticating-for-saml-sso
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

.NOTES
For more info about the Device Flow visit:
https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow
https://docs.github.com/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
https://docs.github.com/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow
#>
[OutputType([void])]
[CmdletBinding()]
Expand All @@ -27,7 +27,7 @@
# The scope of the access token, when using OAuth authentication.
# Provide the list of scopes as space-separated values.
# For more information on scopes visit:
# https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
# https://docs.github.com/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
[Parameter()]
[string] $Scope,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

.NOTES
For more info about the Device Flow visit:
https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
https://docs.github.com/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
#>
[OutputType([PSCustomObject])]
[CmdletBinding(DefaultParameterSetName = 'DeviceFlow')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

.NOTES
For more info about the Device Flow visit:
https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
https://docs.github.com/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
#>
[OutputType([PSCustomObject])]
[CmdletBinding()]
Expand All @@ -25,7 +25,7 @@
# The scope of the access token, when using OAuth authentication.
# Provide the list of scopes as space-separated values.
# For more information on scopes visit:
# https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
# https://docs.github.com/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
[Parameter()]
[string] $Scope = 'gist, read:org, repo, workflow'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

.NOTES
For more info about the Device Flow visit:
https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
https://docs.github.com/apps/creating-github-apps/writing-code-for-a-github-app/building-a-cli-with-a-github-app
#>
[OutputType([PSCustomObject])]
[CmdletBinding(DefaultParameterSetName = 'DeviceFlow')]
Expand Down
2 changes: 1 addition & 1 deletion src/GitHub/private/Menu/Invoke-Meny.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if ($pos -ge $menuItems.length) { $pos = $menuItems.length - 1 }
Invoke-DrawMenu $menuItems $pos $menuTitel
}
Write-Output $($menuItems[$pos])
$($menuItems[$pos])
}


Expand Down
45 changes: 45 additions & 0 deletions src/GitHub/private/Organization/Get-GitHubAllOrganization.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
filter Get-GitHubAllOrganization {
<#
.SYNOPSIS
List organizations

.DESCRIPTION
Lists all organizations, in the order that they were created on GitHub.

**Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.

.EXAMPLE
Get-GitHubAllOrganization -Since 142951047

List organizations, starting with PSModule

.NOTES
https://docs.github.com/rest/orgs/orgs#list-organizations

#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
# A organization ID. Only return organizations with an ID greater than this ID.
[Parameter()]
[int] $Since = 0,

# The number of results per page (max 100).
[Parameter()]
[int] $PerPage = 30
)

$body = @{
since = $Since
per_page = $PerPage
}

$inputObject = @{
APIEndpoint = '/organizations'
Method = 'GET'
Body = $body
}

(Invoke-GitHubAPI @inputObject).Response

}
41 changes: 41 additions & 0 deletions src/GitHub/private/Organization/Get-GitHubMyOrganization.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
filter Get-GitHubMyOrganization {
<#
.SYNOPSIS
List organizations for the authenticated user

.DESCRIPTION
List organizations for the authenticated user.

**OAuth scope requirements**

This only lists organizations that your authorization allows you to operate on in some way (e.g., you can list teams with `read:org` scope, you can publicize your organization membership with `user` scope, etc.). Therefore, this API requires at least `user` or `read:org` scope. OAuth requests with insufficient scope receive a `403 Forbidden` response.

.EXAMPLE
Get-GitHubMyOrganization

List organizations for the authenticated user.

.NOTES
https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
# The number of results per page (max 100).
[Parameter()]
[int] $PerPage = 30
)

$body = @{
per_page = $PerPage
}

$inputObject = @{
APIEndpoint = '/user/orgs'
Method = 'GET'
Body = $body
}

(Invoke-GitHubAPI @inputObject).Response

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
filter Get-GitHubOrganizationByName {
<#
.SYNOPSIS
Get an organization

.DESCRIPTION
To see many of the organization response values, you need to be an authenticated organization owner with the `admin:org` scope. When the value of `two_factor_requirement_enabled` is `true`, the organization requires all members, billing managers, and outside collaborators to enable [two-factor authentication](https://docs.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/).

GitHub Apps with the `Organization plan` permission can use this endpoint to retrieve information about an organization's GitHub plan. See "[Authenticating with GitHub Apps](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/)" for details. For an example response, see 'Response with GitHub plan information' below."

.EXAMPLE
Get-GitHubOrganizationByName -OrganizationName 'github'

Get the 'GitHub' organization

.NOTES
https://docs.github.com/rest/orgs/orgs#get-an-organization
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
# The organization name. The name is not case sensitive.
[Parameter(
Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
[Alias('login')]
[Alias('org')]
[Alias('owner')]
[string] $OrganizationName
)


$inputObject = @{
APIEndpoint = "/orgs/$OrganizationName"
Method = 'GET'
}

(Invoke-GitHubAPI @inputObject).Response

}
43 changes: 43 additions & 0 deletions src/GitHub/private/Organization/Get-GitHubUserOrganization.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
filter Get-GitHubUserOrganization {
<#
.SYNOPSIS
List organizations for a user

.DESCRIPTION
List [public organization memberships](https://docs.github.com/articles/publicizing-or-concealing-organization-membership) for the specified user.

This method only lists _public_ memberships, regardless of authentication. If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the [List organizations for the authenticated user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user) API instead.

.EXAMPLE
Get-GitHubUserOrganization -Username 'octocat'

List public organizations for the user 'octocat'.

.NOTES
https://docs.github.com/rest/orgs/orgs#list-organizations-for-a-user
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
# The handle for the GitHub user account.
[Parameter(Mandatory)]
[string] $Username,

# The number of results per page (max 100).
[Parameter()]
[int] $PerPage = 30
)

$body = @{
per_page = $PerPage
}

$inputObject = @{
APIEndpoint = "/users/$Username/orgs"
Method = 'GET'
Body = $body
}

(Invoke-GitHubAPI @inputObject).Response

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Get-GitHubUserList {
filter Get-GitHubAllUser {
<#
.SYNOPSIS
List users
Expand All @@ -9,9 +9,9 @@
Note: Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of users.

.EXAMPLE
Get-GitHubUserList -Since 17722253
Get-GitHubAllUser -Since 17722253

Get the authenticated user
Get a list of users, starting with the user 'MariusStorhaug'.

.NOTES
https://docs.github.com/rest/users/users#list-users
Expand All @@ -22,22 +22,20 @@
# A user ID. Only return users with an ID greater than this ID.
[Parameter()]
[int] $Since = 0,

# The number of results per page (max 100).
[Parameter()]
[int] $PerPage = 100
[int] $PerPage = 30
)

$body = @{
since = $Since
per_page = $PerPage
}
$body = $PSBoundParameters | ConvertFrom-HashTable | ConvertTo-HashTable -NameCasingStyle snake_case

$inputObject = @{
APIEndpoint = "/users"
Method = 'GET'
Body = $body
}

Invoke-GitHubAPI @inputObject
(Invoke-GitHubAPI @inputObject).Response

}
30 changes: 30 additions & 0 deletions src/GitHub/private/Users/Get-GitHubMyUser.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
filter Get-GitHubMyUser {
<#
.SYNOPSIS
Get the authenticated user

.DESCRIPTION
If the authenticated user is authenticated with an OAuth token with the `user` scope, then the response lists public and private profile information.
If the authenticated user is authenticated through OAuth without the `user` scope, then the response lists only public profile information.

.EXAMPLE
Get-GitHubMyUser

Get the authenticated user

.NOTES
https://docs.github.com/rest/users/users#get-the-authenticated-user
#>
[OutputType([pscustomobject])]
[Alias('Get-GitHubContext')]
[CmdletBinding()]
param ()

$inputObject = @{
APIEndpoint = '/user'
Method = 'GET'
}

(Invoke-GitHubAPI @inputObject).Response

}
41 changes: 41 additions & 0 deletions src/GitHub/private/Users/Get-GitHubUserByName.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
filter Get-GitHubUserByName {
<#
.SYNOPSIS
Get a user

.DESCRIPTION
Provides publicly available information about someone with a GitHub account.
GitHub Apps with the `Plan` user permission can use this endpoint to retrieve information about a user's GitHub plan. The GitHub App must be authenticated as a user. See "[Identifying and authorizing users for GitHub Apps](https://docs.github.com/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps/)" for details about authentication. For an example response, see 'Response with GitHub plan information' below"
The `email` key in the following response is the publicly visible email address from your GitHub [profile page](https://github.com/settings/profile). When setting up your profile, you can select a primary email address to be ΓÇ£publicΓÇ¥ which provides an email entry for this endpoint. If you do not set a public email address for `email`, then it will have a value of `null`. You only see publicly visible email addresses when authenticated with GitHub. For more information, see [Authentication](https://docs.github.com/rest/overview/resources-in-the-rest-api#authentication).
The Emails API enables you to list all of your email addresses, and toggle a primary email to be visible publicly. For more information, see "[Emails API](https://docs.github.com/rest/users/emails)".

.EXAMPLE
Get-GitHubUserByName -Username 'octocat'

Get the 'octocat' user.

.NOTES
https://docs.github.com/rest/users/users#get-a-user
#>
[OutputType([pscustomobject])]
[CmdletBinding()]
param (
# The handle for the GitHub user account.
[Parameter(
Mandatory,
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
[Alias('login')]
[string] $Username
)


$inputObject = @{
APIEndpoint = "/users/$Username"
Method = 'GET'
}

(Invoke-GitHubAPI @inputObject).Response

}
Loading