Last active
August 29, 2015 13:57
-
-
Save julianeon/9920745 to your computer and use it in GitHub Desktop.
To create a maintenance window in a service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subdomain="CHANGE_THIS" | |
api_key="CHANGE_THIS" | |
start="CHANGE_TO_TIME_LIKE_2014-04-08T13:00:00-04:00Z" | |
stop="CHANGE_TO_TIME_LIKE_2014-04-09T13:00:00-04:00Z" | |
about="This is the maintenance window for this service." | |
service="CHANGE_TO_ID_LIKE_P5QRAN5" | |
requester="CHANGE_TO_ID_LIKE_PVYWSCX" | |
endpoint="https://#{subdomain}.pagerduty.com/api/v1/maintenance_windows" | |
def curl_command_post_maintenance(token_string,main_details,endpoint) | |
curl_command='curl -H "Content-type: application/json" -H "Authorization: Token token='+token_string+"\" -X POST -d '#{main_details}' \""+endpoint+'"' | |
end | |
def maintenance_details(start,stop,about,service_id,user_id) | |
packet='{"maintenance_window": {"start_time":"'+start+'","end_time":"'+stop+'","description":"'+about+'","service_ids":["'+service_id+'"]},"requester_id":"'+user_id+'"}' | |
end | |
details=maintenance_details(start,stop,about,service,requester) | |
curl_command_string=curl_command_post_maintenance(api_key,details,endpoint) | |
puts curl_command_string | |
system(curl_command_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment