3
3
"Name" : " StatusPage.io - Create Scheduled Maintenance Incident" ,
4
4
"Description" : " Creates or updates a scheduled maintenance incident on StatusPage.io" ,
5
5
"ActionType" : " Octopus.Script" ,
6
- "Version" : 5 ,
6
+ "Version" : 6 ,
7
7
"Properties" : {
8
8
"Octopus.Action.Script.Syntax" : " PowerShell" ,
9
9
"Octopus.Action.Script.ScriptSource" : " Inline" ,
10
10
"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",
12
12
"Octopus.Action.Script.ScriptFileName" : null ,
13
13
"Octopus.Action.Package.FeedId" : null ,
14
14
"Octopus.Action.Package.PackageId" : null
76
76
}
77
77
}
78
78
],
79
- "LastModifiedBy" : " nshenoy " ,
79
+ "LastModifiedBy" : " Sam-Kudo " ,
80
80
"$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 " ,
83
83
"Type" : " ActionTemplate"
84
84
},
85
85
"Category" : " statusPage"
86
- }
86
+ }
0 commit comments