Class: Argonaut::Cli
- Inherits:
-
Object
- Object
- Argonaut::Cli
- Defined in:
- lib/argonaut/cli.rb
Instance Attribute Summary collapse
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
Instance Method Summary collapse
- #clear_reservations ⇒ Object
- #find_app(app_name) ⇒ Object
-
#initialize(gateway:) ⇒ Cli
constructor
A new instance of Cli.
- #initialize_configuration_file ⇒ Object
-
#list_reservations ⇒ Object
Gets list of current user’s reservations.
- #release!(env_name, app_name) ⇒ Object
-
#reservations(team_name_or_id) ⇒ Object
Gets all the reservations for the given team.
- #reserve!(env_name, app_name) ⇒ Object
- #teams ⇒ Object
Constructor Details
#initialize(gateway:) ⇒ Cli
Returns a new instance of Cli.
8 9 10 |
# File 'lib/argonaut/cli.rb', line 8 def initialize(gateway:) @gateway = gateway end |
Instance Attribute Details
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
6 7 8 |
# File 'lib/argonaut/cli.rb', line 6 def gateway @gateway end |
Instance Method Details
#clear_reservations ⇒ Object
27 28 29 |
# File 'lib/argonaut/cli.rb', line 27 def clear_reservations @gateway.delete(path: "clear_reservations", data: nil) end |
#find_app(app_name) ⇒ Object
41 42 43 44 |
# File 'lib/argonaut/cli.rb', line 41 def find_app(app_name) data = { application_name: app_name } @gateway.fetch(path: "find_application", data: data) end |
#initialize_configuration_file ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/argonaut/cli.rb', line 46 def initialize_configuration_file return false if File.exist? Argonaut::Constants::SETTINGS_FILE File.open( Argonaut::Constants::SETTINGS_FILE, "w" ) do |f| f.write %q( # The only required fields needed by the gem to function are api_token and url_root api_token: YOUR_TOKEN url_root: https://theargonaut-api.herokuapp.com # Below are the optional settings to customize output options: colorize_rows: true time_format: '%d %b %Y %l:%M %p' high_contrast_colors: true ) end true end |
#list_reservations ⇒ Object
Gets list of current user’s reservations
23 24 25 |
# File 'lib/argonaut/cli.rb', line 23 def list_reservations @gateway.fetch(path: "list_reservations") end |
#release!(env_name, app_name) ⇒ Object
36 37 38 39 |
# File 'lib/argonaut/cli.rb', line 36 def release!(env_name, app_name) data = { application_name: app_name, environment_name: env_name } @gateway.delete(path: "reservations", data: data) end |
#reservations(team_name_or_id) ⇒ Object
Gets all the reservations for the given team
18 19 20 |
# File 'lib/argonaut/cli.rb', line 18 def reservations(team_name_or_id) @gateway.fetch(path: "teams/#{team_name_or_id}/reservations") end |
#reserve!(env_name, app_name) ⇒ Object
31 32 33 34 |
# File 'lib/argonaut/cli.rb', line 31 def reserve!(env_name, app_name) data = { application_name: app_name, environment_name: env_name } @gateway.post(path: "reservations", data: data) end |
#teams ⇒ Object
12 13 14 15 |
# File 'lib/argonaut/cli.rb', line 12 def teams raw_data = @gateway.fetch(path: 'teams') raw_data['data'] end |