Class: C66::Commands::C66Toolbelt
- Inherits:
-
Thor
- Object
- Thor
- C66::Commands::C66Toolbelt
- Defined in:
- lib/c66/commands/c66_toolbelt.rb
Instance Method Summary collapse
Instance Method Details
#deploy ⇒ Object
276 277 278 279 280 281 282 283 284 285 |
# File 'lib/c66/commands/c66_toolbelt.rb', line 276 def deploy() begin get_stack([:stack]) abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil? response = token.post("#{base_url}/stacks/#{@stack}/redeploy.json", {}) say JSON.parse(response.body)['response']['message'] rescue OAuth2::Error => e abort "Could't find your stack, maybe it was moved, deleted or you accidentally mistyped the stack ID" end end |
#init ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/c66/commands/c66_toolbelt.rb', line 206 def init load_params result = client.auth_code.(:redirect_uri => values[:redirect_url], :scope => values[:scope]) say "Visit the URL below and paste the initialization code here" say result auth_code = ask("Authorization Code:") begin token = client.auth_code.get_token(auth_code, :redirect_uri => values[:redirect_url]) rescue OAuth2::Error => e abort e. end @config = { :auth_code => auth_code, :token => token.token, :refresh_token => token.refresh_token } save_config say "Configuration saved to #{config_file}" end |
#list ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/c66/commands/c66_toolbelt.rb', line 228 def list response = parse_response(token.get("#{base_url}/stacks.json")) if response['count'] != 0 response['response'].each do |stack| say "#{stack['name']} (#{stack['uid']}) : #{stack['environment']} - #{STATUS[stack['status']]}" end else say "No stacks found" end end |
#set ⇒ Object
263 264 265 266 267 268 269 270 271 272 |
# File 'lib/c66/commands/c66_toolbelt.rb', line 263 def set() begin get_stack([:stack]) abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil? response = token.post("#{base_url}/stacks/#{@stack}/setting.json", { :body => { :setting_name => [:setting_name], :setting_value => [:value] }}) say "Setting applied" if JSON.parse(response.body)['response']['ok'] rescue OAuth2::Error => e abort e. end end |
#settings ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/c66/commands/c66_toolbelt.rb', line 242 def settings() begin get_stack([:stack]) abort "No stack provided or saved, please use '--stack' or '-s' option" if @stack.nil? response = token.get("#{base_url}/stacks/#{@stack}/settings.json") settings = JSON.parse(response.body)['response'] abort "No settings found" if settings.nil? settings.each do |setting| say "#{setting['key']}\t\t#{setting['value']}\t#{setting['readonly'] ? '(readonly)' : ''}\r\n" end rescue OAuth2::Error => e abort e. end end |