morpheus-cli 2.10.3 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/bin/morpheus +5 -96
  3. data/lib/morpheus/api/api_client.rb +23 -1
  4. data/lib/morpheus/api/checks_interface.rb +106 -0
  5. data/lib/morpheus/api/incidents_interface.rb +102 -0
  6. data/lib/morpheus/api/monitoring_apps_interface.rb +47 -0
  7. data/lib/morpheus/api/monitoring_contacts_interface.rb +47 -0
  8. data/lib/morpheus/api/monitoring_groups_interface.rb +47 -0
  9. data/lib/morpheus/api/monitoring_interface.rb +36 -0
  10. data/lib/morpheus/api/option_type_lists_interface.rb +47 -0
  11. data/lib/morpheus/api/option_types_interface.rb +47 -0
  12. data/lib/morpheus/api/roles_interface.rb +0 -1
  13. data/lib/morpheus/api/setup_interface.rb +19 -9
  14. data/lib/morpheus/cli.rb +20 -1
  15. data/lib/morpheus/cli/accounts.rb +8 -3
  16. data/lib/morpheus/cli/app_templates.rb +19 -11
  17. data/lib/morpheus/cli/apps.rb +52 -37
  18. data/lib/morpheus/cli/cli_command.rb +229 -53
  19. data/lib/morpheus/cli/cli_registry.rb +48 -40
  20. data/lib/morpheus/cli/clouds.rb +55 -26
  21. data/lib/morpheus/cli/command_error.rb +12 -0
  22. data/lib/morpheus/cli/credentials.rb +68 -26
  23. data/lib/morpheus/cli/curl_command.rb +98 -0
  24. data/lib/morpheus/cli/dashboard_command.rb +2 -7
  25. data/lib/morpheus/cli/deployments.rb +4 -4
  26. data/lib/morpheus/cli/deploys.rb +1 -2
  27. data/lib/morpheus/cli/dot_file.rb +5 -8
  28. data/lib/morpheus/cli/error_handler.rb +179 -15
  29. data/lib/morpheus/cli/groups.rb +21 -13
  30. data/lib/morpheus/cli/hosts.rb +220 -110
  31. data/lib/morpheus/cli/instance_types.rb +2 -2
  32. data/lib/morpheus/cli/instances.rb +257 -167
  33. data/lib/morpheus/cli/key_pairs.rb +15 -9
  34. data/lib/morpheus/cli/library.rb +673 -27
  35. data/lib/morpheus/cli/license.rb +2 -2
  36. data/lib/morpheus/cli/load_balancers.rb +4 -4
  37. data/lib/morpheus/cli/log_level_command.rb +6 -4
  38. data/lib/morpheus/cli/login.rb +17 -3
  39. data/lib/morpheus/cli/logout.rb +25 -11
  40. data/lib/morpheus/cli/man_command.rb +388 -0
  41. data/lib/morpheus/cli/mixins/accounts_helper.rb +1 -1
  42. data/lib/morpheus/cli/mixins/monitoring_helper.rb +434 -0
  43. data/lib/morpheus/cli/mixins/print_helper.rb +620 -112
  44. data/lib/morpheus/cli/mixins/provisioning_helper.rb +1 -1
  45. data/lib/morpheus/cli/monitoring_apps_command.rb +29 -0
  46. data/lib/morpheus/cli/monitoring_checks_command.rb +427 -0
  47. data/lib/morpheus/cli/monitoring_contacts_command.rb +373 -0
  48. data/lib/morpheus/cli/monitoring_groups_command.rb +29 -0
  49. data/lib/morpheus/cli/monitoring_incidents_command.rb +711 -0
  50. data/lib/morpheus/cli/option_types.rb +10 -1
  51. data/lib/morpheus/cli/recent_activity_command.rb +2 -5
  52. data/lib/morpheus/cli/remote.rb +874 -134
  53. data/lib/morpheus/cli/roles.rb +54 -27
  54. data/lib/morpheus/cli/security_group_rules.rb +2 -2
  55. data/lib/morpheus/cli/security_groups.rb +23 -19
  56. data/lib/morpheus/cli/set_prompt_command.rb +50 -0
  57. data/lib/morpheus/cli/shell.rb +222 -157
  58. data/lib/morpheus/cli/tasks.rb +19 -15
  59. data/lib/morpheus/cli/users.rb +27 -17
  60. data/lib/morpheus/cli/version.rb +1 -1
  61. data/lib/morpheus/cli/virtual_images.rb +28 -13
  62. data/lib/morpheus/cli/whoami.rb +131 -52
  63. data/lib/morpheus/cli/workflows.rb +24 -9
  64. data/lib/morpheus/formatters.rb +195 -3
  65. data/lib/morpheus/logging.rb +86 -0
  66. data/lib/morpheus/terminal.rb +371 -0
  67. data/scripts/generate_morpheus_commands_help.morpheus +60 -0
  68. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63a320542a8d185d0e96a8ca526ff4ff23b21868
