class Morpheus::Cli::SecurityPackagesCommand

Protected Instance Methods

add_security_package_advanced_option_types() click to toggle source
# File lib/morpheus/cli/commands/security_packages.rb, line 70
def add_security_package_advanced_option_types()
  []
end
add_security_package_option_types() click to toggle source
# File lib/morpheus/cli/commands/security_packages.rb, line 54
def add_security_package_option_types()
  [
    {'shorthand' => '-t', 'fieldName' => 'type', 'fieldLabel' => 'Security Package Type', 'type' => 'select', 'optionSource' => lambda {|api_client, api_params| 
      api_client.security_package_types.list({max:10000})['securityPackageTypes'].collect { |it| {"name" => it["name"], "value" => it["code"]} }
    }, 'required' => true, 'defaultValue' => 'SCAP Package'},      
    {'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true},
    {'shorthand' => '-l', 'optionalValue' => true, 'fieldName' => 'labels', 'fieldLabel' => 'Labels', 'type' => 'text', 'required' => false, 'noPrompt' => true, 'processValue' => lambda {|val| parse_labels(val) }},
    {'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false},
    {'fieldName' => 'enabled', 'fieldLabel' => 'Enabled', 'type' => 'checkbox', 'required' => false, 'defaultValue' => true},
    # {'code' => 'securityPackage.sourceType', 'fieldName' => 'sourceType', 'fieldLabel' => 'Source', 'type' => 'select', 'selectOptions' => [{'name'=>'url','value'=>'url'}], 'defaultValue' => 'url', 'required' => true},
    # {'code' => 'securityPackage.sourceType', 'fieldContext' => 'file', 'fieldName' => 'sourceType', 'fieldLabel' => 'Source', 'type' => 'hidden', 'defaultValue' => 'url', 'required' => true},
    {'fieldName' => 'url', 'fieldLabel' => 'URL', 'type' => 'text', 'required' => true, 'description' => "URL to download the security package zip file from"},
    # {'fieldName' => 'file', 'fieldLabel' => 'File Content', 'type' => 'file-content', 'required' => true},
  ]
end
build_list_options(opts, options, params) click to toggle source

set_rest_type :security_package_types

# File lib/morpheus/cli/commands/security_packages.rb, line 18
def build_list_options(opts, options, params)
  opts.on('-l', '--labels LABEL', String, "Filter by labels, can match any of the values") do |val|
    add_query_parameter(params, 'labels', parse_labels(val))
  end
  opts.on('--all-labels LABEL', String, "Filter by labels, must match all of the values") do |val|
    add_query_parameter(params, 'allLabels', parse_labels(val))
  end
  # build_standard_list_options(opts, options)
  super
end
security_package_column_definitions(options) click to toggle source
# File lib/morpheus/cli/commands/security_packages.rb, line 39
def security_package_column_definitions(options)
  {
    "ID" => 'id',
    "Name" => 'name',
    "Labels" => lambda {|it| format_list(it['labels'], '', 3) rescue '' },
    "Type" => lambda {|it| it['type'] ? it['type']['name'] : '' },
    "Description" => 'description',
    "Enabled" => lambda {|it| format_boolean(it['enabled']) },
    # "Source" => 'sourceType',
    "URL" => 'url',
    "Created" => lambda {|it| format_local_dt(it['dateCreated']) },
    "Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
  }
end
security_package_list_column_definitions(options) click to toggle source
# File lib/morpheus/cli/commands/security_packages.rb, line 29
def security_package_list_column_definitions(options)
  {
    "ID" => 'id',
    "Name" => 'name',
    "Labels" => lambda {|it| format_list(it['labels'], '', 3) rescue '' },
    "Type" => lambda {|it| it['type'] ? it['type']['name'] : '' },
    "Description" => 'description',
  }
end
update_security_package_advanced_option_types() click to toggle source
# File lib/morpheus/cli/commands/security_packages.rb, line 80
def update_security_package_advanced_option_types()
  add_security_package_advanced_option_types().collect {|it| it.delete('required'); it.delete('defaultValue'); it.delete('dependsOnCode'); it }
end
update_security_package_option_types() click to toggle source
# File lib/morpheus/cli/commands/security_packages.rb, line 74
def update_security_package_option_types()
  option_types = add_security_package_option_types.collect {|it| it.delete('required'); it.delete('defaultValue'); it.delete('dependsOnCode'); it }
  option_types.reject! {|it| it['fieldName'] == 'type' }
  option_types
end