morpheus-cli 5.3.2.2 → 5.4.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 (182) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/api_client.rb +26 -1
  4. data/lib/morpheus/api/clouds_interface.rb +4 -11
  5. data/lib/morpheus/api/health_interface.rb +37 -3
  6. data/lib/morpheus/api/instances_interface.rb +18 -5
  7. data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
  8. data/lib/morpheus/api/load_balancer_profiles_interface.rb +10 -0
  9. data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +4 -4
  10. data/lib/morpheus/api/network_dhcp_relays_interface.rb +36 -0
  11. data/lib/morpheus/api/network_dhcp_servers_interface.rb +36 -0
  12. data/lib/morpheus/api/network_edge_clusters_interface.rb +26 -0
  13. data/lib/morpheus/api/network_routers_interface.rb +21 -0
  14. data/lib/morpheus/api/network_servers_interface.rb +98 -0
  15. data/lib/morpheus/api/rest_interface.rb +2 -1
  16. data/lib/morpheus/api/roles_interface.rb +7 -0
  17. data/lib/morpheus/api/virtual_images_interface.rb +23 -2
  18. data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
  19. data/lib/morpheus/cli/cli_command.rb +21 -14
  20. data/lib/morpheus/cli/cli_registry.rb +56 -2
  21. data/lib/morpheus/cli/{access_token_command.rb → commands/access_token_command.rb} +1 -1
  22. data/lib/morpheus/cli/{account_groups_command.rb → commands/account_groups_command.rb} +0 -8
  23. data/lib/morpheus/cli/{activity_command.rb → commands/activity_command.rb} +0 -0
  24. data/lib/morpheus/cli/commands/{standard/alias_command.rb → alias_command.rb} +0 -3
  25. data/lib/morpheus/cli/{appliance_settings_command.rb → commands/appliance_settings_command.rb} +0 -0
  26. data/lib/morpheus/cli/{approvals_command.rb → commands/approvals_command.rb} +0 -0
  27. data/lib/morpheus/cli/{apps.rb → commands/apps.rb} +3 -11
  28. data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
  29. data/lib/morpheus/cli/{backup_jobs_command.rb → commands/backup_jobs_command.rb} +0 -0
  30. data/lib/morpheus/cli/{backup_settings_command.rb → commands/backup_settings_command.rb} +0 -0
  31. data/lib/morpheus/cli/{backups_command.rb → commands/backups_command.rb} +0 -0
  32. data/lib/morpheus/cli/commands/{standard/benchmark_command.rb → benchmark_command.rb} +0 -3
  33. data/lib/morpheus/cli/{blueprints_command.rb → commands/blueprints_command.rb} +0 -0
  34. data/lib/morpheus/cli/{boot_scripts_command.rb → commands/boot_scripts_command.rb} +0 -3
  35. data/lib/morpheus/cli/{budgets_command.rb → commands/budgets_command.rb} +0 -0
  36. data/lib/morpheus/cli/commands/{standard/cat_command.rb → cat_command.rb} +0 -0
  37. data/lib/morpheus/cli/{catalog_item_types_command.rb → commands/catalog_item_types_command.rb} +0 -0
  38. data/lib/morpheus/cli/{certificates_command.rb → commands/certificates_command.rb} +0 -0
  39. data/lib/morpheus/cli/commands/change_password_command.rb +132 -0
  40. data/lib/morpheus/cli/{cloud_datastores_command.rb → commands/cloud_datastores_command.rb} +0 -4
  41. data/lib/morpheus/cli/{cloud_folders_command.rb → commands/cloud_folders_command.rb} +0 -4
  42. data/lib/morpheus/cli/{cloud_resource_pools_command.rb → commands/cloud_resource_pools_command.rb} +170 -138
  43. data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
  44. data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +51 -39
  45. data/lib/morpheus/cli/commands/{standard/coloring_command.rb → coloring_command.rb} +0 -2
  46. data/lib/morpheus/cli/{containers_command.rb → commands/containers_command.rb} +0 -7
  47. data/lib/morpheus/cli/commands/{standard/curl_command.rb → curl_command.rb} +0 -3
  48. data/lib/morpheus/cli/{cypher_command.rb → commands/cypher_command.rb} +0 -1
  49. data/lib/morpheus/cli/{dashboard_command.rb → commands/dashboard_command.rb} +0 -2
  50. data/lib/morpheus/cli/commands/{standard/debug_command.rb → debug_command.rb} +0 -1
  51. data/lib/morpheus/cli/{deploy.rb → commands/deploy.rb} +0 -1
  52. data/lib/morpheus/cli/{deployments.rb → commands/deployments.rb} +0 -0
  53. data/lib/morpheus/cli/{deploys.rb → commands/deploys.rb} +0 -1
  54. data/lib/morpheus/cli/{doc.rb → commands/doc.rb} +1 -1
  55. data/lib/morpheus/cli/commands/{standard/echo_command.rb → echo_command.rb} +0 -2
  56. data/lib/morpheus/cli/commands/{standard/edit_profile_command.rb → edit_profile_command.rb} +15 -4
  57. data/lib/morpheus/cli/commands/{standard/edit_rc_command.rb → edit_rc_command.rb} +19 -3
  58. data/lib/morpheus/cli/{environments_command.rb → commands/environments_command.rb} +0 -5
  59. data/lib/morpheus/cli/{execute_schedules_command.rb → commands/execute_schedules_command.rb} +0 -0
  60. data/lib/morpheus/cli/{execution_request_command.rb → commands/execution_request_command.rb} +0 -2
  61. data/lib/morpheus/cli/commands/{standard/exit_command.rb → exit_command.rb} +0 -2
  62. data/lib/morpheus/cli/{file_copy_request_command.rb → commands/file_copy_request_command.rb} +0 -4
  63. data/lib/morpheus/cli/{forgot_password.rb → commands/forgot_password.rb} +0 -0
  64. data/lib/morpheus/cli/commands/{standard/get_prompt_command.rb → get_prompt_command.rb} +0 -3
  65. data/lib/morpheus/cli/{groups.rb → commands/groups.rb} +0 -7
  66. data/lib/morpheus/cli/{guidance_command.rb → commands/guidance_command.rb} +1 -1
  67. data/lib/morpheus/cli/{health_command.rb → commands/health_command.rb} +104 -19
  68. data/lib/morpheus/cli/commands/{standard/history_command.rb → history_command.rb} +0 -3
  69. data/lib/morpheus/cli/{hosts.rb → commands/hosts.rb} +0 -10
  70. data/lib/morpheus/cli/{image_builder_command.rb → commands/image_builder_command.rb} +2 -8
  71. data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
  72. data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +364 -148
  73. data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +0 -0
  74. data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +118 -134
  75. data/lib/morpheus/cli/{jobs_command.rb → commands/jobs_command.rb} +0 -0
  76. data/lib/morpheus/cli/{key_pairs.rb → commands/key_pairs.rb} +0 -6
  77. data/lib/morpheus/cli/{library_cluster_layouts_command.rb → commands/library_cluster_layouts_command.rb} +20 -4
  78. data/lib/morpheus/cli/{library_container_scripts_command.rb → commands/library_container_scripts_command.rb} +0 -0
  79. data/lib/morpheus/cli/{library_container_templates_command.rb → commands/library_container_templates_command.rb} +0 -1
  80. data/lib/morpheus/cli/{library_container_types_command.rb → commands/library_container_types_command.rb} +0 -4
  81. data/lib/morpheus/cli/{library_instance_types_command.rb → commands/library_instance_types_command.rb} +0 -4
  82. data/lib/morpheus/cli/{library_layouts_command.rb → commands/library_layouts_command.rb} +0 -4
  83. data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb} +3 -7
  84. data/lib/morpheus/cli/{library_option_types_command.rb → commands/library_option_types_command.rb} +0 -4
  85. data/lib/morpheus/cli/{library_spec_templates_command.rb → commands/library_spec_templates_command.rb} +0 -1
  86. data/lib/morpheus/cli/{library_upgrades_command.rb → commands/library_upgrades_command.rb} +0 -4
  87. data/lib/morpheus/cli/{license.rb → commands/license.rb} +0 -3
  88. data/lib/morpheus/cli/commands/load_balancer_pools.rb +111 -0
  89. data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +0 -4
  90. data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +136 -0
  91. data/lib/morpheus/cli/commands/load_balancers.rb +89 -0
  92. data/lib/morpheus/cli/commands/{standard/log_level_command.rb → log_level_command.rb} +0 -3
  93. data/lib/morpheus/cli/{log_settings_command.rb → commands/log_settings_command.rb} +0 -0
  94. data/lib/morpheus/cli/{login.rb → commands/login.rb} +0 -5
  95. data/lib/morpheus/cli/commands/logout.rb +63 -0
  96. data/lib/morpheus/cli/{logs_command.rb → commands/logs_command.rb} +0 -3
  97. data/lib/morpheus/cli/commands/{standard/man_command.rb → man_command.rb} +0 -2
  98. data/lib/morpheus/cli/{monitoring_alerts_command.rb → commands/monitoring_alerts_command.rb} +0 -7
  99. data/lib/morpheus/cli/{monitoring_apps_command.rb → commands/monitoring_apps_command.rb} +0 -1
  100. data/lib/morpheus/cli/{monitoring_checks_command.rb → commands/monitoring_checks_command.rb} +2 -1
  101. data/lib/morpheus/cli/{monitoring_contacts_command.rb → commands/monitoring_contacts_command.rb} +0 -7
  102. data/lib/morpheus/cli/{monitoring_groups_command.rb → commands/monitoring_groups_command.rb} +0 -1
  103. data/lib/morpheus/cli/{monitoring_incidents_command.rb → commands/monitoring_incidents_command.rb} +0 -1
  104. data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +416 -0
  105. data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +407 -0
  106. data/lib/morpheus/cli/{network_domains_command.rb → commands/network_domains_command.rb} +0 -4
  107. data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +329 -0
  108. data/lib/morpheus/cli/commands/network_firewalls_command.rb +806 -0
  109. data/lib/morpheus/cli/{network_groups_command.rb → commands/network_groups_command.rb} +0 -4
  110. data/lib/morpheus/cli/{network_pool_servers_command.rb → commands/network_pool_servers_command.rb} +0 -4
  111. data/lib/morpheus/cli/{network_pools_command.rb → commands/network_pools_command.rb} +0 -4
  112. data/lib/morpheus/cli/{network_proxies_command.rb → commands/network_proxies_command.rb} +0 -4
  113. data/lib/morpheus/cli/{network_routers_command.rb → commands/network_routers_command.rb} +291 -12
  114. data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
  115. data/lib/morpheus/cli/commands/network_transport_zones_command.rb +452 -0
  116. data/lib/morpheus/cli/{networks_command.rb → commands/networks_command.rb} +21 -21
  117. data/lib/morpheus/cli/{packages_command.rb → commands/packages_command.rb} +0 -2
  118. data/lib/morpheus/cli/{ping.rb → commands/ping.rb} +0 -7
  119. data/lib/morpheus/cli/{policies_command.rb → commands/policies_command.rb} +0 -7
  120. data/lib/morpheus/cli/{power_schedules_command.rb → commands/power_schedules_command.rb} +0 -0
  121. data/lib/morpheus/cli/{preseed_scripts_command.rb → commands/preseed_scripts_command.rb} +0 -3
  122. data/lib/morpheus/cli/{price_sets_command.rb → commands/price_sets_command.rb} +0 -0
  123. data/lib/morpheus/cli/{prices_command.rb → commands/prices_command.rb} +0 -0
  124. data/lib/morpheus/cli/{processes_command.rb → commands/processes_command.rb} +0 -1
  125. data/lib/morpheus/cli/{projects_command.rb → commands/projects_command.rb} +0 -0
  126. data/lib/morpheus/cli/{provisioning_licenses_command.rb → commands/provisioning_licenses_command.rb} +0 -0
  127. data/lib/morpheus/cli/{provisioning_settings_command.rb → commands/provisioning_settings_command.rb} +0 -0
  128. data/lib/morpheus/cli/{recent_activity_command.rb → commands/recent_activity_command.rb} +0 -0
  129. data/lib/morpheus/cli/{remote.rb → commands/remote.rb} +1 -7
  130. data/lib/morpheus/cli/{reports_command.rb → commands/reports_command.rb} +0 -2
  131. data/lib/morpheus/cli/commands/{standard/rm_command.rb → rm_command.rb} +0 -0
  132. data/lib/morpheus/cli/{roles.rb → commands/roles.rb} +244 -39
  133. data/lib/morpheus/cli/{search_command.rb → commands/search_command.rb} +0 -0
  134. data/lib/morpheus/cli/{security_group_rules.rb → commands/security_group_rules.rb} +0 -5
  135. data/lib/morpheus/cli/{security_groups.rb → commands/security_groups.rb} +0 -6
  136. data/lib/morpheus/cli/{service_catalog_command.rb → commands/service_catalog_command.rb} +0 -0
  137. data/lib/morpheus/cli/{service_plans_command.rb → commands/service_plans_command.rb} +0 -0
  138. data/lib/morpheus/cli/commands/{standard/set_prompt_command.rb → set_prompt_command.rb} +0 -3
  139. data/lib/morpheus/cli/{setup.rb → commands/setup.rb} +0 -0
  140. data/lib/morpheus/cli/{shell.rb → commands/shell.rb} +2 -103
  141. data/lib/morpheus/cli/commands/{standard/sleep_command.rb → sleep_command.rb} +0 -2
  142. data/lib/morpheus/cli/commands/{standard/source_command.rb → source_command.rb} +0 -2
  143. data/lib/morpheus/cli/commands/{standard/ssl_verification_command.rb → ssl_verification_command.rb} +0 -3
  144. data/lib/morpheus/cli/{storage_providers_command.rb → commands/storage_providers_command.rb} +0 -4
  145. data/lib/morpheus/cli/{subnets_command.rb → commands/subnets_command.rb} +7 -6
  146. data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +25 -6
  147. data/lib/morpheus/cli/commands/{standard/tee_command.rb → tee_command.rb} +0 -0
  148. data/lib/morpheus/cli/{tenants_command.rb → commands/tenants_command.rb} +0 -7
  149. data/lib/morpheus/cli/commands/{standard/update_command.rb → update_command.rb} +0 -1
  150. data/lib/morpheus/cli/{usage_command.rb → commands/usage_command.rb} +0 -0
  151. data/lib/morpheus/cli/{user_groups_command.rb → commands/user_groups_command.rb} +0 -1
  152. data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +0 -0
  153. data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +0 -1
  154. data/lib/morpheus/cli/{users.rb → commands/users.rb} +0 -7
  155. data/lib/morpheus/cli/{vdi_allocations_command.rb → commands/vdi_allocations_command.rb} +0 -0
  156. data/lib/morpheus/cli/{vdi_apps_command.rb → commands/vdi_apps_command.rb} +0 -0
  157. data/lib/morpheus/cli/{vdi_command.rb → commands/vdi_command.rb} +0 -0
  158. data/lib/morpheus/cli/{vdi_gateways_command.rb → commands/vdi_gateways_command.rb} +0 -0
  159. data/lib/morpheus/cli/{vdi_pools_command.rb → commands/vdi_pools_command.rb} +4 -1
  160. data/lib/morpheus/cli/commands/{standard/version_command.rb → version_command.rb} +0 -0
  161. data/lib/morpheus/cli/{virtual_images.rb → commands/virtual_images.rb} +251 -33
  162. data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
  163. data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
  164. data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
  165. data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
  166. data/lib/morpheus/cli/mixins/load_balancers_helper.rb +2 -2
  167. data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
  168. data/lib/morpheus/cli/mixins/print_helper.rb +1 -0
  169. data/lib/morpheus/cli/mixins/provisioning_helper.rb +155 -112
  170. data/lib/morpheus/cli/mixins/rest_command.rb +154 -52
  171. data/lib/morpheus/cli/mixins/secondary_rest_command.rb +575 -0
  172. data/lib/morpheus/cli/option_parser.rb +25 -17
  173. data/lib/morpheus/cli/option_types.rb +96 -32
  174. data/lib/morpheus/cli/version.rb +1 -1
  175. data/lib/morpheus/cli.rb +5 -128
  176. data/lib/morpheus/terminal.rb +5 -6
  177. data/morpheus-cli.gemspec +1 -1
  178. metadata +156 -143
  179. data/lib/morpheus/cli/change_password_command.rb +0 -147
  180. data/lib/morpheus/cli/library.rb +0 -1
  181. data/lib/morpheus/cli/load_balancers.rb +0 -245
  182. data/lib/morpheus/cli/logout.rb +0 -81
