fluke/devops-client/lib/devops-client/handler/group.rb

36 lines
818 B
Ruby
Raw Normal View History

2014-05-08 15:34:26 +04:00
require "devops-client/handler/handler"
require "devops-client/options/group_options"
require "json"
require "devops-client/output/groups"
class Group < Handler
2015-04-14 15:29:02 +03:00
output_with Output::Groups
2014-05-08 15:34:26 +04:00
def initialize(host, def_options={})
2015-04-14 15:29:02 +03:00
@host, @options = host, def_options
2014-05-08 15:34:26 +04:00
@options_parser = GroupOptions.new(ARGV, def_options)
end
def handle
case ARGV[1]
when "list"
2015-04-14 15:29:02 +03:00
@options, @args = @options_parser.parse_options_for!(:list)
list_handler(@args[2], @args[3])
2014-05-08 15:34:26 +04:00
output
end
end
2015-04-14 15:29:02 +03:00
def list_handler(provider=nil, vpc_id=nil)
r = inspect_parameters @options_parser.list_params, provider
2014-05-08 15:34:26 +04:00
unless r.nil?
@options_parser.invalid_list_command
abort(r)
end
p = {}
2015-04-14 15:29:02 +03:00
p["vpc-id"] = vpc_id unless vpc_id.nil?
@list = get("/groups/#{provider}", p)
2014-05-08 15:34:26 +04:00
end
end