morpheus-cli 5.4.0 → 5.4.3.1

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/account_users_interface.rb +68 -0
  4. data/lib/morpheus/api/api_client.rb +55 -10
  5. data/lib/morpheus/api/audit_interface.rb +9 -0
  6. data/lib/morpheus/api/catalog_item_types_interface.rb +20 -0
  7. data/lib/morpheus/api/instances_interface.rb +49 -0
  8. data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
  9. data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
  10. data/lib/morpheus/api/load_balancer_profiles_interface.rb +4 -5
  11. data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +13 -4
  12. data/lib/morpheus/api/load_balancers_interface.rb +5 -0
  13. data/lib/morpheus/api/network_routers_interface.rb +9 -0
  14. data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
  15. data/lib/morpheus/api/ping_interface.rb +2 -0
  16. data/lib/morpheus/api/read_interface.rb +4 -3
  17. data/lib/morpheus/api/rest_interface.rb +3 -3
  18. data/lib/morpheus/api/secondary_read_interface.rb +1 -1
  19. data/lib/morpheus/api/secondary_rest_interface.rb +19 -19
  20. data/lib/morpheus/api/setup_interface.rb +4 -0
  21. data/lib/morpheus/api/snapshots_interface.rb +19 -0
  22. data/lib/morpheus/api/storage_server_types_interface.rb +14 -0
  23. data/lib/morpheus/api/storage_servers_interface.rb +9 -0
  24. data/lib/morpheus/api/storage_volume_types_interface.rb +9 -0
  25. data/lib/morpheus/api/storage_volumes_interface.rb +9 -0
  26. data/lib/morpheus/api/users_interface.rb +16 -63
  27. data/lib/morpheus/cli/cli_command.rb +253 -5
  28. data/lib/morpheus/cli/cli_registry.rb +1 -1
  29. data/lib/morpheus/cli/commands/alias_command.rb +1 -1
  30. data/lib/morpheus/cli/commands/apps.rb +14 -78
  31. data/lib/morpheus/cli/commands/audit.rb +188 -0
  32. data/lib/morpheus/cli/commands/blueprints_command.rb +1 -1
  33. data/lib/morpheus/cli/commands/catalog_item_types_command.rb +88 -0
  34. data/lib/morpheus/cli/commands/change_password_command.rb +4 -4
  35. data/lib/morpheus/cli/commands/clusters.rb +96 -58
  36. data/lib/morpheus/cli/commands/hosts.rb +27 -15
  37. data/lib/morpheus/cli/commands/image_builder_command.rb +4 -8
  38. data/lib/morpheus/cli/commands/instances.rb +359 -3
  39. data/lib/morpheus/cli/commands/integrations_command.rb +1 -12
  40. data/lib/morpheus/cli/commands/library_instance_types_command.rb +3 -0
  41. data/lib/morpheus/cli/commands/load_balancer_monitors.rb +70 -0
  42. data/lib/morpheus/cli/commands/load_balancer_pools.rb +29 -50
  43. data/lib/morpheus/cli/commands/load_balancer_profiles.rb +64 -0
  44. data/lib/morpheus/cli/commands/load_balancer_types.rb +9 -4
  45. data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +69 -58
  46. data/lib/morpheus/cli/commands/load_balancers.rb +109 -6
  47. data/lib/morpheus/cli/commands/network_firewalls_command.rb +22 -5
  48. data/lib/morpheus/cli/commands/network_routers_command.rb +96 -45
  49. data/lib/morpheus/cli/commands/network_static_routes_command.rb +451 -0
  50. data/lib/morpheus/cli/commands/network_transport_zones_command.rb +4 -4
  51. data/lib/morpheus/cli/commands/networks_command.rb +2 -2
  52. data/lib/morpheus/cli/commands/open_command.rb +30 -0
  53. data/lib/morpheus/cli/commands/options.rb +98 -0
  54. data/lib/morpheus/cli/commands/ping.rb +3 -5
  55. data/lib/morpheus/cli/commands/policies_command.rb +2 -2
  56. data/lib/morpheus/cli/commands/prices_command.rb +7 -7
  57. data/lib/morpheus/cli/commands/provisioning_settings_command.rb +1 -0
  58. data/lib/morpheus/cli/commands/remote.rb +20 -12
  59. data/lib/morpheus/cli/commands/roles.rb +1 -1
  60. data/lib/morpheus/cli/commands/security_groups.rb +2 -2
  61. data/lib/morpheus/cli/commands/service_plans_command.rb +1 -1
  62. data/lib/morpheus/cli/commands/setup.rb +1 -1
  63. data/lib/morpheus/cli/commands/shell.rb +2 -2
  64. data/lib/morpheus/cli/commands/snapshots.rb +139 -0
  65. data/lib/morpheus/cli/commands/storage_server_types.rb +50 -0
  66. data/lib/morpheus/cli/commands/storage_servers.rb +122 -0
  67. data/lib/morpheus/cli/commands/storage_volume_types.rb +50 -0
  68. data/lib/morpheus/cli/commands/storage_volumes.rb +103 -0
  69. data/lib/morpheus/cli/commands/tasks.rb +5 -5
  70. data/lib/morpheus/cli/commands/tenants_command.rb +1 -1
  71. data/lib/morpheus/cli/commands/user_groups_command.rb +1 -1
  72. data/lib/morpheus/cli/commands/user_settings_command.rb +3 -2
  73. data/lib/morpheus/cli/commands/user_sources_command.rb +1 -1
  74. data/lib/morpheus/cli/commands/users.rb +28 -28
  75. data/lib/morpheus/cli/commands/view.rb +102 -0
  76. data/lib/morpheus/cli/commands/virtual_images.rb +4 -1
  77. data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
  78. data/lib/morpheus/cli/mixins/load_balancers_helper.rb +24 -4
  79. data/lib/morpheus/cli/mixins/print_helper.rb +50 -18
  80. data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
  81. data/lib/morpheus/cli/mixins/provisioning_helper.rb +96 -6
  82. data/lib/morpheus/cli/mixins/rest_command.rb +148 -74
  83. data/lib/morpheus/cli/mixins/secondary_rest_command.rb +174 -82
  84. data/lib/morpheus/cli/mixins/storage_servers_helper.rb +156 -0
  85. data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +119 -0
  86. data/lib/morpheus/cli/option_types.rb +95 -28
  87. data/lib/morpheus/cli/version.rb +1 -1
  88. data/lib/morpheus/cli.rb +1 -0
  89. data/lib/morpheus/ext/string.rb +29 -6
  90. data/lib/morpheus/routes.rb +238 -0
  91. data/lib/morpheus/util.rb +6 -1
  92. metadata +26 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09fb64a860681d1b04e678410b8f69cd981e950c476a52377c0d9630cdc9af92'
