Class: Deis::Client
- Inherits:
-
Object
- Object
- Deis::Client
- Defined in:
- lib/deis_client.rb
Constant Summary collapse
- @@methods =
{ # method => HTTP-verb, path login: [:post, '/auth/login/'], apps: [:get, '/apps'], create_app: [:post, '/apps/'], delete_app: [:delete, '/apps/:app/'], app: [:get, '/apps/:app/'], app_logs: [:get, '/apps/:app/logs/'], app_run: [:post, '/apps/:app/run/'], containers: [:get, '/apps/:app/containers/'], scale: [:post, '/apps/:app/scale/'], config: [:get, '/apps/:app/config/'], set_config: [:post, '/apps/:app/config/'], domains: [:get, '/apps/:app/domains/'], builds: [:get, '/apps/:app/builds/'], create_build: [:post, '/apps/:app/builds/'], releases: [:get, '/apps/:app/releases/'], release: [:get, '/apps/:app/releases/:release/'], rollback_release: [:post, '/apps/:app/releases/rollback/'] }
Instance Method Summary collapse
- #app(id) ⇒ Object
- #app_logs(id) ⇒ Object
- #app_run(id, command) ⇒ Object
- #apps ⇒ Object
- #builds(app_id) ⇒ Object
- #config(app_id) ⇒ Object
- #containers(app_id) ⇒ Object
- #create_app(id = nil) ⇒ Object
- #create_build(app_id, image) ⇒ Object
- #delete_app(id) ⇒ Object
- #domains(app_id) ⇒ Object
-
#initialize(deis_url, username, password) ⇒ Client
constructor
A new instance of Client.
- #login ⇒ Object
- #release(app_id, release) ⇒ Object
- #releases(app_id) ⇒ Object
- #rollback_release(app_id, release) ⇒ Object
- #scale(app_id, type_number_hash) ⇒ Object
- #set_config(app_id, values) ⇒ Object
Constructor Details
#initialize(deis_url, username, password) ⇒ Client
Returns a new instance of Client.
79 80 81 82 83 |
# File 'lib/deis_client.rb', line 79 def initialize(deis_url, username, password) @http = Deis::ApiWrapper.new deis_url @headers = {'Content-Type' => 'application/json'} @auth = { username: username, password: password } end |
Instance Method Details
#app(id) ⇒ Object
112 113 114 |
# File 'lib/deis_client.rb', line 112 def app(id) perform :app, app: id end |
#app_logs(id) ⇒ Object
116 117 118 |
# File 'lib/deis_client.rb', line 116 def app_logs(id) perform :app_logs, app: id end |
#app_run(id, command) ⇒ Object
120 121 122 |
# File 'lib/deis_client.rb', line 120 def app_run(id, command) perform :app_run, { app: id }, command: command end |
#apps ⇒ Object
96 97 98 |
# File 'lib/deis_client.rb', line 96 def apps perform :apps end |
#builds(app_id) ⇒ Object
144 145 146 |
# File 'lib/deis_client.rb', line 144 def builds(app_id) perform :builds, app: app_id end |
#config(app_id) ⇒ Object
132 133 134 |
# File 'lib/deis_client.rb', line 132 def config(app_id) perform :config, app: app_id end |
#containers(app_id) ⇒ Object
124 125 126 |
# File 'lib/deis_client.rb', line 124 def containers(app_id) perform :containers, app: app_id end |
#create_app(id = nil) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/deis_client.rb', line 100 def create_app(id = nil) if id perform :create_app, {}, id: id else perform :create_app end end |
#create_build(app_id, image) ⇒ Object
148 149 150 |
# File 'lib/deis_client.rb', line 148 def create_build(app_id, image) perform :create_build, { app: app_id }, image: image end |
#delete_app(id) ⇒ Object
108 109 110 |
# File 'lib/deis_client.rb', line 108 def delete_app(id) perform :delete_app, app: id end |
#domains(app_id) ⇒ Object
140 141 142 |
# File 'lib/deis_client.rb', line 140 def domains(app_id) perform :domains, app: app_id end |
#login ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/deis_client.rb', line 85 def login verb, path = @@methods[:login] response = @http.public_send(verb, path, body: @auth) raise AuthorizationError.new unless response.code == 200 @token = response['token'] @headers['Authorization'] = "token #{@token}" response end |
#release(app_id, release) ⇒ Object
156 157 158 |
# File 'lib/deis_client.rb', line 156 def release(app_id, release) perform :releases, app: app_id, release: release end |
#releases(app_id) ⇒ Object
152 153 154 |
# File 'lib/deis_client.rb', line 152 def releases(app_id) perform :releases, app: app_id end |
#rollback_release(app_id, release) ⇒ Object
160 161 162 |
# File 'lib/deis_client.rb', line 160 def rollback_release(app_id, release) perform :rollback_release, { app: app_id }, release: release end |
#scale(app_id, type_number_hash) ⇒ Object
128 129 130 |
# File 'lib/deis_client.rb', line 128 def scale(app_id, type_number_hash) perform :scale, { app: app_id }, type_number_hash end |
#set_config(app_id, values) ⇒ Object
136 137 138 |
# File 'lib/deis_client.rb', line 136 def set_config(app_id, values) perform :set_config, { app: app_id }, values: values end |