Class: Morpheus::IncidentsInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/incidents_interface.rb

Instance Method Summary collapse

Methods inherited from APIClient

#accounts, #app_templates, #apps, #archive_buckets, #archive_files, #auth, #clouds, #containers, #custom_instance_types, #dashboard, #deploy, #deployments, #dry, #dry_run, #execute, #groups, #image_builder, #instance_types, #instances, #key_pairs, #license, #load_balancers, #logs, #monitoring, #option_type_lists, #option_types, #options, #provision_types, #roles, #security_group_rules, #security_groups, #servers, #set_ssl_verification_enabled, #setup, #ssl_verification_enabled?, #task_sets, #tasks, #users, #virtual_images, #whoami

Constructor Details

#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ IncidentsInterface

Returns a new instance of IncidentsInterface.



4
5
6
7
8
9
# File 'lib/morpheus/api/incidents_interface.rb', line 4

def initialize(access_token, refresh_token,expires_at = nil, base_url=nil) 
  @access_token = access_token
  @refresh_token = refresh_token
  @base_url = base_url
  @expires_at = expires_at
end

Instance Method Details

#close(id) ⇒ Object



56
57
58
# File 'lib/morpheus/api/incidents_interface.rb', line 56

def close(id)
  destroy(id)
end

#create(options) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/morpheus/api/incidents_interface.rb', line 33

def create(options)
  url = "#{@base_url}/api/monitoring/incidents"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = options
  opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#destroy(id) ⇒ Object



49
50
51
52
53
54
# File 'lib/morpheus/api/incidents_interface.rb', line 49

def destroy(id)
  url = "#{@base_url}/api/monitoring/incidents/#{id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :delete, url: url, headers: headers}
  execute(opts)
end

#events(id) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/morpheus/api/incidents_interface.rb', line 93

def events(id)
  # JD: maybe switch to this instead /api/monitoring/incidents/#{id}/events instead?
  # url = "#{@base_url}/api/monitoring/incidents/#{id}/events"
  url = "#{@base_url}/api/monitoring/incident-events/#{id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#get(id, params = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/morpheus/api/incidents_interface.rb', line 11

def get(id, params={})
  raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
  url = "#{@base_url}/api/monitoring/incidents/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#history(id, params = {}) ⇒ Object



79
80
81
82
83
84
# File 'lib/morpheus/api/incidents_interface.rb', line 79

def history(id, params={})
  url = "#{@base_url}/api/monitoring/incidents/#{id}/history"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#list(params = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/morpheus/api/incidents_interface.rb', line 19

def list(params={})
  url = "#{@base_url}/api/monitoring/incidents"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#mute(id, payload = {}) ⇒ Object



75
76
77
# File 'lib/morpheus/api/incidents_interface.rb', line 75

def mute(id, payload={})
  quarantine(id, payload)
end

#notifications(id, params = {}) ⇒ Object



86
87
88
89
90
91
# File 'lib/morpheus/api/incidents_interface.rb', line 86

def notifications(id, params={})
  url = "#{@base_url}/api/monitoring/incidents/#{id}/notifications"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#quarantine(id, options = {}) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/morpheus/api/incidents_interface.rb', line 67

def quarantine(id, options={})
  url = "#{@base_url}/api/monitoring/incidents/#{id}/quarantine"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = options
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end

#reopen(id, options = {}) ⇒ Object



60
61
62
63
64
65
# File 'lib/morpheus/api/incidents_interface.rb', line 60

def reopen(id, options={})
  url = "#{@base_url}/api/monitoring/incidents/#{id}/reopen"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: options.to_json}
  execute(opts)
end

#stats(params = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/morpheus/api/incidents_interface.rb', line 26

def stats(params={})
  url = "#{@base_url}/api/monitoring/incidents/stats"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#update(id, options) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/morpheus/api/incidents_interface.rb', line 41

def update(id, options)
  url = "#{@base_url}/api/monitoring/incidents/#{id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = options
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end