diff --git a/Coverage.md b/Coverage.md index e65516446..27405ffa0 100644 --- a/Coverage.md +++ b/Coverage.md @@ -5,7 +5,7 @@ - + @@ -13,11 +13,11 @@ - + - +
Available functions992998
Covered functions
Missing functions833839
Coverage16.03%15.93%
@@ -218,6 +218,9 @@ | `/orgs/{org}/personal-access-tokens` | | :x: | | :x: | | | `/orgs/{org}/personal-access-tokens/{pat_id}` | | | | :x: | | | `/orgs/{org}/personal-access-tokens/{pat_id}/repositories` | | :x: | | | | +| `/orgs/{org}/private-registries` | | :x: | | :x: | | +| `/orgs/{org}/private-registries/public-key` | | :x: | | | | +| `/orgs/{org}/private-registries/{secret_name}` | :x: | :x: | :x: | | | | `/orgs/{org}/projects` | | :x: | | :x: | | | `/orgs/{org}/properties/schema` | | :x: | :x: | | | | `/orgs/{org}/properties/schema/{custom_property_name}` | :x: | :x: | | | :x: | diff --git a/src/classes/public/Webhooks/GitHubWebhook.ps1 b/src/classes/public/Webhooks/GitHubWebhook.ps1 new file mode 100644 index 000000000..8b2a7cf7a --- /dev/null +++ b/src/classes/public/Webhooks/GitHubWebhook.ps1 @@ -0,0 +1,63 @@ +class GitHubWebhook { + # Unique identifier of the delivery. + [uint64] $ID + + # Unique identifier for the event (shared with all deliveries for all webhooks that subscribe to this event). + [string] $GUID + + # Time when the delivery was delivered. + [Nullable[datetime]] $DeliveredAt + + # Whether the delivery is a redelivery. + [Nullable[boolean]] $Redelivery + + # Time spent delivering, in seconds. + [Nullable[double]] $Duration + + # Description of the status of the attempted delivery + [string] $Status + + # Status code received when delivery was made. + [uint16] $StatusCode + + # The event that triggered the delivery. + [string] $Event + + # The type of activity for the event that triggered the delivery. + [string] $Action + + # The id of the GitHub App installation associated with this event. + [Nullable[uint64]] $InstallationID + + # The id of the repository associated with this event. + [Nullable[uint64]] $RepositoryID + + # Time when the webhook delivery was throttled. + [Nullable[datetime]] $ThrottledAt + + # The URL target of the delivery. + [string] $URL + + # The request for the delivery. + [object] $Request + + # The response from the delivery. + [object] $Response + + # Simple parameterless constructor + GitHubWebhook() {} + + # Creates a context object from a hashtable of key-vaule pairs. + GitHubWebhook([hashtable]$Properties) { + foreach ($Property in $Properties.Keys) { + $this.$Property = $Properties.$Property + } + } + + # Creates a context object from a PSCustomObject. + GitHubWebhook([PSCustomObject]$Object) { + $Object.PSObject.Properties | ForEach-Object { + $this.($_.Name) = $_.Value + } + } +} diff --git a/src/formats/GitHubWebhook.format.ps1xml b/src/formats/GitHubWebhook.format.ps1xml new file mode 100644 index 000000000..c5b96100e --- /dev/null +++ b/src/formats/GitHubWebhook.format.ps1xml @@ -0,0 +1,135 @@ + + + + + + GitHubWebhookTable + + GitHubWebhook + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if ($_.Status -eq 'ok') { + [char]0x2705 + [char]0x200B + } else { + [char]0x274C + [char]0x200B + } + + + + + + + if ($_.Redelivery -eq 'true') { + "`u{1F504}" + } + + + + ID + + + GUID + + + Event + + + StatusCode + + + DeliveredAt + + + Duration + + + + + + + + + + GitHubWebhookList + + GitHubWebhook + + + + + + + + ID + + + + GUID + + + + DeliveredAt + + + + Redelivery + + + + Duration + + + + Status + + + + StatusCode + + + + Event + + + + Action + + + + + + + + diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 index 9d0d0be35..6b6e77462 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -18,6 +18,7 @@ .NOTES [Get a delivery for an app webhook](https://docs.github.com/rest/apps/webhooks#get-a-delivery-for-an-app-webhook) #> + [OutputType([GitHubWebhook])] [CmdletBinding()] param( # The ID of the delivery. @@ -47,7 +48,25 @@ } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + [GitHubWebhook]( + @{ + ID = $_.id + GUID = $_.guid + DeliveredAt = $_.delivered_at + Redelivery = $_.redelivery + Duration = $_.duration + Status = $_.status + StatusCode = $_.status_code + Event = $_.event + Action = $_.action + InstallationID = $_.installation.id + RepositoryID = $_.repository.id + ThrottledAt = $_.throttled_at + URL = $_.url + Request = $_.request + Response = $_.response + } + ) } } catch { throw $_ diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 index 9aea3c270..1be9aff19 100644 --- a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -15,10 +15,16 @@ 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) + [List deliveries for an app webhook](https://docs.github.com/rest/apps/webhooks#list-deliveries-for-an-app-webhook) #> + [OutputType([GitHubWebhook[]])] [CmdletBinding()] param( + # The number of results per page (max 100). + [Parameter()] + [ValidateRange(0, 100)] + [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()] @@ -34,14 +40,39 @@ process { try { + $body = @{ + per_page = $PerPage + } + $inputObject = @{ Context = $Context APIEndpoint = '/app/hook/deliveries' Method = 'GET' + Body = $body } Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + $_.Response | ForEach-Object { + [GitHubWebhook]( + @{ + ID = $_.id + GUID = $_.guid + DeliveredAt = $_.delivered_at + Redelivery = $_.redelivery + Duration = $_.duration + Status = $_.status + StatusCode = $_.status_code + Event = $_.event + Action = $_.action + InstallationID = $_.installation.id + RepositoryID = $_.repository.id + ThrottledAt = $_.throttled_at + URL = $_.url + Request = $_.request + Response = $_.response + } + ) + } } } catch { throw $_ diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 index 8b8518977..e4719a71b 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 @@ -23,6 +23,7 @@ [Get a delivery for an app webhook](https://docs.github.com/rest/apps/webhooks#get-a-delivery-for-an-app-webhook) [Get a webhook configuration for an app](https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app) #> + [OutputType([GitHubWebhook[]])] [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( # The ID of the delivery. diff --git a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 index a540209fc..4c4bea32f 100644 --- a/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 +++ b/src/functions/public/Repositories/Repositories/Get-GitHubRepositoryActivity.ps1 @@ -66,7 +66,6 @@ [string] $Direction = 'desc', # The number of results per page (max 100). - # Default: 30 [Parameter()] [ValidateRange(0, 100)] [int] $PerPage,