Skip to content

Commit ca9d6f7

Browse files
🩹 [Patch]: Remove status function for Australia region (migrated to new reporting type) (#548)
Removes the obsolete Australia region from GitHub Status functions and centralizes stamp definitions into a single `$script:GitHub.Stamps` property. A new `Get-GitHubStamp` function provides a public API for listing and retrieving available stamps, and all status functions now use it as their single source of truth. - Fixes #545 ## Removed Australia region The Australia status page (`https://au.githubstatus.com`) has been migrated to a new reporting type and is no longer available through the GitHub Status API. All status functions have been updated to remove Australia from the available stamps. ## Centralized stamp definitions Stamp definitions have been moved from a standalone `$script:StatusBaseURL` hashtable into the `$script:GitHub.Stamps` property, making them part of the main module configuration object. This provides a single source of truth for all stamp-related logic across functions, completers, and tests. ## New `Get-GitHubStamp` function A new public function `Get-GitHubStamp` exposes the available stamps: ```powershell # List all available stamps Get-GitHubStamp # Get a specific stamp by name Get-GitHubStamp -Name 'Europe' ``` ## Parameter changes The `-Stamp` parameter has been renamed to `-Name` across all status functions for consistency. The original `-Stamp` name remains available as an alias for backward compatibility: ```powershell # Both of these work Get-GitHubStatus -Name 'Europe' Get-GitHubStatus -Stamp 'Europe' # Alias, still supported ``` ## Tab-completion Status functions now support tab-completion for the `-Name` parameter via a registered argument completer that reads from `Get-GitHubStamp`, so completion options stay in sync with the defined stamps automatically. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com> Co-authored-by: Marius Storhaug <marstor@hotmail.com>
1 parent 3dbdfc3 commit ca9d6f7

12 files changed

Lines changed: 186 additions & 48 deletions

‎.github/PSModule.yml‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
Test:
66
CodeCoverage:
77
PercentTarget: 50
8-
# TestResults:
9-
# Skip: true
10-
# SourceCode:
11-
# Skip: true
12-
# PSModule:
13-
# Skip: true
14-
# Module:
15-
# Windows:
16-
# Skip: true
17-
# MacOS:
18-
# Skip: true
8+
# Skip: true
9+
# TestResults:
10+
# Skip: true
11+
# SourceCode:
12+
# Skip: true
13+
# PSModule:
14+
# Skip: true
15+
# Module:
16+
# Skip: true
17+
# Windows:
18+
# Skip: true
19+
# MacOS:
20+
# Skip: true
1921
# Build:
2022
# Docs:
2123
# Skip: true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class GitHubStamp {
2+
# The name of the stamp (region).
3+
# Example: 'Public'
4+
[string] $Name
5+
6+
# The base URL of the status page for this stamp.
7+
# Example: 'https://www.githubstatus.com'
8+
[string] $BaseUrl
9+
10+
GitHubStamp() {}
11+
12+
GitHubStamp([string]$Name, [string]$BaseUrl) {
13+
$this.Name = $Name
14+
$this.BaseUrl = $BaseUrl
15+
}
16+
17+
[string] ToString() {
18+
return $this.Name
19+
}
20+
}

‎src/functions/public/Config/Get-GitHubConfig.ps1‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
1414
Get the DefaultContext value from the GitHub module configuration.
1515
16-
17-
1816
.LINK
1917
https://psmodule.io/GitHub/Functions/Config/Get-GitHubConfig
2018
#>

‎src/functions/public/Status/Get-GitHubScheduledMaintenance.ps1‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454

5555
# The stamp to check status for.
5656
[Parameter()]
57-
[ValidateSet('Public', 'Europe', 'Australia', 'US')]
58-
[string] $Stamp = 'Public'
57+
[Alias('Stamp')]
58+
[string] $Name = 'Public'
5959
)
6060

6161
begin {
@@ -64,7 +64,8 @@
6464
}
6565