@@ -10,7 +10,8 @@
10
10
  # * load_balancer_column_definitions() - Column definitions for the "get" command display output.
11
11
  # * load_balancer_list_column_definitions() - Column definitions for the "list" command display output.
12
12
  #
13
- # # An example of a RestCommand for `morpheus load-balancers`.
13
+ # Example of a RestCommand for `morpheus load-balancers`.
14
+ #
14
15
  # class Morpheus::Cli::LoadBalancers
15
16
  #
16
17
  # include Morpheus::Cli::CliCommand
@@ -21,7 +22,7 @@
21
22
  # # and would be the default values if not set.
22
23
  # set_rest_name :load_balancers
23
24
  # set_rest_label "Load Balancer"
24
- # set_rest_plural_label "Load Balancers"
25
+ # set_rest_label_plural "Load Balancers"
25
26
  # set_rest_object_key "load_balancer"
26
27
  # set_rest_has_type true
27
28
  # set_rest_type "load_balancer_types"
@@ -38,7 +39,7 @@ module Morpheus::Cli::RestCommand
38
39
 
39
40
  module ClassMethods
40
41
 
41
- # rest_name is the plural name of the rest command resource eg. NeatThingsCommand would be "neat_things"
42
+ # rest_name is the plural name of the resource eg. NeatThings would be "neat_things"
42
43
  # It is used to derive all other default rest settings key, label, etc.
