morpheus-cli 5.4.0 → 5.4.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 (75) 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 +51 -9
  5. data/lib/morpheus/api/audit_interface.rb +9 -0
  6. data/lib/morpheus/api/instances_interface.rb +21 -0
  7. data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
  8. data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
  9. data/lib/morpheus/api/load_balancer_profiles_interface.rb +4 -5
  10. data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +13 -4
  11. data/lib/morpheus/api/load_balancers_interface.rb +5 -0
  12. data/lib/morpheus/api/network_routers_interface.rb +9 -0
  13. data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
  14. data/lib/morpheus/api/read_interface.rb +4 -3
  15. data/lib/morpheus/api/rest_interface.rb +3 -3
  16. data/lib/morpheus/api/secondary_read_interface.rb +1 -1
  17. data/lib/morpheus/api/secondary_rest_interface.rb +19 -19
  18. data/lib/morpheus/api/storage_server_types_interface.rb +14 -0
  19. data/lib/morpheus/api/storage_servers_interface.rb +9 -0
  20. data/lib/morpheus/api/storage_volume_types_interface.rb +9 -0
  21. data/lib/morpheus/api/storage_volumes_interface.rb +9 -0
  22. data/lib/morpheus/api/users_interface.rb +16 -63
  23. data/lib/morpheus/cli/cli_command.rb +253 -5
  24. data/lib/morpheus/cli/cli_registry.rb +1 -1
  25. data/lib/morpheus/cli/commands/alias_command.rb +1 -1
  26. data/lib/morpheus/cli/commands/apps.rb +14 -78
  27. data/lib/morpheus/cli/commands/audit.rb +188 -0
  28. data/lib/morpheus/cli/commands/blueprints_command.rb +1 -1
  29. data/lib/morpheus/cli/commands/change_password_command.rb +4 -4
  30. data/lib/morpheus/cli/commands/clusters.rb +37 -12
  31. data/lib/morpheus/cli/commands/hosts.rb +15 -15
  32. data/lib/morpheus/cli/commands/instances.rb +109 -2
  33. data/lib/morpheus/cli/commands/load_balancer_monitors.rb +71 -0
  34. data/lib/morpheus/cli/commands/load_balancer_pools.rb +30 -50
  35. data/lib/morpheus/cli/commands/load_balancer_profiles.rb +65 -0
  36. data/lib/morpheus/cli/commands/load_balancer_types.rb +9 -4
  37. data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +77 -57
  38. data/lib/morpheus/cli/commands/load_balancers.rb +93 -6
  39. data/lib/morpheus/cli/commands/network_firewalls_command.rb +22 -5
  40. data/lib/morpheus/cli/commands/network_routers_command.rb +96 -45
  41. data/lib/morpheus/cli/commands/network_static_routes_command.rb +446 -0
  42. data/lib/morpheus/cli/commands/network_transport_zones_command.rb +4 -4
  43. data/lib/morpheus/cli/commands/open_command.rb +30 -0
  44. data/lib/morpheus/cli/commands/options.rb +98 -0
  45. data/lib/morpheus/cli/commands/policies_command.rb +1 -1
  46. data/lib/morpheus/cli/commands/prices_command.rb +7 -7
  47. data/lib/morpheus/cli/commands/remote.rb +4 -2
  48. data/lib/morpheus/cli/commands/roles.rb +1 -1
  49. data/lib/morpheus/cli/commands/shell.rb +2 -2
  50. data/lib/morpheus/cli/commands/storage_server_types.rb +50 -0
  51. data/lib/morpheus/cli/commands/storage_servers.rb +122 -0
  52. data/lib/morpheus/cli/commands/storage_volume_types.rb +50 -0
  53. data/lib/morpheus/cli/commands/storage_volumes.rb +103 -0
  54. data/lib/morpheus/cli/commands/tenants_command.rb +1 -1
  55. data/lib/morpheus/cli/commands/user_groups_command.rb +1 -1
  56. data/lib/morpheus/cli/commands/user_settings_command.rb +2 -1
  57. data/lib/morpheus/cli/commands/user_sources_command.rb +1 -1
  58. data/lib/morpheus/cli/commands/users.rb +28 -28
  59. data/lib/morpheus/cli/commands/view.rb +102 -0
  60. data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
  61. data/lib/morpheus/cli/mixins/load_balancers_helper.rb +24 -4
  62. data/lib/morpheus/cli/mixins/print_helper.rb +50 -18
  63. data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
  64. data/lib/morpheus/cli/mixins/provisioning_helper.rb +15 -5
  65. data/lib/morpheus/cli/mixins/rest_command.rb +145 -73
  66. data/lib/morpheus/cli/mixins/secondary_rest_command.rb +174 -81
  67. data/lib/morpheus/cli/mixins/storage_servers_helper.rb +156 -0
  68. data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +119 -0
  69. data/lib/morpheus/cli/option_types.rb +45 -24
  70. data/lib/morpheus/cli/version.rb +1 -1
  71. data/lib/morpheus/cli.rb +1 -0
  72. data/lib/morpheus/ext/string.rb +29 -6
  73. data/lib/morpheus/routes.rb +238 -0
  74. data/lib/morpheus/util.rb +6 -1
  75. metadata +29 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09fb64a860681d1b04e678410b8f69cd981e950c476a52377c0d9630cdc9af92'