4
- data.tar.gz: c9d15338a5e8e801608b0098345656d6bd9a19ade174005aba2948596ef289b5
3
+ metadata.gz: c4a903c14e297c4ac0a1e4122f2348e997844c31051f7eb5e966663e3014adf9
4
+ data.tar.gz: 4f1ee47b1c73c9f6e9a00bcc7faec384e46a798b29e1a11138361b4f574ca544
5
5
  SHA512:
6
- metadata.gz: ae7e456cf6c52ef57ee80d1ae77601a5297ae48612bd5088cffb8a74ec8f170da14850de931e7a34bc16a4aecedd69b0c2191ad4b981200c82cf53a24ed7b662
7
- data.tar.gz: 25d57f2dbc6350fd59209a1422a1820203cb51060bd57ab538b12b8f47daf5fe0a781672eb733d3b5ebdc973fc82a3dc6d01d5724eb3ece09414b7fc6138704d
6
+ metadata.gz: 87adf644de800a8a79d474fdf686d02061216b5033d7a83030e46f9824c150d1089c42cf87099667a3cd3ec76f1b62683946a05ec7e4395febbd7f623267dcd7
7
+ data.tar.gz: 013a285d1d21b26ffd89aec19c918626879de2fff8496684dc7cea85ea50fa92e54e187d0af93ac93e0f8f435101b9f40f8f55762b94579e59110c15cd3c0829
data/Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
1
  FROM ruby:2.5.1
2
2
 
3
- RUN gem install morpheus-cli -v 5.4.0
3
+ RUN gem install morpheus-cli -v 5.4.3.1
4
4
 
5
5
  ENTRYPOINT ["morpheus"]
