Skip to content
9 changes: 6 additions & 3 deletions Coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<table>
<tr>
<td>Available functions</td>
<td>992</td>
<td>998</td>
</tr>
<tr>
<td>Covered functions</td>
<td>159</td>
</tr>
<tr>
<td>Missing functions</td>
<td>833</td>
<td>839</td>
</tr>
<tr>
<td>Coverage</td>
<td>16.03%</td>
<td>15.93%</td>
</tr>
</table>

Expand Down Expand Up @@ -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: |
Expand Down
63 changes: 63 additions & 0 deletions src/classes/public/Webhooks/GitHubWebhook.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}
}
135 changes: 135 additions & 0 deletions src/formats/GitHubWebhook.format.ps1xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<ViewDefinitions>
<!-- Table View -->
<View>
<Name>GitHubWebhookTable</Name>
<ViewSelectedBy>
<TypeName>GitHubWebhook</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>S </Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>R </Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>ID</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>GUID</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Event</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>StatusCode</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>DeliveredAt</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Duration(s)</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<!-- S(tatus) column -->
<TableColumnItem>
<ScriptBlock>
if ($_.Status -eq 'ok') {
[char]0x2705 + [char]0x200B
} else {
[char]0x274C + [char]0x200B
}
</ScriptBlock>
</TableColumnItem>
<!-- R(edeliery) column -->
<TableColumnItem>
<!-- <PropertyName>Redelivery</PropertyName> -->
<ScriptBlock>
if ($_.Redelivery -eq 'true') {
"`u{1F504}"
}
</ScriptBlock>
</TableColumnItem>
<TableColumnItem>
<PropertyName>ID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>GUID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Event</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>StatusCode</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>DeliveredAt</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Duration</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>

<!-- List View -->
<View>
<Name>GitHubWebhookList</Name>
<ViewSelectedBy>
<TypeName>GitHubWebhook</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<Label>ID</Label>
<PropertyName>ID</PropertyName>
</ListItem>
<ListItem>
<Label>GUID</Label>
<PropertyName>GUID</PropertyName>
</ListItem>
<ListItem>
<Label>DeliveredAt</Label>
<PropertyName>DeliveredAt</PropertyName>
</ListItem>
<ListItem>
<Label>Redelivery</Label>
<PropertyName>Redelivery</PropertyName>
</ListItem>
<ListItem>
<Label>Duration (s)</Label>
<PropertyName>Duration</PropertyName>
</ListItem>
<ListItem>
<Label>Status</Label>
<PropertyName>Status</PropertyName>
</ListItem>
<ListItem>
<Label>StatusCode</Label>
<PropertyName>StatusCode</PropertyName>
</ListItem>
<ListItem>
<Label>Event</Label>
<PropertyName>Event</PropertyName>
</ListItem>
<ListItem>
<Label>Action</Label>
<PropertyName>Action</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 $_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand All @@ -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 $_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
[string] $Direction = 'desc',

# The number of results per page (max 100).
# Default: 30
[Parameter()]
[ValidateRange(0, 100)]
[int] $PerPage,
Expand Down