4
- data.tar.gz: aeccbd35966dd37101a032acd9346804767ae627
3
+ metadata.gz: 943b71ed0cd1182919d30c80a340e4dddd348469
4
+ data.tar.gz: 5240605a00d07cfae6f73cc53789ad456ba99713
5
5
  SHA512:
6
- metadata.gz: c825db622aed4d8d571d97bf13a250333f04543834b7749f57a33555fc17e89a0190797e6c0ec6b06dfdf246f623329c4fd7b3b9aef097ac0160e196f1d80712
7
- data.tar.gz: fe005b26254bbc9fcf41cde841a5ad40715583d0b637a763e8d0612bdc23341f98df11e9385b98a4d8588fc15c6e53a517d040f9463935be7b2e139141500c84
6
+ metadata.gz: 03b911517a40f1254ebb91e14d69d840038c80df028966b0cd23035b0fbc54eff8e22aa6bfa75cbc70584b26c858290c2e905b8115a1b7312066a3431fb56305
7
+ data.tar.gz: 93de8368cae2dd82312741584dc4d688fc9dc5a6defadccdcede1f58254a92765f65739d43d82e300c72547fb0dfb630eda587bac858537262c6a0e7ce90b783
data/bin/morpheus CHANGED
@@ -1,98 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'term/ansicolor'
3
- require 'optparse'
4
- require 'morpheus/cli'
5
- require 'morpheus/rest_client'
6
- require 'morpheus/cli/cli_registry'
7
- require 'morpheus/cli/dot_file'
8
- require 'morpheus/cli/error_handler'
2
+ require 'morpheus/terminal'
9
3
 
10
- # setup environment variables
11
- Morpheus::Cli.home_directory = ENV['MORPHEUS_CLI_HOME'] || File.join(Dir.home, ".morpheus")
12
-
13
- # use colors by default
14
- Term::ANSIColor::coloring = STDOUT.isatty
15
- # include Term::ANSIColor # tempting
16
-
17
- # short circuit version switch
18
- if ARGV[0] == '-v' || ARGV[0] == '--version'
19
- version = Morpheus::Cli::VERSION
20
- puts version
21
- exit 0
22
- end
23
-
24
- args = ARGV.dup
25
-
26
- # global options
27
-
28
- # raise log level right away
29
- if args.find {|it| it == '-V' || it == '--debug'}
30
- Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::DEBUG)
31
- end
32
-
33
- # execute startup script .morpheus_profile unless --noprofile is passed
34
- noprofile = false
35
- if args.find {|it| it == '--noprofile' }
36
- noprofile = true
37
- args.delete_if {|it| it == '--noprofile' }
38
- end
39
- if !noprofile && File.exists?(Morpheus::Cli::DotFile.morpheus_profile_filename)
40
- Morpheus::Cli::DotFile.new(Morpheus::Cli::DotFile.morpheus_profile_filename).execute()
41
- end
42
-
43
- # all commands should be registered commands or aliases
44
- if (args.count == 0) || !(Morpheus::Cli::CliRegistry.has_command?(args[0]) || Morpheus::Cli::CliRegistry.has_alias?(args[0]))
45
- # just for printing help. todo: start using this. maybe in class Cli::MainCommand
46
- optparse = Morpheus::Cli::OptionParser.new do|opts|
47
- opts.banner = "Options:" # hack alert
48
- opts.on('-v','--version', "Print the version.") do
49
- puts Morpheus::Cli::VERSION
50
- exit
51
- end
52
- opts.on('--noprofile','--noprofile', "Do not read and execute the personal initialization script .morpheus_profile") do
53
- @noprofile = true
54
- end
55
- opts.on('-C','--nocolor', "Disable ANSI coloring") do
56
- Term::ANSIColor::coloring = false
57
- end
58
- opts.on('-V','--debug', "Print extra output for debugging. ") do |json|
59
- Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::DEBUG)
60
- ::RestClient.log = Morpheus::Logging.debug? ? STDOUT : nil
61
- end
62
- opts.on( '-h', '--help', "Prints this help" ) do
63
- puts opts
64
- exit
65
- end
66
- end
67
- out = "Usage: morpheus [command] [options]\n"
68
- out << "Commands:\n"
69
- Morpheus::Cli::CliRegistry.all.keys.sort.each {|cmd|
70
- out << "\t#{cmd.to_s}\n"
71
- }
72
- # out << "Options:\n"
73
- out << optparse.to_s
74
- out << "\n"
75
- out << "For more information, see https://github.com/gomorpheus/morpheus-cli/wiki"
76
- out << "\n"
77
- puts out
78
- optparse.to_s
79
- exit 127
80
- end
81
-
82
- # ok, execute the command (or alias)
83
- begin
84
- # shell is a Singleton command class
85
- if args[0] == "shell"
86
- cmd_result = Morpheus::Cli::Shell.instance.handle(args[1..-1])
87
- else
88
- cmd_result = Morpheus::Cli::CliRegistry.exec(args[0], args[1..-1])
89
- end
90
- if cmd_result == false
91
- exit 1
92
- else
93
- exit 0
94
- end
95
- rescue => e
96
- Morpheus::Cli::ErrorHandler.new.handle_error(e)
97
- exit 1
98
- end
4
+ terminal = Morpheus::Terminal.new
5
+ exit_code, err = terminal.execute(ARGV)
6
+ # raise err unless err.nil?
7
+ exit exit_code
@@ -26,7 +26,7 @@ class Morpheus::APIClient
26
26
  # JD: could return a Request object instead...