@@ -0,0 +1,68 @@
1
+ require 'morpheus/api/rest_interface'
2
+
3
+ class Morpheus::AccountUsersInterface < Morpheus::RestInterface
4
+
5
+ def base_path(account_id)
6
+ if account_id
7
+ "/api/accounts/#{account_id}/users"
8
+ else
9
+ "/api/users"
10
+ end
11
+ end
12
+
13
+ def list(account_id, params={}, headers={})
14
+ #validate_id!(account_id, "account_id")
15
+ execute(method: :get, url: "#{build_url(account_id)}", params: params, headers: headers)
16
+ end
17
+
18
+ def get(account_id, id, params={}, headers={})
19
+ #validate_id!(account_id, "account_id")
20
+ validate_id!(id)
21
+ execute(method: :get, url: "#{build_url(account_id, id)}", params: params, headers: headers)
22
+ end
23
+
24
+ def create(account_id, payload, params={}, headers={})
25
+ #validate_id!(account_id, "account_id")
26
+ execute(method: :post, url: "#{build_url(account_id)}", params: params, payload: payload, headers: headers)
27
+ end
28
+
29
+ def update(account_id, id, payload, params={}, headers={})
30
+ #validate_id!(account_id, "account_id")
31
+ validate_id!(id)
32
+ execute(method: :put, url: "#{build_url(account_id, id)}", params: params, payload: payload, headers: headers)
33
+ end
34
+
35
+ def destroy(account_id, id, params = {}, headers={})
36
+ #validate_id!(account_id, "account_id")
37
+ validate_id!(id)
38
+ execute(method: :delete, url: "#{build_url(account_id, id)}", params: params, headers: headers)
39
+ end
40
+
41
+ def feature_permissions(account_id, id, params={}, headers={})
42
+ #validate_id!(account_id, "account_id")
43
+ validate_id!(id)
44
+ execute(method: :get, url: "#{build_url(account_id, id)}/feature-permissions", params: params, headers: headers)
45
+ end
46
+
47
+ def permissions(account_id, id, params={}, headers={})
48
+ #validate_id!(account_id, "account_id")
49
+ validate_id!(id)
50
+ execute(method: :get, url: "#{build_url(account_id, id)}/permissions", params: params, headers: headers)
51
+ end
52
+
53
+ def available_roles(account_id, id=nil, params={}, headers={})
54
+ #validate_id!(account_id, "account_id")
55
+ execute(method: :get, url: "#{build_url(account_id, id)}/available-roles", params: params, headers: headers)
56
+ end
57
+
58
+ private
59
+
60
+ def build_url(account_id, id=nil)
61
+ url = base_path(account_id)
62
+ if id
63
+ url += "/#{CGI::escape(id.to_s)}"
64
+ end
65
+ url
66
+ end
67
+
68
+ end
@@ -242,7 +242,7 @@ class Morpheus::APIClient
242
242
  # @verify_ssl is not used atm
243
243
  # todo: finish this and use it instead of the global variable RestClient.ssl_verification_enabled?
244
244
  # gotta clean up all APIClient subclasses new() methods to support this
245
- # the CliCommand subclasses should be changed to @users_interface = @api_client.users
245
+ # the CliCommand subclasses should be changed to @foos_interface = @api_client.foos
246
246
  # also.. Credentials.new()
247
247
  if @verify_ssl == false
248
248
  opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
@@ -347,7 +347,6 @@ class Morpheus::APIClient
347
347
  end
348
348
 
349
349
  def auth
350
- # Morpheus::AuthInterface.new(common_interface_options).setopts(@options)
351
350
  Morpheus::AuthInterface.new({url: @base_url, client_id: @client_id, verify_ssl: @verify_ssl}).setopts(@options)
352
351
  end
353
352
 
@@ -487,8 +486,12 @@ class Morpheus::APIClient
487
486
  Morpheus::LoadBalancerPoolsInterface.new(common_interface_options).setopts(@options)
488
487
  end
489
488
 
490
- def virtual_servers
491
- Morpheus::VirtualServersInterface.new(common_interface_options).setopts(@options)
489
+ def load_balancer_profiles
490
+ Morpheus::LoadBalancerProfilesInterface.new(common_interface_options).setopts(@options)
491
+ end
492
+
493
+ def load_balancer_monitors
494
+ Morpheus::LoadBalancerMonitorsInterface.new(common_interface_options).setopts(@options)
492
495
  end
493
496
 
494
497
  def tasks
