Skip to content

Commit 3a09940

Browse files
authored
Merge pull request #1586 from Sam-Kudo/master
Bugfixing Template - Statuspage Create Incident
2 parents b69242c + 6edecbc commit 3a09940

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

step-templates/statuspageio-create-scheduled-maintenance-incident.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"Name": "StatusPage.io - Create Scheduled Maintenance Incident",
44
"Description": "Creates or updates a scheduled maintenance incident on StatusPage.io",
55
"ActionType": "Octopus.Script",
6-
"Version": 5,
6+
"Version": 6,
77
"Properties": {
88
"Octopus.Action.Script.Syntax": "PowerShell",
99
"Octopus.Action.Script.ScriptSource": "Inline",
1010
"Octopus.Action.RunOnServer": "false",
11-
"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",
11+
"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",
1212
"Octopus.Action.Script.ScriptFileName": null,
1313
"Octopus.Action.Package.FeedId": null,
1414
"Octopus.Action.Package.PackageId": null
@@ -76,11 +76,11 @@
7676
}
7777
}
7878
],
79-
"LastModifiedBy": "nshenoy",
79+
"LastModifiedBy": "Sam-Kudo",
8080
"$Meta": {
81-
"ExportedAt": "2016-10-26T18:49:13.955+00:00",
82-
"OctopusVersion": "3.4.10",
81+
"ExportedAt": "2025-02-17T14:35:00.000+00:00",
82+
"OctopusVersion": "2025.1.8967",
8383
"Type": "ActionTemplate"
8484
},
8585
"Category": "statusPage"
86-
}
86+
}

0 commit comments

Comments
 (0)