4
- data.tar.gz: c9d15338a5e8e801608b0098345656d6bd9a19ade174005aba2948596ef289b5
3
+ metadata.gz: 6cb700dea3828e709872e3cbdd2273b369aeee43bc7f451a305101ee3e0d7385
4
+ data.tar.gz: 19414673dc1b1631b4221f6c280228cbc14f49b2a4356bc45a3a98a67bdfa9a6
5
5
  SHA512:
6
- metadata.gz: ae7e456cf6c52ef57ee80d1ae77601a5297ae48612bd5088cffb8a74ec8f170da14850de931e7a34bc16a4aecedd69b0c2191ad4b981200c82cf53a24ed7b662
7
- data.tar.gz: 25d57f2dbc6350fd59209a1422a1820203cb51060bd57ab538b12b8f47daf5fe0a781672eb733d3b5ebdc973fc82a3dc6d01d5724eb3ece09414b7fc6138704d
6
+ metadata.gz: f1cc0cd19da8b84cff01f68e92ad8f82261bb399beff06b99461b4e9fc4fa76b5e1553e3f7a2aacf0dff746f858b9ef805f9d5a2c058da3af7d71fbd2bf616cc
7
+ data.tar.gz: dc86c29c0192b1b82b5f449f6c1803f7476164c4444f7ee285d3db5397d7778ae0e45438b14ca27feab8d14269222cc59a17dd7a329c6962aeb8bd8cf2bb6962
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.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
@@ -487,8 +487,12 @@ class Morpheus::APIClient
487
487
  Morpheus::LoadBalancerPoolsInterface.new(common_interface_options).setopts(@options)
488
488
  end
489
489
 
490
- def virtual_servers
491
- Morpheus::VirtualServersInterface.new(common_interface_options).setopts(@options)
490
+ def load_balancer_profiles
491
+ Morpheus::LoadBalancerProfilesInterface.new(common_interface_options).setopts(@options)
492
+ end
493
+
494
+ def load_balancer_monitors
495
+ Morpheus::LoadBalancerMonitorsInterface.new(common_interface_options).setopts(@options)
492
496
  end
493
497
 
494
498
  def tasks
@@ -543,6 +547,10 @@ class Morpheus::APIClient
543
547
  Morpheus::UsersInterface.new(common_interface_options).setopts(@options)
544
548
  end
545
549
 
550
+ def account_users
551
+ Morpheus::AccountUsersInterface.new(common_interface_options).setopts(@options)
552
+ end
553
+
546
554
  def user_groups
