From 2082d6e36bd2f059fd5bdff679b846b96d6f530e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 5 Oct 2023 00:22:33 +0200 Subject: [PATCH 1/2] Added get status functions --- .../Status/Get-GitHubScheduledMaintenance.ps1 | 64 +++++++++++++++++++ src/GitHub/public/Status/Get-GitHubStatus.ps1 | 41 ++++++++++++ .../Status/Get-GitHubStatusComponents.ps1 | 24 +++++++ .../Status/Get-GitHubStatusIncidents.ps1 | 46 +++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 src/GitHub/public/Status/Get-GitHubScheduledMaintenance.ps1 create mode 100644 src/GitHub/public/Status/Get-GitHubStatus.ps1 create mode 100644 src/GitHub/public/Status/Get-GitHubStatusComponents.ps1 create mode 100644 src/GitHub/public/Status/Get-GitHubStatusIncidents.ps1 diff --git a/src/GitHub/public/Status/Get-GitHubScheduledMaintenance.ps1 b/src/GitHub/public/Status/Get-GitHubScheduledMaintenance.ps1 new file mode 100644 index 000000000..df8338ed3 --- /dev/null +++ b/src/GitHub/public/Status/Get-GitHubScheduledMaintenance.ps1 @@ -0,0 +1,64 @@ +function Get-GitHubScheduledMaintenance { + <# + .SYNOPSIS + Gets the status of GitHub scheduled maintenance + + .DESCRIPTION + Scheduled maintenances are planned outages, upgrades, or general notices that you're working + on infrastructure and disruptions may occurr. A close sibling of Incidents, each usually goes + through a progression of statuses listed below, with an impact calculated from a blend of + component statuses (or an optional override). + + Status: Scheduled, In Progress, Verifying, or Completed + Impact: None (black), Minor (yellow), Major (orange), or Critical (red) + + .EXAMPLE + Get-GitHubScheduledMaintenance + + Get a list of the 50 most recent scheduled maintenances. + This includes scheduled maintenances as described in the above two endpoints, as well as those in the Completed state. + + .EXAMPLE + Get-GitHubScheduledMaintenance -Active + + Get a list of any active maintenances. + + .EXAMPLE + Get-GitHubScheduledMaintenance -Upcoming + + Get a list of any upcoming maintenances. + + .NOTES + https://www.githubstatus.com/api#scheduled-maintenances + #> + param( + # Get a list of any active maintenances. + # This endpoint will only return scheduled maintenances in the In Progress or Verifying state. + [Parameter()] + [switch] $Active, + + # Get a list of any upcoming maintenances. + # This endpoint will only return scheduled maintenances still in the Scheduled state. + [Parameter()] + [switch] $Upcoming + ) + + if ($Active) { + $APIURI = 'https://www.githubstatus.com/api/v2/scheduled-maintenances/active.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.scheduled_maintenances + return + } + + if ($Upcoming) { + $APIURI = 'https://www.githubstatus.com/api/v2/scheduled-maintenances/upcoming.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.scheduled_maintenances + return + } + + $APIURI = 'https://www.githubstatus.com/api/v2/scheduled-maintenances.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.scheduled_maintenances + +} diff --git a/src/GitHub/public/Status/Get-GitHubStatus.ps1 b/src/GitHub/public/Status/Get-GitHubStatus.ps1 new file mode 100644 index 000000000..c4d0ffcd7 --- /dev/null +++ b/src/GitHub/public/Status/Get-GitHubStatus.ps1 @@ -0,0 +1,41 @@ +function Get-GitHubStatus { + <# + .SYNOPSIS + Gets the status of GitHub services + + .DESCRIPTION + Get a summary of the status page, including a status indicator, component statuses, unresolved incidents, and any upcoming or in-progress scheduled maintenances. + Get the status rollup for the whole page. This endpoint includes an indicator - one of none, minor, major, or critical, as well as a human description of the blended component status. Examples of the blended status include "All Systems Operational", "Partial System Outage", and "Major Service Outage". + + .EXAMPLE + Get-GitHubStatus + + Gets the status of GitHub services + + .EXAMPLE + Get-GitHubStatus -Summary + + Gets a summary of the status page, including a status indicator, component statuses, unresolved incidents, and any upcoming or in-progress scheduled maintenances. + + .NOTES + https://www.githubstatus.com/api#summary + https://www.githubstatus.com/api#status + #> + [OutputType([pscustomobject])] + [CmdletBinding()] + param( + [switch] $Summary + ) + + if ($Summary) { + $APIURI = 'https://www.githubstatus.com/api/v2/summary.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response + return + } + + $APIURI = 'https://www.githubstatus.com/api/v2/status.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.status + +} diff --git a/src/GitHub/public/Status/Get-GitHubStatusComponents.ps1 b/src/GitHub/public/Status/Get-GitHubStatusComponents.ps1 new file mode 100644 index 000000000..9da591488 --- /dev/null +++ b/src/GitHub/public/Status/Get-GitHubStatusComponents.ps1 @@ -0,0 +1,24 @@ +function Get-GitHubStatusComponents { + <# + .SYNOPSIS + Gets the status of GitHub components + + .DESCRIPTION + Get the components for the page. Each component is listed along with its status - one of operational, degraded_performance, partial_outage, or major_outage. + + .EXAMPLE + Get-GitHubStatusComponents + + Gets the status of GitHub components + + .NOTES + https://www.githubstatus.com/api#components + #> + [OutputType([pscustomobject[]])] + [CmdletBinding()] + param() + + $APIURI = 'https://www.githubstatus.com/api/v2/components.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.components +} diff --git a/src/GitHub/public/Status/Get-GitHubStatusIncidents.ps1 b/src/GitHub/public/Status/Get-GitHubStatusIncidents.ps1 new file mode 100644 index 000000000..3c5a5bf2f --- /dev/null +++ b/src/GitHub/public/Status/Get-GitHubStatusIncidents.ps1 @@ -0,0 +1,46 @@ +function Get-GitHubStatusIncidents { + <# + .SYNOPSIS + Gets the status of GitHub incidents + + .DESCRIPTION + Incidents are the cornerstone of any status page, being composed of many incident updates. + Each incident usually goes through a progression of statuses listed below, with an impact + calculated from a blend of component statuses (or an optional override). + + Status: Investigating, Identified, Monitoring, Resolved, or Postmortem + Impact: None (black), Minor (yellow), Major (orange), or Critical (red) + + .EXAMPLE + Get-GitHubStatusIncidents + + Gets the status of GitHub incidents + + .EXAMPLE + Get-GitHubStatusIncidents -Unresolved + + Gets the status of GitHub incidents that are unresolved + + .NOTES + https://www.githubstatus.com/api#incidents + #> + [OutputType([pscustomobject[]])] + [CmdletBinding()] + param( + # Gets the status of GitHub incidents that are unresolved + [Parameter()] + [switch] $Unresolved + ) + + if ($Unresolved) { + $APIURI = 'https://www.githubstatus.com/api/v2/incidents/unresolved.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.incidents + return + } + + $APIURI = 'https://www.githubstatus.com/api/v2/incidents.json' + $response = Invoke-RestMethod -Uri $APIURI -Method Get + $response.incidents + +} From 154210b4431d12e8af00f9dad4b13324202db354 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 5 Oct 2023 00:28:34 +0200 Subject: [PATCH 2/2] fix --- src/GitHub/public/Status/Get-GitHubStatus.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/GitHub/public/Status/Get-GitHubStatus.ps1 b/src/GitHub/public/Status/Get-GitHubStatus.ps1 index c4d0ffcd7..9b7f0e1d7 100644 --- a/src/GitHub/public/Status/Get-GitHubStatus.ps1 +++ b/src/GitHub/public/Status/Get-GitHubStatus.ps1 @@ -24,6 +24,8 @@ [OutputType([pscustomobject])] [CmdletBinding()] param( + # Gets a summary of the status page, including a status indicator, component statuses, unresolved incidents, and any upcoming or in-progress scheduled maintenances. + [Parameter()] [switch] $Summary )