43
44
  # The default name the command name with underscores `_` instead of dashes `-`.
44
45
  def rest_name
@@ -50,7 +51,7 @@ module Morpheus::Cli::RestCommand
50
51
  end
51
52
 
52
53
  def rest_name=(v)
53
- @rest_name = v
54
+ @rest_name = v.to_s
54
55
  end
55
56
 
56
57
  alias :set_rest_name :rest_name=
@@ -61,11 +62,11 @@ module Morpheus::Cli::RestCommand
61
62
  end
62
63
 
63
64
  def default_rest_key
64
- rest_name.chomp("s")
65
+ rest_name.to_s.chomp("s")
65
66
  end
66
67
 
67
68
  def rest_key=(v)
68
- @rest_key = v
69
+ @rest_key = v.to_s
69
70
  end
70
71
 
71
72
  alias :set_rest_key :rest_key=
@@ -80,7 +81,7 @@ module Morpheus::Cli::RestCommand
80
81
  end
81
82
 
82
83
  def rest_arg=(v)
83
- @rest_arg = v
84
+ @rest_arg = v.to_s
84
85
  end
85
86
 
86
87
  alias :set_rest_arg :rest_arg=
@@ -95,26 +96,26 @@ module Morpheus::Cli::RestCommand
95
96
  end
