class DTK::Client::Library

Public Class Methods

pretty_print_cols() click to toggle source
# File lib/commands/thor/library.rb, line 23
def self.pretty_print_cols()
  PPColumns.get(:library)
end
whoami() click to toggle source
# File lib/commands/thor/library.rb, line 27
def self.whoami()
  return :library, "library/list", nil
end

Public Instance Methods

create(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 98
def create(context_params)
  library_id, module_name = context_params.retrieve_arguments([:library_id, :option_1!],method_argument_names)
  post_body = {
   :module_name => module_name
  }
  post_body.merge!(:library_id => library_id) if library_id
  response = post rest_url("service_module/create"), post_body
  # when changing context send request for getting latest libraries instead of getting from cache
  @@invalidate_map << :library

  return response
end
delete(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 112
def delete(context_params)
  library_id, component_module_id = context_params.retrieve_arguments([:library_id, :option_1!],method_argument_names)
  post_body = {
   :component_module_id => component_module_id
  }
  post_body.merge!(:library_id => library_id) if library_id
  response = post rest_url("component_module/delete"), post_body
  # when changing context send request for getting latest libraries instead of getting from cache
  @@invalidate_map << :library

  return response
end
import_service_module(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 86
def import_service_module(context_params)
  library_id, service_modules = context_params.retrieve_arguments([:library_id, :option_1!],method_argument_names)
  post_body = {
    :remote_module_name => service_modules,
    :rsa_pub_key => SSHUtil.rsa_pub_key_content()
  }
  post_body.merge!(:library_id => library_id) if library_id

  post rest_url("service_module/import"), post_body
end
info(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 32
def info(context_params)
  library_id = context_params.retrieve_arguments([:library_id],method_argument_names)
  not_implemented
end
list(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 56
def list(context_params)
  library_id, about = context_params.retrieve_arguments([:library_id, :option_1],method_argument_names||="")
  if library_id.nil?
    search_hash = SearchHash.new()
    search_hash.cols = pretty_print_cols()
    response = post rest_url("library/list"), search_hash.post_body_hash
    response.render_table(:library)
  else
    # sets data type to be used when printing table
    case about
     when "assemblies"
      data_type = :assembly_template
     when "nodes"
      data_type = :node_template
     when "components"
      data_type = :component
     else
      raise_validation_error_method_usage('list')
    end

    post_body = {
      :library_id => library_id,
      :about => about
    }
    response = post rest_url("library/info_about"), post_body
    response.render_table(data_type)
  end
end
list_assemblies(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 50
def list_assemblies(context_params)
  context_params.method_arguments = ["assemblies"]
  list(context_params)
end
list_components(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 44
def list_components(context_params)
  context_params.method_arguments = ["components"]
  list(context_params)
end
list_nodes(context_params) click to toggle source
# File lib/commands/thor/library.rb, line 38
def list_nodes(context_params)
  context_params.method_arguments = ["nodes"]
  list(context_params)
end