547
555
  Morpheus::UserGroupsInterface.new(common_interface_options).setopts(@options)
548
556
  end
@@ -689,6 +697,22 @@ class Morpheus::APIClient
689
697
  Morpheus::StorageProvidersInterface.new(common_interface_options).setopts(@options)
690
698
  end
691
699
 
700
+ def storage_servers
701
+ Morpheus::StorageServersInterface.new(common_interface_options).setopts(@options)
702
+ end
703
+
704
+ def storage_server_types
705
+ Morpheus::StorageServerTypesInterface.new(common_interface_options).setopts(@options)
706
+ end
707
+
708
+ def storage_volumes
709
+ Morpheus::StorageVolumesInterface.new(common_interface_options).setopts(@options)
710
+ end
711
+
712
+ def storage_volume_types
713
+ Morpheus::StorageVolumeTypesInterface.new(common_interface_options).setopts(@options)
714
+ end
715
+
692
716
  def library_instance_types
693
717
  Morpheus::LibraryInstanceTypesInterface.new(common_interface_options).setopts(@options)
694
718
  end
@@ -773,14 +797,18 @@ class Morpheus::APIClient
773
797
  Morpheus::WikiInterface.new(common_interface_options).setopts(@options)
774
798
  end
775
799
 
776
- def budgets
777
- Morpheus::BudgetsInterface.new(common_interface_options).setopts(@options)
778
- end
779
-
780
800
  def health
781
801
  Morpheus::HealthInterface.new(common_interface_options).setopts(@options)
782
802
  end
783
803
 
804
+ def audit
805
+ Morpheus::AuditInterface.new(common_interface_options).setopts(@options)
806
+ end
807
+
808
+ def budgets
809
+ Morpheus::BudgetsInterface.new(common_interface_options).setopts(@options)
810
+ end
811
+
784
812
  def invoices
785
813
  Morpheus::InvoicesInterface.new(common_interface_options).setopts(@options)
786
814
  end
@@ -856,17 +884,31 @@ class Morpheus::APIClient
856
884
  def network_dhcp_relays
857
885
  Morpheus::NetworkDhcpRelaysInterface.new(common_interface_options).setopts(@options)
858
886
  end
887
+
888
+ def network_static_routes
889
+ Morpheus::NetworkStaticRoutesInterface.new(common_interface_options).setopts(@options)
890
+ end
859
891
 
860
892
  def rest(endpoint)
861
893
  Morpheus::RestInterface.new(common_interface_options).setopts(@options.merge({base_path: "#{@base_url}/api/#{endpoint}"}))
862
894
  end
863
895
 
896
+ def interface(type)
897
+ type = type.to_s.singularize.underscore
898
+ interface_name = type.pluralize
899
+ if !respond_to?(interface_name)
900
+ raise "#{self.class} has not defined an interface method named '#{interface_name}'"
901
+ end
902
+ return send(interface_name)
903
+ end
904
+ alias :get_interface :interface
905
+
864
906
  # add new interfaces here
865
907
 
866
908
  protected
867
909
 
868
- def validate_id!(id)
869
- raise "#{self.class} passed a blank id!" if id.to_s.strip.empty?
910
+ def validate_id!(id, param_name='id')
911
+ raise "#{self.class} passed a blank #{param_name}!" if id.to_s.strip.empty?
870
912
  end
871
913
 
872
914
  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
@@ -344,4 +344,25 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
344
344
  execute(method: :get, url: "/api/instances/#{id}/deploy", params: params)
345
345
  end
346
346
 