27
27
  return opts
28
28
  end
29
- # puts "#{Term::ANSIColor.dark} #=> Morpheus::RestClient.execute(#{opts})#{Term::ANSIColor.reset}" if Morpheus::Logging.debug?
29
+ # Morpheus::Logging::DarkPrinter.puts "Morpheus::RestClient.execute(#{opts})" if Morpheus::Logging.debug?
30
30
  # instead, using ::RestClient.log = STDOUT
31
31
  response = Morpheus::RestClient.execute(opts)
32
32
  if parse_json
@@ -140,6 +140,14 @@ class Morpheus::APIClient
140
140
  Morpheus::CustomInstanceTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
141
141
  end
142
142
 
143
+ def option_types
144
+ Morpheus::OptionTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
145
+ end
146
+
147
+ def option_type_lists
148
+ Morpheus::OptionTypeListsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
149
+ end
150
+
143
151
  def dashboard
144
152
  Morpheus::DashboardInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
145
153
  end
@@ -148,4 +156,18 @@ class Morpheus::APIClient
148
156
  Morpheus::SetupInterface.new(@base_url)
149
157
  end
150
158
 
159
+ def monitoring
160
+ Morpheus::MonitoringInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
161
+ end
162
+
163
+ # def checks
164
+ # # Morpheus::ChecksInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
165
+ # monitoring.checks
166
+ # end
167
+
168
+ # def incidents
169
+ # # Morpheus::IncidentsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
170
+ # monitoring.incidents
171
+ # end
172
+
151
173
  end