@@ -543,6 +546,10 @@ class Morpheus::APIClient
543
546
  Morpheus::UsersInterface.new(common_interface_options).setopts(@options)
544
547
  end
545
548
 
549
+ def account_users
550
+ Morpheus::AccountUsersInterface.new(common_interface_options).setopts(@options)
551
+ end
552
+
546
553
  def user_groups
547
554
  Morpheus::UserGroupsInterface.new(common_interface_options).setopts(@options)
548
555
  end
@@ -689,6 +696,22 @@ class Morpheus::APIClient
689
696
  Morpheus::StorageProvidersInterface.new(common_interface_options).setopts(@options)
690
697
  end
691
698
 
699
+ def storage_servers
700
+ Morpheus::StorageServersInterface.new(common_interface_options).setopts(@options)
701
+ end
702
+
703
+ def storage_server_types
704
+ Morpheus::StorageServerTypesInterface.new(common_interface_options).setopts(@options)
705
+ end
706
+
707
+ def storage_volumes
708
+ Morpheus::StorageVolumesInterface.new(common_interface_options).setopts(@options)
709
+ end
710
+
711
+ def storage_volume_types
712
+ Morpheus::StorageVolumeTypesInterface.new(common_interface_options).setopts(@options)
713
+ end
714
+
692
715
  def library_instance_types
693
716
  Morpheus::LibraryInstanceTypesInterface.new(common_interface_options).setopts(@options)
694
717
  end
@@ -773,14 +796,18 @@ class Morpheus::APIClient
773
796
  Morpheus::WikiInterface.new(common_interface_options).setopts(@options)
774
797
  end
775
798
 
776
- def budgets
777
- Morpheus::BudgetsInterface.new(common_interface_options).setopts(@options)
778
- end
779
-
780
799
  def health
781
800
  Morpheus::HealthInterface.new(common_interface_options).setopts(@options)
782
801
  end
783
802
 
803
+ def audit
804
+ Morpheus::AuditInterface.new(common_interface_options).setopts(@options)
805
+ end
806
+
807
+ def budgets
808
+ Morpheus::BudgetsInterface.new(common_interface_options).setopts(@options)
809
+ end
810
+
784
811
  def invoices
785
812
  Morpheus::InvoicesInterface.new(common_interface_options).setopts(@options)
786
813
  end
@@ -856,17 +883,35 @@ class Morpheus::APIClient
856
883
  def network_dhcp_relays
857
884
  Morpheus::NetworkDhcpRelaysInterface.new(common_interface_options).setopts(@options)
858
885
  end
886
+
887
+ def network_static_routes
888
+ Morpheus::NetworkStaticRoutesInterface.new(common_interface_options).setopts(@options)
889
+ end
890
+
891
+ def snapshots
892
+ Morpheus::SnapshotsInterface.new(common_interface_options).setopts(@options)
893
+ end
859
894
 
860
895
  def rest(endpoint)
861
896
  Morpheus::RestInterface.new(common_interface_options).setopts(@options.merge({base_path: "#{@base_url}/api/#{endpoint}"}))
862
897
  end
863
898
 
899
+ def interface(type)
900
+ type = type.to_s.singularize.underscore
901
+ interface_name = type.pluralize
902
+ if !respond_to?(interface_name)
903
+ raise "#{self.class} has not defined an interface method named '#{interface_name}'"
904
+ end
905
+ return send(interface_name)
906
+ end
907
+ alias :get_interface :interface
908
+
864
909
  # add new interfaces here
865
910
 
866
911
  protected
867
912
 
868
- def validate_id!(id)
869
- raise "#{self.class} passed a blank id!" if id.to_s.strip.empty?
913
+ def validate_id!(id, param_name='id')
914
+ raise "#{self.class} passed a blank #{param_name}!" if id.to_s.strip.empty?
870
915
  end
871
916
 
872
917
  end
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/read_interface'
2
+
3
+ class Morpheus::AuditInterface < Morpheus::ReadInterface
4
+
5
+ def base_path
6
+ "/api/audit"
7
+ end
8
+
9
+ end
@@ -6,4 +6,24 @@ class Morpheus::CatalogItemTypesInterface < Morpheus::RestInterface
6
6
  "/api/catalog-item-types"
7
7
  end
8
8
 