96
97
 
97
98
  def rest_label=(v)
98
- @rest_label = v
99
+ @rest_label = v.to_s
99
100
  end
100
101
 
101
102
  alias :set_rest_label :rest_label=
102
103
 
103
104
  # the plural version of the label eg. "Neat Things"
104
- def rest_plural_label
105
- @rest_plural_label || default_rest_plural_label
105
+ def rest_label_plural
106
+ @rest_label_plural || default_rest_label_plural
106
107
  end
107
108
 
108
- def default_rest_plural_label
109
+ def default_rest_label_plural
109
110
  #rest_name.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ")
110
111
  rest_label.to_s.pluralize
111
112
  end
112
113
 
113
- def rest_plural_label=(v)
114
- @rest_plural_label = v
114
+ def rest_label_plural=(v)
115
+ @rest_label_plural = v.to_s
115
116
  end
116
117
 
117
- alias :set_rest_plural_label :rest_plural_label=
118
+ alias :set_rest_label_plural :rest_label_plural=
118
119
 
119
120
  # rest_interface_name is the interface name for the resource. eg. "neat_things"
120
121
  def rest_interface_name
@@ -126,7 +127,7 @@ module Morpheus::Cli::RestCommand
126
127
  end
127
128
 
128
129
  def rest_interface_name=(v)
