Skip to content

Commit 2589fa4

Browse files
[Feature] GitHub Status - Get status info about the GitHub services (#45)
- Fixes #27
1 parent 4dd9c4f commit 2589fa4

File tree

4 files changed

+177
-0
lines changed

4 files changed

+177
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
function Get-GitHubScheduledMaintenance {
2+
<#
3+
.SYNOPSIS
4+
Gets the status of GitHub scheduled maintenance
5+
6+
.DESCRIPTION
7+
Scheduled maintenances are planned outages, upgrades, or general notices that you're working
8+
on infrastructure and disruptions may occurr. A close sibling of Incidents, each usually goes
9+
through a progression of statuses listed below, with an impact calculated from a blend of
10+
component statuses (or an optional override).
11+
12+
Status: Scheduled, In Progress, Verifying, or Completed
13+
Impact: None (black), Minor (yellow), Major (orange), or Critical (red)
14+
15+
.EXAMPLE
16+
Get-GitHubScheduledMaintenance
17+
18+
Get a list of the 50 most recent scheduled maintenances.
19+
This includes scheduled maintenances as described in the above two endpoints, as well as those in the Completed state.
20+
21+
.EXAMPLE
22+
Get-GitHubScheduledMaintenance -Active
23+
24+
Get a list of any active maintenances.
25+
26+
.EXAMPLE
27+
Get-GitHubScheduledMaintenance -Upcoming
28+
29+
Get a list of any upcoming maintenances.
30+
31+
.NOTES
32+
https://www.githubstatus.com/api#scheduled-maintenances
33+
#>
34+
param(
35+
# Get a list of any active maintenances.
36+
# This endpoint will only return scheduled maintenances in the In Progress or Verifying state.
37+
[Parameter()]
38+
[switch] $Active,
39+
40+
# Get a list of any upcoming maintenances.
41+
# This endpoint will only return scheduled maintenances still in the Scheduled state.
42+
[Parameter()]
43+
[switch] $Upcoming
44+
)
45+
46+
if ($Active) {
47+
$APIURI = 'https://www.githubstatus.com/api/v2/scheduled-maintenances/active.json'
48+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
49+
$response.scheduled_maintenances
50+
return
51+
}
52+
53+
if ($Upcoming) {
54+
$APIURI = 'https://www.githubstatus.com/api/v2/scheduled-maintenances/upcoming.json'
55+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
56+
$response.scheduled_maintenances
57+
return
58+
}
59+
60+
$APIURI = 'https://www.githubstatus.com/api/v2/scheduled-maintenances.json'
61+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
62+
$response.scheduled_maintenances
63+
64+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
function Get-GitHubStatus {
2+
<#
3+
.SYNOPSIS
4+
Gets the status of GitHub services
5+
6+
.DESCRIPTION
7+
Get a summary of the status page, including a status indicator, component statuses, unresolved incidents, and any upcoming or in-progress scheduled maintenances.
8+
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".
9+
10+
.EXAMPLE
11+
Get-GitHubStatus
12+
13+
Gets the status of GitHub services
14+
15+
.EXAMPLE
16+
Get-GitHubStatus -Summary
17+
18+
Gets a summary of the status page, including a status indicator, component statuses, unresolved incidents, and any upcoming or in-progress scheduled maintenances.
19+
20+
.NOTES
21+
https://www.githubstatus.com/api#summary
22+
https://www.githubstatus.com/api#status
23+
#>
24+
[OutputType([pscustomobject])]
25+
[CmdletBinding()]
26+
param(
27+
# Gets a summary of the status page, including a status indicator, component statuses, unresolved incidents, and any upcoming or in-progress scheduled maintenances.
28+
[Parameter()]
29+
[switch] $Summary
30+
)
31+
32+
if ($Summary) {
33+
$APIURI = 'https://www.githubstatus.com/api/v2/summary.json'
34+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
35+
$response
36+
return
37+
}
38+
39+
$APIURI = 'https://www.githubstatus.com/api/v2/status.json'
40+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
41+
$response.status
42+
43+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function Get-GitHubStatusComponents {
2+
<#
3+
.SYNOPSIS
4+
Gets the status of GitHub components
5+
6+
.DESCRIPTION
7+
Get the components for the page. Each component is listed along with its status - one of operational, degraded_performance, partial_outage, or major_outage.
8+
9+
.EXAMPLE
10+
Get-GitHubStatusComponents
11+
12+
Gets the status of GitHub components
13+
14+
.NOTES
15+
https://www.githubstatus.com/api#components
16+
#>
17+
[OutputType([pscustomobject[]])]
18+
[CmdletBinding()]
19+
param()
20+
21+
$APIURI = 'https://www.githubstatus.com/api/v2/components.json'
22+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
23+
$response.components
24+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
function Get-GitHubStatusIncidents {
2+
<#
3+
.SYNOPSIS
4+
Gets the status of GitHub incidents
5+
6+
.DESCRIPTION
7+
Incidents are the cornerstone of any status page, being composed of many incident updates.
8+
Each incident usually goes through a progression of statuses listed below, with an impact
9+
calculated from a blend of component statuses (or an optional override).
10+
11+
Status: Investigating, Identified, Monitoring, Resolved, or Postmortem
12+
Impact: None (black), Minor (yellow), Major (orange), or Critical (red)
13+
14+
.EXAMPLE
15+
Get-GitHubStatusIncidents
16+
17+
Gets the status of GitHub incidents
18+
19+
.EXAMPLE
20+
Get-GitHubStatusIncidents -Unresolved
21+
22+
Gets the status of GitHub incidents that are unresolved
23+
24+
.NOTES
25+
https://www.githubstatus.com/api#incidents
26+
#>
27+
[OutputType([pscustomobject[]])]
28+
[CmdletBinding()]
29+
param(
30+
# Gets the status of GitHub incidents that are unresolved
31+
[Parameter()]
32+
[switch] $Unresolved
33+
)
34+
35+
if ($Unresolved) {
36+
$APIURI = 'https://www.githubstatus.com/api/v2/incidents/unresolved.json'
37+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
38+
$response.incidents
39+
return
40+
}
41+
42+
$APIURI = 'https://www.githubstatus.com/api/v2/incidents.json'
43+
$response = Invoke-RestMethod -Uri $APIURI -Method Get
44+
$response.incidents
45+
46+
}

0 commit comments

Comments
 (0)