Class: Crowbar::Client::Command::Role::List

Inherits:
Base
  • Object
show all
Includes:
Mixin::Barclamp, Mixin::Filter, Mixin::Format
Defined in:
lib/crowbar/client/command/role/list.rb

Overview

Implementation for the role list command

Instance Attribute Summary

Attributes inherited from Base

#args, #options, #stderr, #stdin, #stdout

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Crowbar::Client::Command::Base

Instance Method Details

#executeObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/crowbar/client/command/role/list.rb', line 36

def execute
  validate_barclamp! args.barclamp

  request.process do |request|
    case request.code
    when 200
      formatter = Formatter::Array.new(
        format: provide_format,
        headings: ["Role"],
        values: Filter::Array.new(
          filter: provide_filter,
          values: content_from(request)
        ).result
      )

      if formatter.empty?
        err "No roles"
      else
        say formatter.result
      end
    when 404
      err "Barclamp does not exist"
    else
      err request.parsed_response["error"]
    end
  end
end

#requestObject



30
31
32
33
34
# File 'lib/crowbar/client/command/role/list.rb', line 30

def request
  @request ||= Request::Role::List.new(
    args
  )
end