module Morpheus::Cli::RestCommand::ClassMethods
Public Instance Methods
clear the list of registered interfaces, perhaps useful in a command subclass
# File lib/morpheus/cli/mixins/rest_command.rb, line 320 def clear_registered_interfaces() @registered_interfaces = [] end
# File lib/morpheus/cli/mixins/rest_command.rb, line 79 def default_rest_arg rest_key.gsub("_", " ") # "[" + rest_key.gsub("_", " ") + "]" end
# File lib/morpheus/cli/mixins/rest_command.rb, line 95 def default_rest_has_name true end
# File lib/morpheus/cli/mixins/rest_command.rb, line 178 def default_rest_has_type false end
# File lib/morpheus/cli/mixins/rest_command.rb, line 141 def default_rest_interface_name rest_name end
# File lib/morpheus/cli/mixins/rest_command.rb, line 64 def default_rest_key rest_name.to_s.chomp("s") end
# File lib/morpheus/cli/mixins/rest_command.rb, line 110 def default_rest_label rest_key.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ") end
# File lib/morpheus/cli/mixins/rest_command.rb, line 125 def default_rest_label_plural #rest_name.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ") rest_label.to_s.pluralize end
# File lib/morpheus/cli/mixins/rest_command.rb, line 49 def default_rest_name self.command_name.to_s.gsub("-", "_") end
# File lib/morpheus/cli/mixins/rest_command.rb, line 226 def default_rest_type_arg # rest_type_key.gsub("_", " ") # "[" + rest_key.gsub("_", " ") + "]" "type" # [type] end
# File lib/morpheus/cli/mixins/rest_command.rb, line 273 def default_rest_type_interface_name rest_type_name end
# File lib/morpheus/cli/mixins/rest_command.rb, line 212 def default_rest_type_key rest_type_name.chomp("s") end
# File lib/morpheus/cli/mixins/rest_command.rb, line 242 def default_rest_type_label rest_type_key.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ") end
# File lib/morpheus/cli/mixins/rest_command.rb, line 257 def default_rest_type_label_plural #rest_type_name.to_s.split("_").collect {|it| it.to_s.capitalize }.join(" ") rest_type_label.to_s.pluralize end
# File lib/morpheus/cli/mixins/rest_command.rb, line 195 def default_rest_type_name rest_key + "_types" end
set or append to the list of interface names to register for this command The registered interfaces will be pre-loaded into instance variables eg. [:neat_things, :neat_thing_types] will instantiate @neat_things_interface and @neat_thing_types_interface
# File lib/morpheus/cli/mixins/rest_command.rb, line 286 def register_interfaces(*interfaces) @registered_interfaces ||= [] interfaces.flatten.each do |it| @registered_interfaces << it.to_s end # put the default rest_interface first if rest_interface_name && !@registered_interfaces.include?(rest_interface_name) @registered_interfaces.unshift(rest_interface_name) end # and also the rest_type_interface if rest_has_type && !@registered_interfaces.include?(rest_type_interface_name) @registered_interfaces.unshift(rest_type_interface_name) end end
get list of interface names that are registered for this command automatically includes the interface for the rest_name
and rest_type_name
if has_type
# File lib/morpheus/cli/mixins/rest_command.rb, line 305 def registered_interfaces @registered_interfaces ||= [] # put the default rest_interface first if @registered_interfaces.empty? if rest_interface_name @registered_interfaces.unshift(rest_interface_name) end if rest_has_type @registered_interfaces.unshift(rest_type_interface_name) end end @registered_interfaces end
rest_arg
is a label for the arg in the command usage eg. “thing” gets displayed as [thing]
# File lib/morpheus/cli/mixins/rest_command.rb, line 75 def rest_arg defined?(@rest_arg) ? @rest_arg : default_rest_arg end
# File lib/morpheus/cli/mixins/rest_command.rb, line 83 def rest_arg=(v) @rest_arg = v.to_s end
rest_has_name
indicates a resource has a name and can be retrieved by name or id true by default, set to false for lookups by only id
# File lib/morpheus/cli/mixins/rest_command.rb, line 91 def rest_has_name defined?(@rest_has_name) ? @rest_has_name : default_rest_has_name end
# File lib/morpheus/cli/mixins/rest_command.rb, line 99 def rest_has_name=(v) @rest_has_name = !!v end
rest_has_type
indicates a resource has a type. default is false
# File lib/morpheus/cli/mixins/rest_command.rb, line 174 def rest_has_type defined?(@rest_has_type) && @rest_has_type end
# File lib/morpheus/cli/mixins/rest_command.rb, line 182 def rest_has_type=(v) @rest_has_type = !!v end
rest_interface_name
is the interface name for the resource. eg. “neat_things”
# File lib/morpheus/cli/mixins/rest_command.rb, line 137 def rest_interface_name defined?(@rest_interface_name) ? @rest_interface_name : default_rest_interface_name end
# File lib/morpheus/cli/mixins/rest_command.rb, line 145 def rest_interface_name=(v) @rest_interface_name = v.to_s end
rest_key
is the singular name of the resource eg. “neat_thing”
# File lib/morpheus/cli/mixins/rest_command.rb, line 60 def rest_key defined?(@rest_key) ? @rest_key : default_rest_key end
# File lib/morpheus/cli/mixins/rest_command.rb, line 68 def rest_key=(v) @rest_key = v.to_s end
rest_label
is the capitalized resource label eg. “Neat Thing”
# File lib/morpheus/cli/mixins/rest_command.rb, line 106 def rest_label defined?(@rest_label) ? @rest_label : default_rest_label end
# File lib/morpheus/cli/mixins/rest_command.rb, line 114 def rest_label=(v) @rest_label = v.to_s end
the plural version of the label eg. “Neat Things”
# File lib/morpheus/cli/mixins/rest_command.rb, line 121 def rest_label_plural defined?(@rest_label_plural) ? @rest_label_plural : default_rest_label_plural end
# File lib/morpheus/cli/mixins/rest_command.rb, line 130 def rest_label_plural=(v) @rest_label_plural = v.to_s end
rest_name
is the plural name of the resource eg. NeatThings would be “neat_things” It is used to derive all other default rest settings key, label, etc.
The default name the command name with underscores ‘_` instead of dashes `-`.
# File lib/morpheus/cli/mixins/rest_command.rb, line 45 def rest_name defined?(@rest_name) ? @rest_name : default_rest_name end
# File lib/morpheus/cli/mixins/rest_command.rb, line 53 def rest_name=(v) @rest_name = v.to_s end
rest_option_context_map
specifies context mapping during option prompt. default is domain => ”
# File lib/morpheus/cli/mixins/rest_command.rb, line 163 def rest_option_context_map defined?(@option_context_map) ? @option_context_map : {'domain' => ''} end
# File lib/morpheus/cli/mixins/rest_command.rb, line 167 def rest_option_context_map=(v) @option_context_map = v end
rest_perms_config
enables and configures permissions prompt
# File lib/morpheus/cli/mixins/rest_command.rb, line 152 def rest_perms_config defined?(@rest_perms_config) ? @rest_perms_config : {} end
# File lib/morpheus/cli/mixins/rest_command.rb, line 156 def rest_perms_config=(v) @rest_perms_config = v end
# File lib/morpheus/cli/mixins/rest_command.rb, line 222 def rest_type_arg defined?(@rest_type_arg) ? @rest_type_arg : default_rest_type_arg end
# File lib/morpheus/cli/mixins/rest_command.rb, line 231 def rest_type_arg=(v) @rest_type_arg = v.to_s end
the name of the default interface, matches the rest name eg. “neat_things”
# File lib/morpheus/cli/mixins/rest_command.rb, line 269 def rest_type_interface_name defined?(@rest_type_interface_name) ? @rest_type_interface_name : default_rest_type_interface_name end
# File lib/morpheus/cli/mixins/rest_command.rb, line 277 def rest_type_interface_name=(v) @rest_type_interface_name = v.to_s end
rest_type_key
is the singular name of the resource eg. “neat_thing”
# File lib/morpheus/cli/mixins/rest_command.rb, line 208 def rest_type_key defined?(@rest_type_key) ? @rest_type_key : default_rest_type_key end
# File lib/morpheus/cli/mixins/rest_command.rb, line 216 def rest_type_key=(v) @rest_type_key = v.to_s end
rest_type_label
is the capitalized resource label eg. “Neat Thing”
# File lib/morpheus/cli/mixins/rest_command.rb, line 238 def rest_type_label defined?(@rest_type_label) ? @rest_type_label : default_rest_type_label end
# File lib/morpheus/cli/mixins/rest_command.rb, line 246 def rest_type_label=(v) @rest_type_label = v.to_s end
the plural version of the label eg. “Neat Things”
# File lib/morpheus/cli/mixins/rest_command.rb, line 253 def rest_type_label_plural defined?(@rest_type_label_plural) ? @rest_type_label_plural : default_rest_type_label_plural end
# File lib/morpheus/cli/mixins/rest_command.rb, line 262 def rest_type_label_plural=(v) @rest_type_label_plural = v.to_s end
rest_type_name
is the rest_name
for the type, only applicable if rest_has_type
# File lib/morpheus/cli/mixins/rest_command.rb, line 191 def rest_type_name defined?(@rest_type_name) ? @rest_type_name : default_rest_type_name end
# File lib/morpheus/cli/mixins/rest_command.rb, line 199 def rest_type_name=(v) @rest_type_name = v.to_s end