9
+ # NOT json, multipart file upload
10
+ # def update_logo(id, logo_file)
11
+ # url = "#{base_path}/#{id}/update-logo"
12
+ # headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
13
+ # payload = {}
14
+ # payload[:logo] = logo_file
15
+ # payload[:multipart] = true
16
+ # execute(method: :post, url: url, headers: headers, payload: payload)
17
+ # end
18
+
19
+ # NOT json, multipart file upload, uses PUT update endpoint
20
+ def update_logo(id, logo_file)
21
+ url = "#{base_path}/#{id}"
22
+ headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
23
+ payload = {}
24
+ payload["catalogItemType"] = {"logo" => logo_file}
25
+ payload[:multipart] = true
26
+ execute(method: :put, url: url, headers: headers, payload: payload)
27
+ end
28
+
9
29
  end
@@ -262,6 +262,34 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
262
262
  execute(opts)
263
263
  end
264
264
 
265
+ def revert_to_snapshot(id, snapshot_id, payload={})
266
+ url = "#{@base_url}/api/instances/#{id}/revert-snapshot/#{snapshot_id}"
267
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
268
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
269
+ execute(opts)
270
+ end
271
+
272
+ def remove_all_container_snapshots(id, container_id, payload={})
273
+ url = "#{@base_url}/api/instances/#{id}/delete-container-snapshots/#{container_id}"
274
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
275
+ opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
276
+ execute(opts)
277
+ end
278
+
279
+ def remove_all_instance_snapshots(id, payload={})
280
+ url = "#{@base_url}/api/instances/#{id}/delete-all-snapshots"
281
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
282
+ opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
283
+ execute(opts)
284
+ end
285
+
286
+ def create_linked_clone(id, snapshot_id, payload={})
287
+ url = "#{@base_url}/api/instances/#{id}/linked-clone/#{snapshot_id}"
288
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
289
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
290
+ execute(opts)
291
+ end
292
+
265
293
  def service_plans(params={})
266
294
  url = "#{@base_url}/api/instances/service-plans"
267
295
  headers = { params: params, authorization: "Bearer #{@access_token}" }
@@ -344,4 +372,25 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
344
372
  execute(method: :get, url: "/api/instances/#{id}/deploy", params: params)
345
373
  end
346
374
 
