Class: Pagerduty::MaintenanceWindow
- Defined in:
- lib/pagerduty/models/maintenance_window.rb
Defined Under Namespace
Classes: Count
Instance Attribute Summary
Attributes inherited from Pagerduty
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(attributes) ⇒ MaintenanceWindow
constructor
A new instance of MaintenanceWindow.
- #save(options = {}) ⇒ Object
Methods inherited from Pagerduty
#acknowledge, #alerts, #alerts_per_time, #create_escalation_policy, #create_maintenance_window, #create_schedule_override, #create_service, #create_user, #escalation_policies, #escalation_rules, #get_escalation_policy, #get_escalation_rule, #get_incident, #get_incident_counts, #get_log_entries, #get_log_entry, #get_maintenance_window, #get_maintenance_windows, #get_schedule, #get_schedule_users, #get_schedules, #get_service, #get_services, #get_user, #get_users, #has_requirements?, #incidents, #incidents_per_time, #notes, #resolve, #trigger
Methods included from Core
Constructor Details
#initialize(attributes) ⇒ MaintenanceWindow
Returns a new instance of MaintenanceWindow.
23 24 25 26 |
# File 'lib/pagerduty/models/maintenance_window.rb', line 23 def initialize(attributes) self.attributes = attributes self.service_ids = self.services.map(&:id) end |
Instance Method Details
#delete ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/pagerduty/models/maintenance_window.rb', line 41 def delete res = curl({ uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows/#{self.id}", method: 'DELETE' }) res['code'] == '204' ? "Successfully deleted Maintenance Window #{self.id}" : res end |
#save(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pagerduty/models/maintenance_window.rb', line 28 def save(={}) Pagerduty::MaintenanceWindow.new(JSON.parse(curl({ uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows/#{self.id}", data: { start_time: self.start_time, end_time: self.end_time, description: self.description, service_ids: self.service_ids }, method: 'PUT' }).body)['maintenance_window']) end |