class ThreeScaleToolbox::Commands::RemoteCommand::RemoteAddSubcommand
Public Class Methods
command()
click to toggle source
# File lib/3scale_toolbox/commands/remote_command/remote_add.rb, line 7 def self.command Cri::Command.define do name 'add' usage 'add <name> <url>' summary 'remote add' description 'Add new remote to the list' param :remote_name param :remote_url runner RemoteAddSubcommand end end
Public Instance Methods
run()
click to toggle source
# File lib/3scale_toolbox/commands/remote_command/remote_add.rb, line 19 def run # 'arguments' cannot be converted to Hash add_remote arguments[:remote_name], arguments[:remote_url] end
Private Instance Methods
add_remote(remote_name, remote_url)
click to toggle source
# File lib/3scale_toolbox/commands/remote_command/remote_add.rb, line 39 def add_remote(remote_name, remote_url) validate_remote_name remote_name validate_remote remote_url remotes.add_uri(remote_name, remote_url) end
validate_remote(remote_url_str)
click to toggle source
# File lib/3scale_toolbox/commands/remote_command/remote_add.rb, line 30 def validate_remote(remote_url_str) # parsing url before trying to create client # raises Invalid URL when syntax is incorrect ThreeScaleToolbox::Helper.parse_uri(remote_url_str) threescale_client(remote_url_str).list_accounts rescue ThreeScale::API::HttpClient::ForbiddenError raise ThreeScaleToolbox::Error, 'remote not valid' end
validate_remote_name(name)
click to toggle source
# File lib/3scale_toolbox/commands/remote_command/remote_add.rb, line 26 def validate_remote_name(name) raise ThreeScaleToolbox::Error, 'remote name already exists.' if remotes.all.key?(name) end