Class: RightScaleCLI::Configure

Inherits:
Thor
  • Object
show all
Defined in:
lib/rightscale_cli/configure.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Configure

Returns a new instance of Configure.



31
32
33
34
35
36
# File 'lib/rightscale_cli/configure.rb', line 31

def initialize(*args)
  super
  @logger = RightScaleCLI::Logger.new()
  @config = RightScaleCLI::Config.new
  @directives = @config.directives
end

Class Method Details

default_task :all



114
115
116
# File 'lib/rightscale_cli/configure.rb', line 114

def self.banner(task, namespace = true, subcommand = false)
  "#{basename} #{task.formatted_usage(self, true, subcommand)}"
end

Instance Method Details

#accountObject



45
46
47
48
# File 'lib/rightscale_cli/configure.rb', line 45

def ()
  @directives.merge!( { :account_id => ask("RightScale account ID (e.g. 1337):")})
  update_conf
end

#allObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/rightscale_cli/configure.rb', line 93

def all()
  # currently this is the lazy way, each is written sequentially
  
  user
  password
  # do not ask for the api access token as we'll generate this from the refresh token
  # oauth
  refresh
  shard
  api
  puts 'Configuration saved.'
  if @directives[:refresh_token]
    puts 'Refresh API token now? (y/n):'
    if yesno
      system 'rs refresh token'
    end
  end
end

#apiObject



75
76
77
78
# File 'lib/rightscale_cli/configure.rb', line 75

def api()
  @directives.merge!( { :api_version => ask("RightScale API version (e.g. 1.5):") })
  update_conf
end

#oauthObject



63
64
65
66
# File 'lib/rightscale_cli/configure.rb', line 63

def oauth()
  @directives.merge!( { :access_token => ask("RightScale API access token:") })
  update_conf
end

#passwordObject



57
58
59
60
# File 'lib/rightscale_cli/configure.rb', line 57

def password()
  @directives.merge!( { :password_base64 => Base64.encode64(ask_pass).strip })
  update_conf
end

#refreshObject



69
70
71
72
# File 'lib/rightscale_cli/configure.rb', line 69

def refresh()
  @directives.merge!( { :refresh_token => ask('RightScale API refresh token:') })
  update_conf
end

#shardObject



81
82
83
84
85
# File 'lib/rightscale_cli/configure.rb', line 81

def shard()
  shard = ask("RightScale shard (e.g. us-4.rightscale.com):")
  @directives.merge!( { :api_url => "https://#{shard}", :token_endpoint => "https://#{shard}/api/oauth2" })
  update_conf
end

#showObject



88
89
90
# File 'lib/rightscale_cli/configure.rb', line 88

def show()
  puts @directives
end

#userObject



51
52
53
54
# File 'lib/rightscale_cli/configure.rb', line 51

def user()
  @directives.merge!( { :email => ask("RightScale username (e.g. [email protected]):") })
  update_conf
end