129
- @rest_interface_name = v
130
+ @rest_interface_name = v.to_s
130
131
  end
131
132
 
132
133
  alias :set_rest_interface_name :rest_interface_name=
@@ -158,7 +159,7 @@ module Morpheus::Cli::RestCommand
158
159
  end
159
160
 
160
161
  def rest_type_name=(v)
161
- @rest_type_name = v
162
+ @rest_type_name = v.to_s
162
163
  end
163
164
 
164
165
  alias :set_rest_type_name :rest_type_name=
@@ -175,7 +176,7 @@ module Morpheus::Cli::RestCommand
175
176
  end
176
177
 
177
178
  def rest_type_key=(v)
178
- @rest_type_key = v
179
+ @rest_type_key = v.to_s
179
180
  end
180
181
 
181
182
  alias :set_rest_type_key :rest_type_key=
@@ -190,7 +191,7 @@ module Morpheus::Cli::RestCommand
190
191
  end
191
192
 
192
193
  def rest_type_arg=(v)
193
- @rest_type_arg = v
194
+ @rest_type_arg = v.to_s
194
195
  end
195
196
 
196
197
  alias :set_rest_type_arg :rest_type_arg=
@@ -205,26 +206,26 @@ module Morpheus::Cli::RestCommand
205
206
  end
206
207
 
207
208
  def rest_type_label=(v)
208
- @rest_type_label = v
209
+ @rest_type_label = v.to_s
209
210
  end
210
211
 
211
212
  alias :set_rest_type_label :rest_type_label=
212
213
 
213
214
  # the plural version of the label eg. "Neat Things"
214
- def rest_type_plural_label
215
- @rest_type_plural_label || default_rest_type_plural_label
215
+ def rest_type_label_plural
216
+ @rest_type_label_plural || default_rest_type_label_plural
216
217
  end
217
218
 
218
- def default_rest_type_plural_label
219
+ def default_rest_type_label_plural
219
220
  #rest_type_name.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ")
220
221
  rest_type_label.to_s.pluralize
221
222
  end
222
223
 
223
- def rest_type_plural_label=(v)
224
- @rest_type_plural_label = v
224
+ def rest_type_label_plural=(v)
225
+ @rest_type_label_plural = v.to_s
225
226
  end
226
227
 
227
- alias :set_rest_type_plural_label :rest_type_plural_label=
228
+ alias :set_rest_type_label_plural :rest_type_label_plural=
228
229
 
229
230
  # the name of the default interface, matches the rest name eg. "neat_things"