@@ -0,0 +1,106 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::ChecksInterface < Morpheus::APIClient
4
+ def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
5
+ @access_token = access_token
6
+ @refresh_token = refresh_token
7
+ @base_url = base_url
8
+ @expires_at = expires_at
9
+ end
10
+
11
+ def get(id)
12
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ url = "#{@base_url}/api/monitoring/checks/#{id}"
14
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
+ opts = {method: :get, url: url, headers: headers}
16
+ execute(opts)
17
+ end
18
+
19
+ def list(options={})
20
+ url = "#{@base_url}/api/monitoring/checks"
21
+ headers = { params: options, authorization: "Bearer #{@access_token}" }
22
+ opts = {method: :get, url: url, headers: headers}
23
+ execute(opts)
24
+ end
25
+
26
+ # eh? maye use for rendering form
27
+ # def create(options)
28
+ # url = "#{@base_url}/api/monitoring/checks/create"
29
+ # headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
30
+ # payload = options
31
+ # opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
32
+ # execute(opts)
33
+ # end
34
+
35
+ def update(id, options)
36
+ url = "#{@base_url}/api/monitoring/checks/#{id}"
37
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
38
+ payload = options
39
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
40
+ execute(opts)
41
+ end
42
+
43
+ def destroy(id)
44
+ url = "#{@base_url}/api/monitoring/checks/#{id}"
45
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
46
+ opts = {method: :delete, url: url, headers: headers}
47
+ execute(opts)
48
+ end
49
+
50
+ def quarantine(id, options={})
51
+ url = "#{@base_url}/api/monitoring/checks/#{id}/quarantine"
52
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
53
+ payload = options
54
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
55
+ execute(opts)
56
+ end
57
+
58
+ def mute(id, payload={})
59
+ quarantine(id, payload)
60
+ end
61
+
62
+ def history(id, params={})
63
+ url = "#{@base_url}/api/monitoring/checks/#{id}/history"
64
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
65
+ opts = {method: :get, url: url, headers: headers}
66
+ execute(opts)
67
+ end
68
+
69
+ # def notifications(id)
70
+ # url = "#{@base_url}/api/monitoring/checks/#{id}/notifications"
71
+ # headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
72
+ # opts = {method: :get, url: url, headers: headers}
73
+ # execute(opts)
74
+ # end
75
+
76
+ def statistics(id)
77
+ url = "#{@base_url}/api/monitoring/checks/#{id}/statistics"
78
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
79
+ opts = {method: :get, url: url, headers: headers}
80
+ execute(opts)
81
+ end
82
+
83
+ def list_check_types(options={})
84
+ url = "#{@base_url}/api/monitoring/check-types"
85
+ headers = { :params => options, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
86
+ opts = {method: :get, url: url, headers: headers}
87
+ execute(opts)
88
+ end
89
+
90
+ def get_check_type(check_type_id)
91
+ url = "#{@base_url}/api/monitoring/check-types/#{check_type_id}"
92
+ headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
93
+ opts = {method: :get, url: url, headers: headers}
94
+ execute(opts)
95
+ end
96
+
97
+ # def events(id, params={})
98
+ # # JD: maybe switch to this instead /api/monitoring/checks/#{id}/events instead?
99
+ # # url = "#{@base_url}/api/monitoring/checks/#{id}/events"
100
+ # url = "#{@base_url}/api/monitoring/checks/#{id}/events"
101
+ # headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
102
+ # opts = {method: :get, url: url, headers: headers}
103
+ # execute(opts)
104
+ # end
105
+
106
+ end
@@ -0,0 +1,102 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::IncidentsInterface < Morpheus::APIClient
4
+ def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
5
+ @access_token = access_token
6
+ @refresh_token = refresh_token
7
+ @base_url = base_url
8
+ @expires_at = expires_at
9
+ end
10
+
11
+ def get(id, params={})
12
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ url = "#{@base_url}/api/monitoring/incidents/#{id}"
14
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
15
+ opts = {method: :get, url: url, headers: headers}
16
+ execute(opts)
17
+ end
18
+
19
+ def list(params={})
20
+ url = "#{@base_url}/api/monitoring/incidents"
21
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
22
+ opts = {method: :get, url: url, headers: headers}
23
+ execute(opts)
24
+ end
25
+
26
+ def stats(params={})
27
+ url = "#{@base_url}/api/monitoring/incidents/stats"
28
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
29
+ opts = {method: :get, url: url, headers: headers}
30
+ execute(opts)
31
+ end
32
+
33
+ def create(options)
34
+ url = "#{@base_url}/api/monitoring/incidents"
35
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
36
+ payload = options
37
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
38
+ execute(opts)
39
+ end
40
+
41
+ def update(id, options)
42
+ url = "#{@base_url}/api/monitoring/incidents/#{id}"
43
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
44
+ payload = options
45
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
46
+ execute(opts)
47
+ end
48
+
49
+ def destroy(id)
50
+ url = "#{@base_url}/api/monitoring/incidents/#{id}"
51
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
52
+ opts = {method: :delete, url: url, headers: headers}
53
+ execute(opts)
54
+ end
55
+
56
+ def close(id)
57
+ destroy(id)
58
+ end
59
+
60
+ def reopen(id, options={})
61
+ url = "#{@base_url}/api/monitoring/incidents/#{id}/reopen"
62
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
63
+ opts = {method: :put, url: url, headers: headers, payload: options.to_json}
64
+ execute(opts)
65
+ end
66
+
67
+ def quarantine(id, options={})
68
+ url = "#{@base_url}/api/monitoring/incidents/#{id}/quarantine"
69
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
70
+ payload = options
71
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
72
+ execute(opts)
73
+ end
74
+
75
+ def mute(id, payload={})
76
+ quarantine(id, payload)
77
+ end
78
+
79
+ def history(id, params={})
80
+ url = "#{@base_url}/api/monitoring/incidents/#{id}/history"
81
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
82
+ opts = {method: :get, url: url, headers: headers}
83
+ execute(opts)
84
+ end
85
+
86
+ def notifications(id, params={})
87
+ url = "#{@base_url}/api/monitoring/incidents/#{id}/notifications"
88
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
89
+ opts = {method: :get, url: url, headers: headers}
90
+ execute(opts)
91
+ end
92
+
93
+ def events(id)
94
+ # JD: maybe switch to this instead /api/monitoring/incidents/#{id}/events instead?
95
+ # url = "#{@base_url}/api/monitoring/incidents/#{id}/events"
96
+ url = "#{@base_url}/api/monitoring/incident-events/#{id}"
97
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
98
+ opts = {method: :get, url: url, headers: headers}
99
+ execute(opts)
100
+ end
101
+
102
+ end
@@ -0,0 +1,47 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::MonitoringAppsInterface < Morpheus::APIClient
4
+ def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
5
+ @access_token = access_token
6
+ @refresh_token = refresh_token
7
+ @base_url = base_url
8
+ @expires_at = expires_at
9
+ end
10
+
11
+ def get(id, params={})
12
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ url = "#{@base_url}/api/monitoring/apps/#{id}"
14
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
15
+ opts = {method: :get, url: url, headers: headers}
16
+ execute(opts)
17
+ end
18
+
19
+ def list(params={})
20
+ url = "#{@base_url}/api/monitoring/apps"
21
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
22
+ opts = {method: :get, url: url, headers: headers}
23
+ execute(opts)
24
+ end
25
+
26
+ def create(payload)
27
+ url = "#{@base_url}/api/monitoring/apps"
28
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
29
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
30
+ execute(opts)
31
+ end
32
+
33
+ def update(id, payload)
34
+ url = "#{@base_url}/api/monitoring/apps/#{id}"
35
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
36
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
37
+ execute(opts)
38
+ end
39
+
40
+ def destroy(id)
41
+ url = "#{@base_url}/api/monitoring/apps/#{id}"
42
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
43
+ opts = {method: :delete, url: url, headers: headers}
44
+ execute(opts)
45
+ end
46
+
47
+ end
@@ -0,0 +1,47 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::MonitoringContactsInterface < Morpheus::APIClient
4
+ def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
5
+ @access_token = access_token
6
+ @refresh_token = refresh_token
7
+ @base_url = base_url
8
+ @expires_at = expires_at
9
+ end
10
+
11
+ def get(id, params={})
12
+ raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ url = "#{@base_url}/api/monitoring/contacts/#{id}"
14
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
15
+ opts = {method: :get, url: url, headers: headers}
16
+ execute(opts)
17
+ end
18
+
19
+ def list(params={})
20
+ url = "#{@base_url}/api/monitoring/contacts"
21
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
22
+ opts = {method: :get, url: url, headers: headers}
23
+ execute(opts)
24
+ end
25
+
26
+ def create(payload)
27
+ url = "#{@base_url}/api/monitoring/contacts"
28
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
29
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
30
+ execute(opts)
31
+ end
32
+
33
+ def update(id, payload)
34
+ url = "#{@base_url}/api/monitoring/contacts/#{id}"
35
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
36
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
37
+ execute(opts)
38
+ end
39
+
40
+ def destroy(id)
41
+ url = "#{@base_url}/api/monitoring/contacts/#{id}"
42
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
43
+ opts = {method: :delete, url: url, headers: headers}
44
+ execute(opts)
45
+ end
46
+
47
+ end