6666
process {
67-
$baseURL = $script:StatusBaseURL[$Stamp]
67+
$stamp = Get-GitHubStamp -Name $Name
68+
$baseURL = $stamp.BaseUrl
6869

6970
if ($Active) {
7071
$APIURI = "$baseURL/api/v2/scheduled-maintenances/active.json"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
function Get-GitHubStamp {
2+
<#
3+
.SYNOPSIS
4+
Gets the available GitHub Status page stamps (regions).
5+
6+
.DESCRIPTION
7+
Returns the available GitHub Status page stamps, which represent different regional status pages.
8+
Each stamp includes the name and base URL of the status page.
9+
10+
.EXAMPLE
11+
```powershell
12+
Get-GitHubStamp
13+
```
14+
15+
Gets all available GitHub Status page stamps.
16+
17+
.EXAMPLE
18+
```powershell
19+
Get-GitHubStamp -Name 'Europe'
20+
```
21+
22+
Gets the GitHub Status page stamp for 'Europe'.
23+
24+
.NOTES
25+
[GitHub Status API](https://www.githubstatus.com/api)
26+
27+
.LINK
28+
https://psmodule.io/GitHub/Functions/Status/Get-GitHubStamp
29+
#>
30+
[OutputType([GitHubStamp[]])]
31+
[CmdletBinding()]
32+
param(
33+
# The name of the stamp to get. If not specified, all stamps are returned.
34+
[Parameter()]
35+
[ValidateNotNullOrEmpty()]
36+
[Alias('Stamp')]
37+
[string] $Name
38+
)
39+
40+
begin {
41+
$stackPath = Get-PSCallStackPath
42+
Write-Debug "[$stackPath] - Start"
43+
}
44+
45+
process {
46+
if ([string]::IsNullOrEmpty($Name)) {
47+
$script:GitHub.Stamps
48+
return
49+
}
50+
51+
$stamp = $script:GitHub.Stamps | Where-Object { $_.Name -eq $Name }
52+
if (-not $stamp) {
53+
$available = $script:GitHub.Stamps.Name -join ', '
54+
throw "Stamp '$Name' not found. Available stamps: $available"
55+
}
56+
$stamp
57+
}
58+
59+
end {
60+
Write-Debug "[$stackPath] - End"
61+
}
62+
}

‎src/functions/public/Status/Get-GitHubStatus.ps1‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242

4343
# The stamp to check status for.
4444
[Parameter()]
45-
[ValidateSet('Public', 'Europe', 'Australia', 'US')]
46-
[string] $Stamp = 'Public'
45+
[Alias('Stamp')]
46+
[string] $Name = 'Public'
4747
)
4848
begin {
4949
$stackPath = Get-PSCallStackPath
5050
Write-Debug "[$stackPath] - Start"
5151
}
5252

5353
process {
54-
$baseURL = $script:StatusBaseURL[$Stamp]
54+
$baseURL = (Get-GitHubStamp -Name $Name).BaseUrl
5555

5656
if ($Summary) {
5757
$APIURI = "$baseURL/api/v2/summary.json"

‎src/functions/public/Status/Get-GitHubStatusComponent.ps1‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
param(
2727
# The stamp to check status for.
2828
[Parameter()]
29-
[ValidateSet('Public', 'Europe', 'Australia', 'US')]
30-
[string] $Stamp = 'Public'
29+
[Alias('Stamp')]
30+
[string] $Name = 'Public'
3131
)
3232

3333
begin {
@@ -36,7 +36,7 @@
3636
}
3737

3838
process {
39-
$baseURL = $script:StatusBaseURL[$Stamp]
39+
$baseURL = (Get-GitHubStamp -Name $Name).BaseUrl
4040

4141
$APIURI = "$baseURL/api/v2/components.json"
4242
$response = Invoke-RestMethod -Uri $APIURI -Method Get

‎src/functions/public/Status/Get-GitHubStatusIncident.ps1‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141

4242
# The stamp to check status for.
4343
[Parameter()]
44-
[ValidateSet('Public', 'Europe', 'Australia', 'US')]
45-
[string] $Stamp = 'Public'
44+
[Alias('Stamp')]
45+
[string] $Name = 'Public'
4646
)
4747

4848
begin {
@@ -51,7 +51,7 @@
5151
}
5252

5353
process {
54-
$baseURL = $script:StatusBaseURL[$Stamp]
54+
$baseURL = (Get-GitHubStamp -Name $Name).BaseUrl
5555

5656
if ($Unresolved) {
5757
$APIURI = "$baseURL/api/v2/incidents/unresolved.json"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Register-ArgumentCompleter -CommandName @(
2+
'Get-GitHubScheduledMaintenance'
3+
'Get-GitHubStamp'
4+
'Get-GitHubStatus'
5+
'Get-GitHubStatusComponent'
6+
'Get-GitHubStatusIncident'
7+
) -ParameterName Name -ScriptBlock {
8+
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
9+
$null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters
10+
11+
$stamps = Get-GitHubStamp
12+
if (-not $stamps) {
13+
return $null
14+
}
15+
16+
$pattern = switch (Get-GitHubConfig -Name CompletionMode) { 'Contains' { "*$wordToComplete*" } default { "$wordToComplete*" } }
17+
$filteredOptions = $stamps | Where-Object { $_.Name -like $pattern }
18+
19+
if (-not $filteredOptions) {
20+
return $null
21+
}
22+
23+
$filteredOptions | ForEach-Object {
24+
[System.Management.Automation.CompletionResult]::new($_.Name, $_.Name, 'ParameterValue', $_.Name)
25+
}
26+
}

‎src/variables/private/GitHub.ps1‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ $script:GitHub = [pscustomobject]@{
2323
Config = $null
2424
Event = $null
2525
Runner = $null
26+
Stamps = @(
27+
[GitHubStamp]::new('Public', 'https://www.githubstatus.com')
28+
[GitHubStamp]::new('Europe', 'https://eu.githubstatus.com')
29+
[GitHubStamp]::new('US', 'https://us.githubstatus.com')
30+
)
2631
}

0 commit comments

Comments
 (0)