347
+ def refresh(id, params, payload)
348
+ url = "#{@base_url}/api/instances/#{id}/refresh"
349
+ headers = {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
350
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
351
+ execute(opts)
352
+ end
353
+
354
+ def apply(id, params, payload)
355
+ url = "#{@base_url}/api/instances/#{id}/apply"
356
+ headers = {:params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
357
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
358
+ execute(opts)
359
+ end
360
+
361
+ def state_summary(id, params={})
362
+ url = "#{@base_url}/api/instances/#{id}/state-summary"
363
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
364
+ opts = {method: :get, url: url, headers: headers}
365
+ execute(opts)
366
+ end
367
+
347
368
  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
@@ -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
@@ -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
@@ -1,78 +1,31 @@
1
- require 'morpheus/api/api_client'
1
+ require 'morpheus/api/rest_interface'
2
2
 
3
- class Morpheus::UsersInterface < Morpheus::APIClient
3
+ class Morpheus::UsersInterface < Morpheus::RestInterface
4
4
 
5
- def get(account_id, id, params={})
6
- raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
7
- url = build_url(account_id, id)
8
- headers = { params: params, authorization: "Bearer #{@access_token}" }
9
- opts = {method: :get, url: url, timeout: 10, headers: headers}
10
- execute(opts)
5
+ def base_path
6
+ "/api/users"
11
7
  end
12
8
 
13
- def list(account_id, params={})
14
- url = build_url(account_id)
15
- headers = { params: params, authorization: "Bearer #{@access_token}" }
16
- opts = {method: :get, url: url, timeout: 10, headers: headers}
17
- execute(opts)
9
+ def feature_permissions(id, params={}, headers={})
10
+ validate_id!(id)
11
+ execute(method: :get, url: "#{base_path}/#{id}/feature-permissions", params: params, headers: headers)
18
12
  end
19
13
 
20
- def feature_permissions(account_id, id)
21
- url = build_url(account_id, id) + "/feature-permissions"
22
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
23
- opts = {method: :get, url: url, timeout: 10, headers: headers}
24
- execute(opts)
14
+ def permissions(id, params={}, headers={})
15
+ validate_id!(id)
16
+ execute(method: :get, url: "#{base_path}/#{id}/permissions", params: params, headers: headers)
25
17
  end
26
18
 
27
- def permissions(account_id, id)
28
- url = build_url(account_id, id) + "/permissions"
29
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
30
- opts = {method: :get, url: url, timeout: 10, headers: headers}
31
- execute(opts)
32
- end
33
-
34
- def available_roles(account_id, id=nil, options={})
35
- url = build_url(account_id, id) + "/available-roles"
36
- headers = { params: {}, authorization: "Bearer #{@access_token}" }
37
- headers[:params].merge!(options)
38
- opts = {method: :get, url: url, timeout: 10, headers: headers}
39
- execute(opts)
40
- end
41
-
42
- def create(account_id, options)
43
- url = build_url(account_id)
44
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
45
- payload = options
46
- opts = {method: :post, url: url, timeout: 10, headers: headers, payload: payload.to_json}
47
- execute(opts)
48
- end
49
-
50
- def update(account_id, id, options)
51
- url = build_url(account_id, id)
52
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
53
- payload = options
54
- opts = {method: :put, url: url, timeout: 10, headers: headers, payload: payload.to_json}
55
- execute(opts)
56
- end
57
-
58
- def destroy(account_id, id)
59
- url = build_url(account_id, id)
60
- headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
61
- opts = {method: :delete, url: url, timeout: 10, headers: headers}
62
- execute(opts)
19
+ def available_roles(id=nil, params={}, headers={})
20
+ execute(method: :get, url: "#{build_url(id)}/available-roles", params: params, headers: headers)
63
21
  end
64
22
 
65
23
  private
66
24
 
67
- def build_url(account_id=nil, user_id=nil)
68
- url = "#{@base_url}/api"
69
- if account_id
70
- url += "/accounts/#{account_id}/users"
71
- else
72
- url += "/users"
73
- end
74
- if user_id
75
- url += "/#{user_id}"
25
+ def build_url(id=nil)
26
+ url = base_path
27
+ if id
28
+ url += "/#{id}"
76
29
  end
77
30
  url
78
31
  end