class Atlas::Peering
class: Atlas::CLI: The command line interface class
Public Instance Methods
create()
click to toggle source
# File lib/atlas/cli.rb, line 57 def create Config.configure(options[:config]) Config.configure.vpc_id = options[:vpcid] client = Client.new(Config.user_name, Config.api_key, Config.group_id) response = client.create(Config).parsed_response out(response) handle_exit(response) rescue StandardError => exception die(exception, CREATE_ERROR_CODE) end
delete()
click to toggle source
# File lib/atlas/cli.rb, line 72 def delete Config.configure(options[:config]) Config.configure { |c| c.id = options[:id] } client = Client.new(Config.user_name, Config.api_key, Config.group_id) response = client.delete(Config).parsed_response handle_exit(response) rescue StandardError => exception die(exception, DELETE_ERROR_CODE) end
die(exception, error_code)
click to toggle source
# File lib/atlas/cli.rb, line 30 def die(exception, error_code) STDERR.puts(exception.backtrace) exit(error_code) end
handle_exit(response, exit_code = DEFAULT_ERROR_CODE)
click to toggle source
# File lib/atlas/cli.rb, line 18 def handle_exit(response, exit_code = DEFAULT_ERROR_CODE) if response.keys.include?('error') exit(exit_code) else exit(0) end end
list()
click to toggle source
# File lib/atlas/cli.rb, line 43 def list Config.configure(options[:config]) client = Client.new(Config.user_name, Config.api_key, Config.group_id) response = client.list(Config).parsed_response out(response) handle_exit(response) rescue StandardError => exception die(exception, LIST_ERROR_CODE) end
out(response)
click to toggle source
# File lib/atlas/cli.rb, line 26 def out(response) STDOUT.puts(::JSON.pretty_generate(response)) end
version()
click to toggle source
# File lib/atlas/cli.rb, line 37 def version puts Atlas::VERSION end