Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
82ce397
🩹 [Patch]: Refactor constructors to use GitHubContext for URL generation
MariusStorhaug Jul 5, 2025
4dbc399
🩹 [Patch]: Remove alias 'Get-GitHubRepoSecurityFixes' from Get-GitHub…
MariusStorhaug Jul 5, 2025
93e6521
🩹 [Patch]: Remove alias 'Get-GitHubAppJWT' from Get-GitHubAppJSONWebT…
MariusStorhaug Jul 5, 2025
c18a1ee
🩹 [Patch]: Remove aliases from parameters and add new functions for r…
MariusStorhaug Jul 5, 2025
9e3b199
Refactor response handling in multiple functions to use foreach loops…
MariusStorhaug Jul 5, 2025
3da8a4e
🩹 [Patch]: Rename 'Blog' parameter to 'Website' in multiple files for…
MariusStorhaug Jul 5, 2025
290e3fa
🩹 [Patch]: Add functions to retrieve GitHub Enterprise details by nam…
MariusStorhaug Jul 5, 2025
e3fb710
Refactor GitHubOwner classes to streamline properties and enhance use…
MariusStorhaug Jul 5, 2025
11b0d2f
Add test for Get-GitHubEnterprise to retrieve all available enterpris…
MariusStorhaug Jul 5, 2025
1481989
Refactor response handling in Get-GitHubOrganizationMember to use for…
MariusStorhaug Jul 5, 2025
f5e8f67
Refactor GraphQL fields assignment in Get-GitHubEnterpriseByName and …
MariusStorhaug Jul 5, 2025
14a858b
Refactor formatting of the GraphQL property mapping in GitHubEnterpri…
MariusStorhaug Jul 5, 2025
cdc409f
Update examples and comments in Update-GitHubOrganization and Update-…
MariusStorhaug Jul 5, 2025
d174cc1
Remove redundant type assignment in GitHubEnterprise property mapping
MariusStorhaug Jul 5, 2025
92640f3
Remove BillingEmail property from GitHubEnterprise class and related …
MariusStorhaug Jul 5, 2025
44d0a8b
Refactor whitespace in GitHubEnterprise property mapping for improved…
MariusStorhaug Jul 5, 2025
abd8328
Update GraphQL query structure in Get-GitHubEnterpriseList and fix da…
MariusStorhaug Jul 5, 2025
9e53132
Remove hardcoded CreatedAt date checks in GitHubEnterprise tests for …
MariusStorhaug Jul 5, 2025
437959a
Add pagination support to GraphQL query in Get-GitHubEnterpriseList f…
MariusStorhaug Jul 6, 2025
3f4723f
Add Pester tests for GitHub API interactions
MariusStorhaug Jul 6, 2025
2cb9f36
Fix initial hasNextPage value in Get-GitHubEnterpriseList function fo…
MariusStorhaug Jul 6, 2025
b7a356e
Add Get-GitHubOrganizationList function to retrieve organization deta…
MariusStorhaug Jul 6, 2025
e4f218e
Unskip test for Get-GitHubEnterprise to ensure it runs for enterprise…
MariusStorhaug Jul 6, 2025
a41e6bf
Remove debug and verbose flags from Get-GitHubEnterprise call in test…
MariusStorhaug Jul 6, 2025
a5770a9
Unskip test for Get-GitHubEnterprise to ensure it runs for available …
MariusStorhaug Jul 6, 2025
2308670
Unskip test for Get-GitHubEnterprise to ensure it runs for enterprise…
MariusStorhaug Jul 6, 2025
6a4b827
Remove IsAdmin and IsMember fields from GitHubOrganization mapping
MariusStorhaug Jul 6, 2025
a99a017
Pass Context parameter to GitHubOrganization constructor in Get-GitHu…
MariusStorhaug Jul 6, 2025
7653e6b
Make Context parameter mandatory in Get-GitHubEnterprise functions an…
MariusStorhaug Jul 6, 2025
4557c19
Comment out MembersCanForkPrivateRepositories mapping in GitHubOrgani…
MariusStorhaug Jul 6, 2025
e070866
Comment out MembersCanForkPrivateRepositories and RequiresTwoFactorAu…
MariusStorhaug Jul 6, 2025
1ff536a
Add Get-GitHubOrganizationListForAuthUser function and update references
MariusStorhaug Jul 6, 2025
7ab92ef
Add PerPage parameter to Get-GitHubOrganizationListForAuthUser function
MariusStorhaug Jul 6, 2025
589f296
Add Parameter attribute to PerPage in Get-GitHubOrganizationListForAu…
MariusStorhaug Jul 6, 2025
ad37bef
Refactor property mapping in GitHubOrganization class and comment out…
MariusStorhaug Jul 6, 2025
62c7f10
Add initial test scripts for GitHub API interactions
MariusStorhaug Jul 6, 2025
ed85531
Update CodeCoverage PercentTarget to 50 in PSModule.yml
MariusStorhaug Jul 6, 2025
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 .github/PSModule.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Test:
CodeCoverage:
PercentTarget: 0
PercentTarget: 50
6 changes: 3 additions & 3 deletions src/classes/public/App/GitHubAppInstallation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
$this.Url = $Object.html_url
}

