class DTK::Client::Operation::Service::ListAttributes

Public Class Methods

execute(args = Args.new) click to toggle source
# File lib/client/operation/service/list_attributes.rb, line 21
def self.execute(args = Args.new)
  wrap_operation(args) do |args|
    service_instance = args.required(:service_instance)
    links            = args[:links]
    # node             = args[:node]
    name             = args[:attribute_name]
    component        = args[:component]
    format           = args[:format] || 'table'
    format.downcase!

    if component && name 
      raise Error::Usage, "Command options ATTRIBUTE NAME and --component cannot be used at the same time."
    end

    query_string_hash = QueryStringHash.new(
      :links?            => links,
      # :node_id?          => node,
      :filter_component? => component,
      :format            => format,
      :attribute_name    => name
    )
    
    response = rest_get("#{BaseRoute}/#{service_instance}/attributes", query_string_hash)
    
    case format
    when 'table'
      response.set_render_as_table!
    when 'yaml'
      response
    else
      raise Error::Usage, "Please enter valid format: TABLE, YAML"
    end
  end
end