230
231
  def rest_type_interface_name
@@ -236,7 +237,7 @@ module Morpheus::Cli::RestCommand
236
237
  end
237
238
 
238
239
  def rest_type_interface_name=(v)
239
- @rest_type_interface_name = v
240
+ @rest_type_interface_name = v.to_s
240
241
  end
241
242
 
242
243
  alias :set_rest_type_interface_name :rest_type_interface_name=
@@ -247,7 +248,7 @@ module Morpheus::Cli::RestCommand
247
248
  def register_interfaces(*interfaces)
248
249
  @registered_interfaces ||= []
249
250
  interfaces.flatten.each do |it|
250
- @registered_interfaces << it.to_sym
251
+ @registered_interfaces << it.to_s
251
252
  end
252
253
  # put the default rest_interface first
253
254
  if rest_interface_name && !@registered_interfaces.include?(rest_interface_name)
@@ -300,8 +301,8 @@ module Morpheus::Cli::RestCommand
300
301
  self.class.rest_label
301
302
  end
302
303
 
303
- def rest_plural_label
304
- self.class.rest_plural_label
304
+ def rest_label_plural
305
+ self.class.rest_label_plural
305
306
  end
306
307
 
307
308
  def rest_interface_name
@@ -356,8 +357,8 @@ module Morpheus::Cli::RestCommand
356
357
  self.class.rest_type_label
357
358
  end
358
359
 
359
- def rest_type_plural_label
360
- self.class.rest_type_plural_label
360
+ def rest_type_label_plural
361
+ self.class.rest_type_label_plural
361
362
  end
362
363
 
363
364
  def rest_type_interface_name
@@ -415,9 +416,12 @@ module Morpheus::Cli::RestCommand
415
416
  params = {}
416
417
  options = {}
417
418
  optparse = Morpheus::Cli::OptionParser.new do |opts|
418
- opts.banner = subcommand_usage()
419
+ opts.banner = subcommand_usage("[search]")
419
420
  build_standard_list_options(opts, options)
420
- opts.footer = "List #{rest_plural_label.downcase}."
421
+ opts.footer = <<-EOT
422
+ List #{rest_label_plural.downcase}.
423
+ [search] is optional. This is a search phrase to filter the results.
424
+ EOT
421
425
  end
422
426
  optparse.parse!(args)
423
427
  connect(options)
@@ -433,9 +437,9 @@ module Morpheus::Cli::RestCommand
433
437
  json_response = rest_interface.list(params)
434
438
  render_response(json_response, options, rest_list_key) do
435
439
  records = json_response[rest_list_key]
436
- print_h1 "Morpheus #{rest_plural_label}"
440
+ print_h1 "Morpheus #{rest_label_plural}"
437
441
  if records.nil? || records.empty?
438
- print cyan,"No #{rest_plural_label.downcase} found.",reset,"\n"
442
+ print cyan,"No #{rest_label_plural.downcase} found.",reset,"\n"
439
443
  else
440
444
  print as_pretty_table(records, rest_list_column_definitions.upcase_keys!, options)
441
445
  print_results_pagination(json_response) if json_response['meta']
@@ -449,7 +453,7 @@ module Morpheus::Cli::RestCommand
449
453
  params = {}
450
454
  options = {}
451
455
  optparse = Morpheus::Cli::OptionParser.new do |opts|
452
- opts.banner = subcommand_usage("[type]")
456
+ opts.banner = subcommand_usage("[#{rest_arg}]")
453
457
  build_standard_get_options(opts, options)
454
458
  opts.footer = <<-EOT
455
459
  Get details about #{a_or_an(rest_label)} #{rest_label.downcase}.
@@ -500,21 +504,27 @@ EOT
500
504
  end
501
505
 
502
506
  def add(args)
507
+ record_type = nil
503
508
  record_type_id = nil
504
509
  options = {}
505
510
  optparse = Morpheus::Cli::OptionParser.new do |opts|
511
+ opts.banner = subcommand_usage("[#{rest_arg}]")
506
512
  if rest_has_type
507
- opts.banner = subcommand_usage("[name] -t TYPE")
508
513
  opts.on( '-t', "--#{rest_type_arg} TYPE", "#{rest_type_label}" ) do |val|
509
514
  record_type_id = val
510
515
  end
511
- else
512
- opts.banner = subcommand_usage("[name]")
513
516
  end
514
- # if defined?(add_#{rest_key}_option_types)
515
- # build_option_type_options(opts, options, add_#{rest_key}_option_types)
516
- # end
517
+ if self.class.method_defined?("add_#{rest_key}_option_types")
518
+ build_option_type_options(opts, options, self.send("add_#{rest_key}_option_types"))
519
+ end
520
+ if self.class.method_defined?("add_#{rest_key}_advanced_option_types")
521
+ build_option_type_options(opts, options, self.send("add_#{rest_key}_advanced_option_types"))
522
+ end
517
523
  build_standard_add_options(opts, options)