GitHubAppInstallation([PSCustomObject] $Object, [string] $Target, [string] $Type, [string] $HostName) {
GitHubAppInstallation([PSCustomObject] $Object, [string] $Target, [string] $Type, [GitHubContext] $Context) {
$this.ID = $Object.id
$this.App = [GitHubApp]::new(
[PSCustomObject]@{
Expand All @@ -77,7 +77,7 @@
$this.Target = [GitHubOwner]@{
Name = $Target
Type = $Type
Url = "https://$HostName/$Target"
Url = "https://$($Context.HostName)/$Target"
}
$this.Type = $Type
$this.RepositorySelection = $Object.repository_selection
Expand All @@ -88,6 +88,6 @@
$this.UpdatedAt = $Object.updated_at
$this.SuspendedAt = $Object.suspended_at
$this.SuspendedBy = [GitHubUser]::new($Object.suspended_by)
$this.Url = "https://$HostName/$($Type.ToLower())s/$Target/settings/installations/$($Object.id)"
$this.Url = "https://$($Context.HostName)/$($Type.ToLower())s/$Target/settings/installations/$($Object.id)"
}
}
4 changes: 2 additions & 2 deletions src/classes/public/Artifacts/GitHubArtifact.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

GitHubArtifact() {}

GitHubArtifact([PSCustomObject]$Object, [string]$Owner, [string]$Repository, [string]$HostName) {
GitHubArtifact([PSCustomObject]$Object, [string]$Owner, [string]$Repository, [GitHubContext]$Context) {
$this.ID = $Object.id
$this.NodeID = $Object.node_id
$this.Name = $Object.name
$this.Owner = $Owner
$this.Repository = $Repository
$this.Size = $Object.size_in_bytes
$this.Url = "https://$($HostName)/$Owner/$Repository/actions/runs/$($Object.workflow_run.id)/artifacts/$($Object.id)"
$this.Url = "https://$($Context.HostName)/$Owner/$Repository/actions/runs/$($Object.workflow_run.id)/artifacts/$($Object.id)"
$this.ArchiveDownloadUrl = $Object.archive_download_url
$this.Expired = $Object.expired
$this.Digest = $Object.digest
Expand Down
3 changes: 2 additions & 1 deletion src/classes/public/Environment/GitHubEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

GitHubEnvironment() {}

GitHubEnvironment([PSCustomObject]$Object, [string]$Owner, [string]$Repository) {
GitHubEnvironment([PSCustomObject]$Object, [string]$Owner, [string]$Repository, [GitHubContext]$Context) {
$this.ID = $Object.id
$this.NodeID = $Object.node_id
$this.Name = $Object.name
$this.Owner = $Owner
$this.Repository = $Repository
$this.Url = "https://$($Context.HostName)/$Owner/$Repository/settings/environments/$($Object.id)/edit"
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.AdminsCanBypass = $Object.can_admins_bypass
Expand Down
53 changes: 9 additions & 44 deletions src/classes/public/Owner/GitHubOwner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,17 @@
# Example: User
[string] $Type

# The company the account is affiliated with.
# Example: GitHub
[string] $Company

# The blog URL of the account.
# Example: https://github.com/blog
[string] $Blog

# The location of the account.
# Example: San Francisco
[string] $Location

# The email of the account.
# Example: octocat@github.com
[string] $Email

# The Twitter username.
# Example: monalisa
[string] $TwitterUsername

# The number of public repositories.
# Example: 2
[System.Nullable[uint]] $PublicRepos
# The description of the organization.
# Example: A great organization
[string] $Description

# The number of public gists.
# Example: 1
[System.Nullable[uint]] $PublicGists

# The number of followers.
# Example: 20
[System.Nullable[uint]] $Followers

# The number of accounts this account is following.
# Example: 0
[System.Nullable[uint]] $Following
# The website URL of the account.
# Example: https://github.com/blog
[string] $Website

# The creation date of the account.
# Example: 2008-01-14T04:33:35Z
Expand All @@ -63,10 +39,6 @@
# Example: 2008-01-14T04:33:35Z
[System.Nullable[datetime]] $UpdatedAt

# The user's plan.
# Includes: Name, Collaborators, PrivateRepos, Space
[GitHubPlan] $Plan

GitHubOwner() {}

GitHubOwner([PSCustomObject]$Object) {
Expand All @@ -78,20 +50,13 @@
$this.Name = $Object.slug ?? $Object.login
$this.DisplayName = $Object.name
$this.AvatarUrl = $Object.avatar_url
$this.Url = $Object.html_url
$this.Url = $Object.html_url ?? $Object.url
$this.Type = $Object.type
$this.Company = $Object.company
$this.Blog = $Object.website_url ?? $Object.blog
$this.Location = $Object.location
$this.Email = $Object.email
$this.TwitterUsername = $Object.twitter_username
$this.PublicRepos = $Object.public_repos
$this.PublicGists = $Object.public_gists
$this.Followers = $Object.followers
$this.Following = $Object.following
$this.Description = $Object.description ?? $Object.bio
$this.Website = $Object.websiteUrl ?? $Object.blog
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.Plan = [GitHubPlan]::New($Object.plan)
}

[string] ToString() {
Expand Down
39 changes: 18 additions & 21 deletions src/classes/public/Owner/GitHubOwner/GitHubEnterprise.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
class GitHubEnterprise : GitHubOwner {
# The description of the enterprise.
# Example: A great enterprise
[string] $Description

# The description of the enterprise, as HTML.
# Example: <div>A great enterprise</div>
[string] $DescriptionHTML

# The billing information for the organization.
[GitHubBillingInfo] $BillingInfo

# The billing email address for the organization.
# Example: org@example.com
[string] $BillingEmail

# The readme of the enterprise.
# Example: This is the readme for the enterprise
[string] $Readme
Expand All @@ -22,6 +7,22 @@
# Example: <p>This is the readme for the enterprise</p>
[string] $ReadmeHTML

static [hashtable] $PropertyToGraphQLMap = @{
ID = 'databaseId'
NodeID = 'id'
Name = 'slug'
DisplayName = 'name'
AvatarUrl = 'avatarUrl'
Url = 'url'
Website = 'websiteUrl'
Location = 'location'
CreatedAt = 'createdAt'
UpdatedAt = 'updatedAt'
Description = 'description'
Readme = 'readme'
ReadmeHTML = 'readmeHTML'
}

GitHubEnterprise() {}

GitHubEnterprise([PSCustomObject] $Object) {
Expand All @@ -35,17 +36,13 @@
$this.AvatarUrl = $Object.avatarUrl
$this.Url = $Object.url
$this.Type = $Object.type ?? 'Enterprise'
$this.Company = $Object.company
$this.Blog = $Object.websiteUrl
$this.Location = $Object.location
$this.Description = $Object.description
$this.Website = $Object.websiteUrl
$this.CreatedAt = $Object.createdAt
$this.UpdatedAt = $Object.updatedAt

# From GitHubEnterprise
$this.Description = $Object.description
$this.DescriptionHTML = $Object.descriptionHTML
$this.BillingEmail = $Object.billingEmail
$this.BillingInfo = [GitHubBillingInfo]::new($Object.billingInfo)
$this.Readme = $Object.readme
$this.ReadmeHTML = $Object.readmeHTML
}
Expand Down
92 changes: 68 additions & 24 deletions src/classes/public/Owner/GitHubOwner/GitHubOrganization.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
class GitHubOrganization : GitHubOwner {
# The description of the organization.
# Example: A great organization
[string] $Description
# The email of the account.
# Example: octocat@github.com
[string] $Email

# The Twitter username.
# Example: monalisa
[string] $TwitterUsername

# The user's plan.
# Includes: Name, Collaborators, PrivateRepos, Space
[GitHubPlan] $Plan

# The number of public repositories.
# Example: 2
[System.Nullable[uint]] $PublicRepos

# The number of public gists.
# Example: 1
[System.Nullable[uint]] $PublicGists

# The number of followers.
# Example: 20
[System.Nullable[uint]] $Followers

# The number of accounts this account is following.
# Example: 0
[System.Nullable[uint]] $Following

# The number of private gists.
# Example: 81
Expand Down Expand Up @@ -49,7 +73,7 @@

# Whether two-factor authentication is required for members.
# Example: $true
[System.Nullable[bool]] $TwoFactorRequirementEnabled
[System.Nullable[bool]] $RequiresTwoFactorAuthentication

# The type of repositories members can create.
# Example: all
Expand Down Expand Up @@ -134,54 +158,74 @@
# The date and time when the organization was archived, if applicable.
[System.Nullable[datetime]] $ArchivedAt

static [hashtable] $PropertyToGraphQLMap = @{
ArchivedAt = 'archivedAt'
AvatarUrl = 'avatarUrl'
CreatedAt = 'createdAt'
Description = 'description'
DisplayName = 'name'
Email = 'email'
ID = 'databaseId'
Location = 'location'
Name = 'login'
NodeID = 'id'
IsVerified = 'isVerified'
# MembersCanForkPrivateRepositories = 'membersCanForkPrivateRepositories'
# RequiresTwoFactorAuthentication = 'requiresTwoFactorAuthentication'
TwitterUsername = 'twitterUsername'
UpdatedAt = 'updatedAt'
Url = 'url'
# RequireWebCommitSignoff = 'webCommitSignoffRequired'
Website = 'websiteUrl'
}

GitHubOrganization() {}

GitHubOrganization([PSCustomObject] $Object, [string] $HostName) {
GitHubOrganization([PSCustomObject] $Object, [GitHubContext] $Context) {
# From GitHubNode
$this.ID = $Object.id
$this.NodeID = $Object.node_id
$this.ID = $Object.databaseId ?? $Object.id
$this.NodeID = $Object.node_id ?? $Object.id

# From GitHubOwner
$this.Name = $Object.login
$this.DisplayName = $Object.name
$this.AvatarUrl = $Object.avatar_url
$this.Url = $Object.html_url ?? "https://$($HostName)/$($Object.login)"
$this.Type = $Object.type
$this.Company = $Object.company
$this.Blog = $Object.blog
$this.AvatarUrl = $Object.avatar_url ?? $Object.avatarUrl
$this.Url = $Object.html_url ?? $Object.url ?? "https://$($Context.HostName)/$($Object.login)"
$this.Type = $Object.type ?? 'Organization'
$this.Location = $Object.location
$this.Description = $Object.description
$this.Website = $Object.website ?? $Object.blog
$this.CreatedAt = $Object.created_at ?? $Object.createdAt
$this.UpdatedAt = $Object.updated_at ?? $Object.updatedAt

# From GitHubOrganization
$this.Email = $Object.email
$this.TwitterUsername = $Object.twitter_username
$this.TwitterUsername = $Object.twitter_username ?? $Object.twitterUsername
$this.Plan = [GitHubPlan]::New($Object.plan)
$this.PublicRepos = $Object.public_repos
$this.PublicGists = $Object.public_gists
$this.Followers = $Object.followers
$this.Following = $Object.following
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.Plan = [GitHubPlan]::New($Object.plan)

# From GitHubOrganization
$this.Description = $Object.description
$this.PrivateGists = $Object.total_private_gists
$this.TotalPrivateRepos = $Object.total_private_repos
$this.OwnedPrivateRepos = $Object.owned_private_repos
$this.DiskUsage = $Object.disk_usage
$this.Collaborators = $Object.collaborators
$this.IsVerified = $Object.is_verified
$this.IsVerified = $Object.is_verified ?? $Object.isVerified
$this.HasOrganizationProjects = $Object.has_organization_projects
$this.HasRepositoryProjects = $Object.has_repository_projects
$this.BillingEmail = $Object.billing_email
$this.DefaultRepositoryPermission = $Object.default_repository_permission
$this.MembersCanCreateRepositories = $Object.members_can_create_repositories
$this.TwoFactorRequirementEnabled = $Object.two_factor_requirement_enabled
$this.RequiresTwoFactorAuthentication = $Object.two_factor_requirement_enabled ?? $Object.requiresTwoFactorAuthentication
$this.MembersAllowedRepositoryCreationType = $Object.members_allowed_repository_creation_type
$this.MembersCanCreatePublicRepositories = $Object.members_can_create_public_repositories
$this.MembersCanCreatePrivateRepositories = $Object.members_can_create_private_repositories
$this.MembersCanCreateInternalRepositories = $Object.members_can_create_internal_repositories
$this.MembersCanInviteCollaborators = $Object.members_can_invite_collaborators
$this.MembersCanCreatePages = $Object.members_can_create_pages
$this.MembersCanForkPrivateRepositories = $Object.members_can_fork_private_repositories
$this.RequireWebCommitSignoff = $Object.web_commit_signoff_required
$this.MembersCanForkPrivateRepositories = $Object.members_can_fork_private_repositories ?? $Object.membersCanForkPrivateRepositories
$this.RequireWebCommitSignoff = $Object.web_commit_signoff_required ?? $Object.requiresTwoFactorAuthentication
$this.DeployKeysEnabledForRepositories = $Object.deploy_keys_enabled_for_repositories
$this.MembersCanCreatePublicPages = $Object.members_can_create_public_pages
$this.MembersCanCreatePrivatePages = $Object.members_can_create_private_pages
Expand All @@ -194,7 +238,7 @@
$this.SecretScanningPushProtectionCustomLinkEnabled = $Object.secret_scanning_push_protection_custom_link_enabled
$this.SecretScanningPushProtectionCustomLink = $Object.secret_scanning_push_protection_custom_link
$this.SecretScanningValidityChecksEnabled = $Object.secret_scanning_validity_checks_enabled
$this.ArchivedAt = $Object.archived_at
$this.ArchivedAt = $Object.archived_at ?? $Object.archivedAt
}

[string] ToString() {
Expand Down
Loading