From 52015a58a20ce44cc7f4d604370d37b1d7cb120d Mon Sep 17 00:00:00 2001 From: Sam Hawkins Date: Mon, 17 Feb 2025 14:32:13 +1100 Subject: [PATCH 1/3] bugfix statuspage create incident step template --- .../statuspageio-create-scheduled-maintenance-incident.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/step-templates/statuspageio-create-scheduled-maintenance-incident.json b/step-templates/statuspageio-create-scheduled-maintenance-incident.json index 6874d90b1..f11b16f0b 100644 --- a/step-templates/statuspageio-create-scheduled-maintenance-incident.json +++ b/step-templates/statuspageio-create-scheduled-maintenance-incident.json @@ -8,7 +8,7 @@ "Octopus.Action.Script.Syntax": "PowerShell", "Octopus.Action.Script.ScriptSource": "Inline", "Octopus.Action.RunOnServer": "false", - "Octopus.Action.Script.ScriptBody": "## --------------------------------------------------------------------------------------\r\n## Input\r\n## --------------------------------------------------------------------------------------\r\n$pageId = $OctopusParameters['PageId']\r\n$apiKey = $OctopusParameters['ApiKey']\r\n$incidentName = $OctopusParameters['IncidentName']\r\n$incidentStatus = $OctopusParameters['IncidentStatus']\r\n$incidentMessage = $OctopusParameters['IncidentMessage']\r\n$componentId = $OctopusParameters['ComponentId']\r\n\r\nfunction Validate-Parameter($parameterValue, $parameterName) {\r\n if(!$parameterName -contains \"Key\") {\r\n Write-Host \"${parameterName}: ${parameterValue}\"\r\n }\r\n\r\n if (! $parameterValue) {\r\n throw \"$parameterName cannot be empty, please specify a value\"\r\n }\r\n}\r\n\r\nfunction New-ScheduledIncident\r\n{\r\n [CmdletBinding()]\r\n Param(\r\n [Parameter(Mandatory=$true)]\r\n [string]$PageId,\r\n\r\n [Parameter(Mandatory=$true)]\r\n [string]$ApiKey,\r\n\r\n [Parameter(Mandatory=$true)]\r\n [string]$Name,\r\n\r\n [Parameter(Mandatory=$true)]\r\n [ValidateSet(\"scheduled\", \"in_progress\", \"verifying\", \"completed\")]\r\n [string]$Status,\r\n \r\n [Parameter(Mandatory=$false)]\r\n [string]$Message,\r\n\r\n [Parameter(Mandatory=$false)]\r\n [string]$Componentid\r\n )\r\n\r\n $date = [System.DateTime]::Now.ToString(\"o\")\r\n $url = \"https://api.statuspage.io/v1/pages/$PageId/incidents.json\"\r\n $headers = @{\"Authorization\"=\"OAuth $ApiKey\"}\r\n $body = \"incident[name]=$Name&incident[status]=$Status&incident[scheduled_for]=$date&incident[scheduled_until]=$date\"\r\n\r\n if($Message)\r\n {\r\n $body += \"&incident[message]=$Message\"\r\n }\r\n\r\n if($Componentid)\r\n {\r\n $body += \"&incident[component_ids][]=$Componentid\"\r\n }\r\n\r\n $response = iwr -UseBasicParsing -Uri $url -Headers $headers -Method POST -Body $body\r\n $content = ConvertFrom-Json $response\r\n $content.id\r\n}\r\n\r\nValidate-Parameter $pageId -parameterName 'PageId'\r\nValidate-Parameter $apiKey = -parameterName 'ApiKey'\r\nValidate-Parameter $incidentName = -parameterName 'IncidentName'\r\nValidate-Parameter $incidentStatus -parameterName 'IncidentStatus'\r\n\r\nWrite-Output \"Creating new scheduled maintenance incident `\"$incidentName`\" ...\"\r\nNew-ScheduledIncident -PageId $pageId -ApiKey $apiKey -Name $incidentName -Status $incidentStatus -Message $incidentMessage -ComponentId $componentId\r\n", + "Octopus.Action.Script.ScriptBody": "## --------------------------------------------------------------------------------------\r\n## Input\r\n## --------------------------------------------------------------------------------------\r\n$pageId = $OctopusParameters['PageId']\r\n$apiKey = $OctopusParameters['ApiKey']\r\n$incidentName = $OctopusParameters['IncidentName']\r\n$incidentStatus = $OctopusParameters['IncidentStatus']\r\n$incidentMessage = $OctopusParameters['IncidentMessage']\r\n$componentId = $OctopusParameters['ComponentId']\r\n\r\nfunction Validate-Parameter($parameterValue, $parameterName) {\r\n if(!$parameterName -contains \"Key\") {\r\n Write-Host \"${parameterName}: ${parameterValue}\"\r\n }\r\n\r\n if (! $parameterValue) {\r\n throw \"$parameterName cannot be empty, please specify a value\"\r\n }\r\n}\r\n\r\nfunction New-ScheduledIncident\r\n{\r\n [CmdletBinding()]\r\n Param(\r\n [Parameter(Mandatory=$true)]\r\n [string]$PageId,\r\n\r\n [Parameter(Mandatory=$true)]\r\n [string]$ApiKey,\r\n\r\n [Parameter(Mandatory=$true)]\r\n [string]$Name,\r\n\r\n [Parameter(Mandatory=$true)]\r\n [ValidateSet(\"scheduled\", \"in_progress\", \"verifying\", \"completed\")]\r\n [string]$Status,\r\n \r\n [Parameter(Mandatory=$false)]\r\n [string]$Message,\r\n\r\n [Parameter(Mandatory=$false)]\r\n [string]$Componentid\r\n )\r\n\r\n $date = [System.DateTime]::Now.ToString(\"o\")\r\n $dateTomorrow = [System.DateTime]::Now.AddDays(1).ToString(\"o\")\r\n $url = \"https://api.statuspage.io/v1/pages/$PageId/incidents.json\"\r\n $headers = @{\"Authorization\"=\"OAuth $ApiKey\"}\r\n $body = \"incident[name]=$Name&incident[status]=$Status&incident[scheduled_for]=$date&incident[scheduled_until]=$dateTomorrow\"\r\n\r\n if($Message)\r\n {\r\n $body += \"&incident[message]=$Message\"\r\n }\r\n\r\n if($Componentid)\r\n {\r\n $body += \"&incident[component_ids][]=$Componentid\"\r\n }\r\n\r\n $response = iwr -UseBasicParsing -Uri $url -Headers $headers -Method POST -Body $body\r\n $content = ConvertFrom-Json $response\r\n $content.id\r\n}\r\n\r\nValidate-Parameter $pageId -parameterName 'PageId'\r\nValidate-Parameter $apiKey = -parameterName 'ApiKey'\r\nValidate-Parameter $incidentName = -parameterName 'IncidentName'\r\nValidate-Parameter $incidentStatus -parameterName 'IncidentStatus'\r\n\r\nWrite-Output \"Creating new scheduled maintenance incident `\"$incidentName`\" ...\"\r\nNew-ScheduledIncident -PageId $pageId -ApiKey $apiKey -Name $incidentName -Status $incidentStatus -Message $incidentMessage -ComponentId $componentId\r\n", "Octopus.Action.Script.ScriptFileName": null, "Octopus.Action.Package.FeedId": null, "Octopus.Action.Package.PackageId": null @@ -83,4 +83,4 @@ "Type": "ActionTemplate" }, "Category": "statusPage" -} \ No newline at end of file +} From 6660693ce1260b22518703536e8812fe310f44df Mon Sep 17 00:00:00 2001 From: Sam Hawkins Date: Mon, 17 Feb 2025 14:55:43 +1100 Subject: [PATCH 2/3] updated metadata for this branch --- .../statuspageio-create-scheduled-maintenance-incident.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/step-templates/statuspageio-create-scheduled-maintenance-incident.json b/step-templates/statuspageio-create-scheduled-maintenance-incident.json index f11b16f0b..acc3a88cb 100644 --- a/step-templates/statuspageio-create-scheduled-maintenance-incident.json +++ b/step-templates/statuspageio-create-scheduled-maintenance-incident.json @@ -3,7 +3,7 @@ "Name": "StatusPage.io - Create Scheduled Maintenance Incident", "Description": "Creates or updates a scheduled maintenance incident on StatusPage.io", "ActionType": "Octopus.Script", - "Version": 5, + "Version": 6, "Properties": { "Octopus.Action.Script.Syntax": "PowerShell", "Octopus.Action.Script.ScriptSource": "Inline", @@ -76,9 +76,9 @@ } } ], - "LastModifiedBy": "nshenoy", + "LastModifiedBy": "Sam-Kudo", "$Meta": { - "ExportedAt": "2016-10-26T18:49:13.955+00:00", + "ExportedAt": "2025-02-17T14:35:00.000+00:00", "OctopusVersion": "3.4.10", "Type": "ActionTemplate" }, From 6edecbc51b0d7cd3f46c421a828276872f62713e Mon Sep 17 00:00:00 2001 From: Sam Hawkins Date: Mon, 17 Feb 2025 15:14:23 +1100 Subject: [PATCH 3/3] additional metadata update --- .../statuspageio-create-scheduled-maintenance-incident.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/step-templates/statuspageio-create-scheduled-maintenance-incident.json b/step-templates/statuspageio-create-scheduled-maintenance-incident.json index acc3a88cb..84d585d0c 100644 --- a/step-templates/statuspageio-create-scheduled-maintenance-incident.json +++ b/step-templates/statuspageio-create-scheduled-maintenance-incident.json @@ -79,7 +79,7 @@ "LastModifiedBy": "Sam-Kudo", "$Meta": { "ExportedAt": "2025-02-17T14:35:00.000+00:00", - "OctopusVersion": "3.4.10", + "OctopusVersion": "2025.1.8967", "Type": "ActionTemplate" }, "Category": "statusPage"