524
+ opts.footer = <<-EOT
525
+ Create a new #{rest_label.downcase}.
526
+ [#{rest_arg}] is required. This is the name of the new #{rest_label.downcase}.
527
+ EOT
518
528
  end
519
529
  optparse.parse!(args)
520
530
  # todo: make supporting args[0] optional and more flexible
@@ -524,14 +534,15 @@ EOT
524
534
  record_name = args[0]
525
535
  end
526
536
  verify_args!(args:args, optparse:optparse, min:0, max: 1)
527
- # todo: maybe need a flag to make this required, it could be an option type too, so
537
+ connect(options)
538
+ # load or prompt for type
528
539
  if rest_has_type
529
540
  if record_type_id.nil?
530
- raise_command_error "#{rest_type_label} is required.\n#{optparse}"
541
+ #raise_command_error "#{rest_type_label} is required.\n#{optparse}"
542
+ type_list = rest_type_interface.list({max:10000})[rest_type_list_key]
543
+ type_dropdown_options = type_list.collect {|it| {'name' => it['name'], 'value' => it['code']} }
544
+ record_type_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'fieldLabel' => rest_type_label, 'type' => 'select', 'selectOptions' => type_dropdown_options, 'required' => true}], options[:options], @api_client)['type']
531
545
  end
532
- end
533
- connect(options)
534
- if rest_has_type
535
546
  record_type = rest_type_find_by_name_or_id(record_type_id)
536
547
  if record_type.nil?
537
548
  raise_command_error "#{rest_type_label} not found for '#{record_type_id}'.\n#{optparse}"
@@ -549,11 +560,21 @@ EOT
549
560
  options[:options]['name'] = record_name # injected for prompt
550
561
  end
551
562
  if rest_has_type && record_type
552
- # record_payload['type'] = {'code' => record_type['code']}
563
+ # inject type to options for prompting
553
564
  record_payload['type'] = record_type['code']
554
- options[:options]['type'] = record_type['code'] # injected for prompt
565
+ options[:options]['type'] = record_type['code']
566
+ # initialize params for loading optionSource data
567
+ options[:params] ||= {}
568
+ options[:params]['type'] = record_type['code']
555
569
  end
556
570
  record_payload.deep_merge!(passed_options)
571
+ if self.class.method_defined?("add_#{rest_key}_option_types")
572
+ add_option_types = self.send("add_#{rest_key}_option_types")
573
+ v_prompt = Morpheus::Cli::OptionTypes.prompt(add_option_types, options[:options], @api_client, options[:params])
574
+ v_prompt.deep_compact!
575
+ v_prompt.booleanize! # 'on' => true
576
+ record_payload.deep_merge!(v_prompt)
577
+ end
557
578
  # options by type
558
579
  my_option_types = record_type ? record_type['optionTypes'] : nil
559
580
  if my_option_types && !my_option_types.empty?
@@ -568,6 +589,14 @@ EOT
568
589
  v_prompt.booleanize! # 'on' => true
569
590
  record_payload.deep_merge!(v_prompt)
570
591
  end
592
+ # advanced options (uses no_prompt)
593
+ if self.class.method_defined?("add_#{rest_key}_advanced_option_types")
594
+ add_advanced_option_types = self.send("add_#{rest_key}_advanced_option_types")
595
+ v_prompt = Morpheus::Cli::OptionTypes.no_prompt(add_advanced_option_types, options[:options], @api_client, options[:params])
596
+ v_prompt.deep_compact!
597
+ v_prompt.booleanize! # 'on' => true
598
+ record_payload.deep_merge!(v_prompt)
599
+ end
571
600
  payload[rest_object_key] = record_payload
572
601
  end
573
602
  rest_interface.setopts(options)
@@ -586,24 +615,93 @@ EOT
586
615
 
587
616
  def update(args)
588
617
  id = args[0]
618
+ record_type = nil
619
+ record_type_id = nil
589
620
  options = {}
590
- params = {}
591
- account_name = nil
592
621
  optparse = Morpheus::Cli::OptionParser.new do |opts|
593
622
  opts.banner = subcommand_usage("[#{rest_arg}] [options]")
623
+ if self.class.method_defined?("update_#{rest_key}_option_types")
624
+ build_option_type_options(opts, options, self.send("update_#{rest_key}_option_types"))
625
+ end
626
+ if self.class.method_defined?("update_#{rest_key}_advanced_option_types")
627
+ build_option_type_options(opts, options, self.send("update_#{rest_key}_advanced_option_types"))
628
+ end
594
629
  build_standard_update_options(opts, options)
