module Morpheus::Cli::RestCommand::ClassMethods

Public Instance Methods

clear_registered_interfaces() click to toggle source

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
default_rest_arg() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 79
def default_rest_arg
  rest_key.gsub("_", " ") # "[" + rest_key.gsub("_", " ") + "]"
end
default_rest_has_name() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 95
def default_rest_has_name
  true
end
default_rest_has_type() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 178
def default_rest_has_type
  false
end
default_rest_interface_name() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 141
def default_rest_interface_name
  rest_name
end
default_rest_key() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 64
def default_rest_key
  rest_name.to_s.chomp("s")
end
default_rest_label() click to toggle source
# 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
default_rest_label_plural() click to toggle source
# 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
default_rest_name() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 49
def default_rest_name
  self.command_name.to_s.gsub("-", "_")
end
default_rest_type_arg() click to toggle source
# 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
default_rest_type_interface_name() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 273
def default_rest_type_interface_name
  rest_type_name
end
default_rest_type_key() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 212
def default_rest_type_key
  rest_type_name.chomp("s")
end
default_rest_type_label() click to toggle source
# 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
default_rest_type_label_plural() click to toggle source
# 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
default_rest_type_name() click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 195
def default_rest_type_name
  rest_key + "_types"
end
register_interface(*interfaces)
Alias for: register_interfaces
register_interfaces(*interfaces) click to toggle source

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
Also aliased as: register_interface
registered_interfaces() click to toggle source

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() click to toggle source

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
rest_arg=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 83
def rest_arg=(v)
  @rest_arg = v.to_s
end
Also aliased as: set_rest_arg
rest_has_name() click to toggle source

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
rest_has_name=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 99
def rest_has_name=(v)
  @rest_has_name = !!v
end
Also aliased as: set_rest_has_name
rest_has_type() click to toggle source

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
rest_has_type=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 182
def rest_has_type=(v)
  @rest_has_type = !!v
end
Also aliased as: set_rest_has_type
rest_interface_name() click to toggle source

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
rest_interface_name=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 145
def rest_interface_name=(v)
  @rest_interface_name = v.to_s
end
Also aliased as: set_rest_interface_name
rest_key() click to toggle source

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
rest_key=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 68
def rest_key=(v)
  @rest_key = v.to_s
end
Also aliased as: set_rest_key
rest_label() click to toggle source

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
rest_label=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 114
def rest_label=(v)
  @rest_label = v.to_s
end
Also aliased as: set_rest_label
rest_label_plural() click to toggle source

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
rest_label_plural=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 130
def rest_label_plural=(v)
  @rest_label_plural = v.to_s
end
Also aliased as: set_rest_label_plural
rest_name() click to toggle source

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
rest_name=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 53
def rest_name=(v)
  @rest_name = v.to_s
end
Also aliased as: set_rest_name
rest_option_context_map() click to toggle source

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
rest_option_context_map=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 167
def rest_option_context_map=(v)
  @option_context_map = v
end
Also aliased as: set_rest_option_context_map
rest_perms_config() click to toggle source

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
rest_perms_config=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 156
def rest_perms_config=(v)
  @rest_perms_config = v
end
Also aliased as: set_rest_perms_config
rest_type_arg() click to toggle source
# 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
rest_type_arg=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 231
def rest_type_arg=(v)
  @rest_type_arg = v.to_s
end
Also aliased as: set_rest_type_arg
rest_type_interface_name() click to toggle source

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
rest_type_interface_name=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 277
def rest_type_interface_name=(v)
  @rest_type_interface_name = v.to_s
end
Also aliased as: set_rest_type_interface_name
rest_type_key() click to toggle source

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
rest_type_key=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 216
def rest_type_key=(v)
  @rest_type_key = v.to_s
end
Also aliased as: set_rest_type_key
rest_type_label() click to toggle source

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
rest_type_label=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 246
def rest_type_label=(v)
  @rest_type_label = v.to_s
end
Also aliased as: set_rest_type_label
rest_type_label_plural() click to toggle source

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
rest_type_label_plural=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 262
def rest_type_label_plural=(v)
  @rest_type_label_plural = v.to_s
end
Also aliased as: set_rest_type_label_plural
rest_type_name() click to toggle source

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
rest_type_name=(v) click to toggle source
# File lib/morpheus/cli/mixins/rest_command.rb, line 199
def rest_type_name=(v)
  @rest_type_name = v.to_s
end
Also aliased as: set_rest_type_name, set_rest_type
set_rest_arg(v)
Alias for: rest_arg=
set_rest_has_name(v)
Alias for: rest_has_name=
set_rest_has_type(v)
Alias for: rest_has_type=
set_rest_interface_name(v)
set_rest_key(v)
Alias for: rest_key=
set_rest_label(v)
Alias for: rest_label=
set_rest_label_plural(v)
Alias for: rest_label_plural=
set_rest_name(v)
Alias for: rest_name=
set_rest_option_context_map(v)
set_rest_perms_config(v)
Alias for: rest_perms_config=
set_rest_type(v)
Alias for: rest_type_name=
set_rest_type_arg(v)
Alias for: rest_type_arg=
set_rest_type_interface_name(v)
set_rest_type_key(v)
Alias for: rest_type_key=
set_rest_type_label(v)
Alias for: rest_type_label=
set_rest_type_label_plural(v)
set_rest_type_name(v)
Alias for: rest_type_name=