375
+ def refresh(id, params, payload)
376
+ url = "#{@base_url}/api/instances/#{id}/refresh"
377
+ headers = {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
378
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
379
+ execute(opts)
380
+ end
381
+
382
+ def apply(id, params, payload)
383
+ url = "#{@base_url}/api/instances/#{id}/apply"
384
+ headers = {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
385
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
386
+ execute(opts)
387
+ end
388
+
389
+ def state_summary(id, params={})
390
+ url = "#{@base_url}/api/instances/#{id}/state-summary"
391
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
392
+ opts = {method: :get, url: url, headers: headers}
393
+ execute(opts)
394
+ end
395
+
347
396
  end
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/secondary_rest_interface'
2
+
3
+ class Morpheus::LoadBalancerMonitorsInterface < Morpheus::SecondaryRestInterface
4
+
5
+ def base_path(load_balancer_id)
6
+ "/api/load-balancers/#{load_balancer_id}/monitors"
7
+ end
8
+
9
+ end
@@ -1,9 +1,9 @@
1
- require 'morpheus/api/rest_interface'
1
+ require 'morpheus/api/secondary_rest_interface'
2
2
 
3
- class Morpheus::LoadBalancerPoolsInterface < Morpheus::RestInterface
3
+ class Morpheus::LoadBalancerPoolsInterface < Morpheus::SecondaryRestInterface
4
4
 
5
- def base_path
6
- "/api/load-balancer-pools"
5
+ def base_path(load_balancer_id)
6
+ "/api/load-balancers/#{load_balancer_id}/pools"
7
7
  end
8
8
 
9
9
  end
@@ -1,10 +1,9 @@
1
- require 'morpheus/api/rest_interface'
1
+ require 'morpheus/api/secondary_rest_interface'
2
2
 
3
- class Morpheus::LoadBalancerProfilesInterface < Morpheus::RestInterface
3
+ class Morpheus::LoadBalancerProfilesInterface < Morpheus::SecondaryRestInterface
4
4
 
5
- def base_path
6
- "/api/load-balancer-profiles"
5
+ def base_path(load_balancer_id)
6
+ "/api/load-balancers/#{load_balancer_id}/profiles"
7
7
  end
8
8
 
9
9
  end
10
-
@@ -1,9 +1,18 @@
1
- require 'morpheus/api/rest_interface'
1
+ require 'morpheus/api/secondary_rest_interface'
2
2
 
3
- class Morpheus::LoadBalancerVirtualServersInterface < Morpheus::RestInterface
3
+ class Morpheus::LoadBalancerVirtualServersInterface < Morpheus::SecondaryRestInterface
4
4
 
5
- def base_path
6
- "/api/load-balancer-virtual-servers"
5
+ def base_path(load_balancer_id)
6
+ "/api/load-balancers/#{load_balancer_id}/virtual-servers"
7
+ end
8
+
9
+ def list(parent_id=nil, params={}, headers={})
10
+ if parent_id
11
+ validate_id!(parent_id)
12
+ execute(method: :get, url: "#{base_path(parent_id)}", params: params, headers: headers)
13
+ else
14
+ execute(method: :get, url: "/api/load-balancer-virtual-servers", params: params, headers: headers)
15
+ end
7
16
  end
8
17
 
9
18
  end
@@ -6,4 +6,9 @@ class Morpheus::LoadBalancersInterface < Morpheus::RestInterface
6
6
  "/api/load-balancers"
7
7
  end
8
8
 
9
+ def refresh(id, payload, params={}, headers={})
10
+ validate_id!(id)
11
+ execute(method: :put, url: "#{base_path}/#{CGI::escape(id.to_s)}/refresh", params: params, payload: payload, headers: headers)
12
+ end
13
+
9
14
  end
@@ -66,6 +66,15 @@ class Morpheus::NetworkRoutersInterface < Morpheus::APIClient
66
66
  execute(opts)
67
67
  end
68
68
 
69
+ def get_firewall_rule_group(router_id, group_id, params={})
70
+ raise "#{self.class}.get() passed a blank router id!" if router_id.to_s == ''
71
+ raise "#{self.class}.get() passed a blank group id!" if group_id.to_s == ''
72
+ url = "#{@base_url}/api/networks/routers/#{router_id}/firewall-rule-groups/#{group_id}"
73
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
74
+ opts = {method: :get, url: url, headers: headers}
75
+ execute(opts)
76
+ end
77
+
69
78
  def create_firewall_rule_group(router_id, payload={})
70
79
  url = "#{@base_url}/api/networks/routers/#{router_id}/firewall-rule-groups"
71
80
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
@@ -0,0 +1,36 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::NetworkStaticRoutesInterface < Morpheus::RestInterface
4
+
5
+ def base_path
6
+ "/api/networks"
7
+ end
8
+
9
+ def get_static_route(network_id, route_id, params={}, headers={})
10
+ validate_id!(network_id)
11
+ validate_id!(route_id)
12
+ execute(method: :get, url: "#{base_path}/#{network_id}/routes/#{route_id}", params: params, headers: headers)
13
+ end
14
+
15
+ def list_static_routes(network_id, params={}, headers={})
16
+ validate_id!(network_id)
17
+ execute(method: :get, url: "#{base_path}/#{network_id}/routes", params: params, headers: headers)
18
+ end
19
+
20
+ def create_static_route(network_id, payload, params={}, headers={})
21
+ validate_id!(network_id)
22
+ execute(method: :post, url: "#{base_path}/#{network_id}/routes", params: params, payload: payload, headers: headers)
23
+ end
24
+
25
+ def update_static_route(network_id, route_id, payload, params={}, headers={})
26
+ validate_id!(network_id)
27
+ validate_id!(route_id)
28
+ execute(method: :put, url: "#{base_path}/#{network_id}/routes/#{route_id}", params: params, payload: payload, headers: headers)
29
+ end
30
+
31
+ def delete_static_route(network_id, route_id, params={}, headers={})
32
+ validate_id!(network_id)
33
+ validate_id!(route_id)
34
+ execute(method: :delete, url: "#{base_path}/#{network_id}/routes/#{route_id}", params: params, headers: headers)
35
+ end
36
+ end
@@ -14,6 +14,8 @@ class Morpheus::PingInterface < Morpheus::APIClient
14
14
 
15
15
  def get(params={})
16
16
  headers = {params: params}
17
+ # use access token if authenticated
18
+ headers[:authorization] = "Bearer #{@access_token}" if @access_token
17
19
  execute(method: :get, url: "/api/ping", headers: headers)
18
20
  end
19
21
 
@@ -6,9 +6,10 @@ require 'morpheus/api/api_client'
6
6
  class Morpheus::ReadInterface < Morpheus::APIClient
7
7
 
8
8
  # subclasses should override in your interface
9
- # Example: "/api/thing-types"
9
+ # Example: "/api/things"
10
10
  def base_path
11
- raise "#{self.class} has not defined base_path!"
11
+ raise "#{self.class} has not defined base_path!" if @options[:base_path].nil?
12
+ @options[:base_path]
12
13
  end
13
14
 
14
15
  def list(params={}, headers={})
@@ -17,7 +18,7 @@ class Morpheus::ReadInterface < Morpheus::APIClient
17
18
 
18
19
  def get(id, params={}, headers={})
19
20
  validate_id!(id)
20
- execute(method: :get, url: "#{base_path}/#{id}", params: params, headers: headers)
21
+ execute(method: :get, url: "#{base_path}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
21
22
  end
22
23
 
23
24
  end
@@ -17,7 +17,7 @@ class Morpheus::RestInterface < Morpheus::APIClient
17
17
 
18
18
  def get(id, params={}, headers={})
19
19
  validate_id!(id)
20
- execute(method: :get, url: "#{base_path}/#{id}", params: params, headers: headers)
20
+ execute(method: :get, url: "#{base_path}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
21
21
  end
22
22
 
23
23
  def create(payload, params={}, headers={})
@@ -26,12 +26,12 @@ class Morpheus::RestInterface < Morpheus::APIClient
26
26
 
27
27
  def update(id, payload, params={}, headers={})
28
28
  validate_id!(id)
29
- execute(method: :put, url: "#{base_path}/#{id}", params: params, payload: payload, headers: headers)
29
+ execute(method: :put, url: "#{base_path}/#{CGI::escape(id.to_s)}", params: params, payload: payload, headers: headers)
30
30
  end
31
31
 
32
32
  def destroy(id, params = {}, headers={})
33
33
  validate_id!(id)
34
- execute(method: :delete, url: "#{base_path}/#{id}", params: params, headers: headers)
34
+ execute(method: :delete, url: "#{base_path}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
35
35
  end
36
36
 
37
37
  end
@@ -19,7 +19,7 @@ class Morpheus::SecondaryReadInterface < Morpheus::APIClient
19
19
  def get(resource_id, id, params={}, headers={})
20
20
  validate_id!(resource_id)
21
21
  validate_id!(id)
22
- execute(method: :get, url: "#{base_path(resource_id)}/#{id}", params: params, headers: headers)
22
+ execute(method: :get, url: "#{base_path(resource_id)}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
23
23
  end
24
24
 
25
25
  end
@@ -2,41 +2,41 @@ require 'morpheus/api/api_client'
2
2
 
3
3
  # Interface class to be subclassed by interfaces that provide CRUD endpoints
4
4
  # for objects underneath another resource
5
- # Subclasses must override the base_path(resource_id) method
5
+ # Subclasses must override the base_path(parent_id) method
6
6
  class Morpheus::SecondaryRestInterface < Morpheus::APIClient
7
7
 
8
8
  # subclasses should override in your interface
9
- # Example: "/api/things/#{resource_id}/widgets"
10
- def base_path(resource_id)
11
- raise "#{self.class} has not defined base_path(resource_id)!"
9
+ # Example: "/api/things/#{parent_id}/widgets"
10
+ def base_path(parent_id)
11
+ raise "#{self.class} has not defined base_path(parent_id)!"
12
12
  end
13
13
 
14
- def list(resource_id, params={}, headers={})
15
- validate_id!(resource_id)
16
- execute(method: :get, url: "#{base_path(resource_id)}", params: params, headers: headers)
14
+ def list(parent_id, params={}, headers={})
15
+ validate_id!(parent_id)
16
+ execute(method: :get, url: "#{base_path(parent_id)}", params: params, headers: headers)
17
17
  end
18
18
 
19
- def get(resource_id, id, params={}, headers={})
20
- validate_id!(resource_id)
19
+ def get(parent_id, id, params={}, headers={})
20
+ validate_id!(parent_id)
21
21
  validate_id!(id)
22
- execute(method: :get, url: "#{base_path(resource_id)}/#{id}", params: params, headers: headers)
22
+ execute(method: :get, url: "#{base_path(parent_id)}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
23
23
  end
24
24
 
25
- def create(resource_id, payload, params={}, headers={})
26
- validate_id!(resource_id)
27
- execute(method: :post, url: "#{base_path(resource_id)}", params: params, payload: payload, headers: headers)
25
+ def create(parent_id, payload, params={}, headers={})
26
+ validate_id!(parent_id)
27
+ execute(method: :post, url: "#{base_path(parent_id)}", params: params, payload: payload, headers: headers)
28
28
  end
29
29
 
30
- def update(resource_id, id, payload, params={}, headers={})
31
- validate_id!(resource_id)
30
+ def update(parent_id, id, payload, params={}, headers={})
31
+ validate_id!(parent_id)
32
32
  validate_id!(id)
33
- execute(method: :put, url: "#{base_path(resource_id)}/#{id}", params: params, payload: payload, headers: headers)
33
+ execute(method: :put, url: "#{base_path(parent_id)}/#{CGI::escape(id.to_s)}", params: params, payload: payload, headers: headers)
34
34
  end
35
35
 
36
- def destroy(resource_id, id, params = {}, headers={})
37
- validate_id!(resource_id)
36
+ def destroy(parent_id, id, params = {}, headers={})
37
+ validate_id!(parent_id)
38
38
  validate_id!(id)
39
- execute(method: :delete, url: "#{base_path(resource_id)}/#{id}", params: params, headers: headers)
39
+ execute(method: :delete, url: "#{base_path(parent_id)}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
40
40
  end
41
41
 
42
42
  end
@@ -14,12 +14,16 @@ class Morpheus::SetupInterface < Morpheus::APIClient
14
14
 
15
15
  def get(params={})
16
16
  headers = {params: params}
17
+ # use access token if authenticated
18
+ headers[:authorization] = "Bearer #{@access_token}" if @access_token
17
19
  execute(method: :get, url: "/api/setup", headers: headers)
18
20
  end
19
21
 
20
22
  #this should go away and just use
21
23
  def check(params={}, timeout=5)
22
24
  headers = {params: params}
25
+ # use access token if authenticated
26
+ headers[:authorization] = "Bearer #{@access_token}" if @access_token
23
27
  execute(method: :get, url: "/api/setup/check", headers: headers, timeout: timeout)
24
28
  end
25
29
 
@@ -0,0 +1,19 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ # Snapshots API interface.
4
+ class Morpheus::SnapshotsInterface < Morpheus::APIClient
5
+
6
+ def get(snapshot_id)
7
+ url = "#{@base_url}/api/snapshots/#{snapshot_id}"
8
+ headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
9
+ opts = {method: :get, url: url, headers: headers}
10
+ execute(opts)
11
+ end
12
+
13
+ def remove(snapshot_id, payload={})
14
+ url = "#{@base_url}/api/snapshots/#{snapshot_id}"
15
+ headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
16
+ opts = {method: :delete, url: url, headers: headers, payload: payload.to_json}
17
+ execute(opts)
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ require 'morpheus/api/read_interface'
2
+
3
+ class Morpheus::StorageServerTypesInterface < Morpheus::ReadInterface
4
+
5
+ def base_path
6
+ "/api/storage-server-types"
7
+ end
8
+
9
+ # def option_types(id, params={}, headers={})
10
+ # validate_id!(id)
11
+ # execute(method: :get, url: "#{base_path}/#{id}/option-types", params: params, headers: headers)
12
+ # end
13
+
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/rest_interface'
2
+
3
+ class Morpheus::StorageServersInterface < Morpheus::RestInterface
4
+
5
+ def base_path
6
+ "/api/storage-servers"
7
+ end
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/read_interface'
2
+
3
+ class Morpheus::StorageVolumeTypesInterface < Morpheus::ReadInterface
4
+
5
+ def base_path
6
+ "/api/storage-volume-types"
7
+ end
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'morpheus/api/rest_interface'
2
+
3
+ class Morpheus::StorageVolumesInterface < Morpheus::RestInterface
4
+
5
+ def base_path
6
+ "/api/storage-volumes"
7
+ end
8
+
9
+ end