630
+ opts.footer = <<-EOT
631
+ Update an existing #{rest_label.downcase}.
632
+ [#{rest_arg}] is required. This is the name or id of #{a_or_an(rest_label)} #{rest_label.downcase}.
633
+ EOT
595
634
  end
596
635
  optparse.parse!(args)
597
636
  verify_args!(args:args, optparse:optparse, count:1)
598
637
  connect(options)
599
638
  record = rest_find_by_name_or_id(id)
639
+ if record.nil?
640
+ return 1, "#{rest_name} not found for '#{id}'"
641
+ end
642
+ # load type so we can prompt for those option types
643
+ if rest_has_type
644
+ record_type_id = record['type']['id']
645
+ record_type = rest_type_find_by_name_or_id(record_type_id)
646
+ if record_type.nil?
647
+ raise_command_error "#{rest_type_label} not found for '#{record_type_id}'.\n#{optparse}"
648
+ end
649
+ end
600
650
  passed_options = parse_passed_options(options)
601
- payload = nil
651
+ payload = {}
602
652
  if options[:payload]
603
653
  payload = options[:payload]
604
654
  payload.deep_merge!({rest_object_key => passed_options}) unless passed_options.empty?
605
655
  else
606
656
  record_payload = passed_options
657
+ if rest_has_type && record_type
658
+ # inject type to options for prompting
659
+ # record_payload['type'] = record_type['code']
660
+ # options[:options]['type'] = record_type['code']
661
+ # initialize params for loading optionSource data
662
+ options[:params] ||= {}
663
+ options[:params]['type'] = record_type['code']
664
+ end
665
+ # update options without prompting by default
666
+ if self.class.method_defined?("update_#{rest_key}_option_types")
667
+ update_option_types = self.send("update_#{rest_key}_option_types")
668
+ v_prompt = Morpheus::Cli::OptionTypes.no_prompt(update_option_types, options[:options], @api_client, options[:params])
669
+ v_prompt.deep_compact!
670
+ v_prompt.booleanize! # 'on' => true
671
+ record_payload.deep_merge!(v_prompt)
672
+ end
673
+ # options by type
674
+ my_option_types = record_type ? record_type['optionTypes'] : nil
675
+ if my_option_types && !my_option_types.empty?
676
+ # remove redundant fieldContext
677
+ # make them optional for updates
678
+ # todo: use current value as default instead of just making things optioanl
679
+ # maybe new prompt() options like {:mode => :edit, :object => storage_server} or something
680
+ my_option_types.each do |option_type|
681
+ if option_type['fieldContext'] == rest_object_key
682
+ option_type['fieldContext'] = nil
683
+ end
684
+ option_type.delete('required')
685
+ option_type.delete('defaultValue')
686
+ end
687
+ v_prompt = Morpheus::Cli::OptionTypes.no_prompt(my_option_types, options[:options], @api_client, options[:params])
688
+ v_prompt.deep_compact!
689
+ v_prompt.booleanize! # 'on' => true
690
+ record_payload.deep_merge!(v_prompt)
691
+ end
692
+ # advanced options
693
+ if self.class.method_defined?("update_#{rest_key}_advanced_option_types")
694
+ update_advanced_option_types = self.send("update_#{rest_key}_advanced_option_types")
695
+ v_prompt = Morpheus::Cli::OptionTypes.no_prompt(update_advanced_option_types, options[:options], @api_client, options[:params])
696
+ v_prompt.deep_compact!
697
+ v_prompt.booleanize! # 'on' => true
698
+ record_payload.deep_merge!(v_prompt)
699
+ end
700
+ # remove empty config, compact could hanlde this
701
+ if record_payload['config'] && record_payload['config'].empty?
702
+ record_payload.delete('config')
703
+ end
704
+ # prevent updating with empty payload
607
705
  if record_payload.empty?
608
706
  raise_command_error "Specify at least one option to update.\n#{optparse}"
609
707
  end
@@ -629,6 +727,10 @@ EOT
629
727
  optparse = Morpheus::Cli::OptionParser.new do |opts|
630
728
  opts.banner = subcommand_usage("[#{rest_arg}]")
631
729
  build_standard_remove_options(opts, options)
730
+ opts.footer = <<-EOT
731
+ Delete an existing #{rest_label.downcase}.
732
+ [#{rest_arg}] is required. This is the name or id of #{a_or_an(rest_label)} #{rest_label.downcase}.
733
+ EOT
632
734
  end
633
735
  optparse.parse!(args)
634
736
  verify_args!(args:args, optparse:optparse, count:1)