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/'], add_domain: [:post, '/apps/:app/domains/'], remove_domain: [:delete, '/apps/:app/domains/:domain'], 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
- #add_domain(app_id, domain) ⇒ Object
- #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
- #remove_domain(app_id, domain) ⇒ 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.
81 82 83 84 85 |
# File 'lib/deis_client.rb', line 81 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
#add_domain(app_id, domain) ⇒ Object
146 147 148 |
# File 'lib/deis_client.rb', line 146 def add_domain(app_id, domain) perform :add_domain, { app: app_id }, domain: domain end |
#app(id) ⇒ Object
114 115 116 |
# File 'lib/deis_client.rb', line 114 def app(id) perform :app, app: id end |
#app_logs(id) ⇒ Object
118 119 120 |
# File 'lib/deis_client.rb', line 118 def app_logs(id) perform :app_logs, app: id end |
#app_run(id, command) ⇒ Object
122 123 124 |
# File 'lib/deis_client.rb', line 122 def app_run(id, command) perform :app_run, { app: id }, command: command end |
#apps ⇒ Object
98 99 100 |
# File 'lib/deis_client.rb', line 98 def apps perform :apps end |
#builds(app_id) ⇒ Object
154 155 156 |
# File 'lib/deis_client.rb', line 154 def builds(app_id) perform :builds, app: app_id end |
#config(app_id) ⇒ Object
134 135 136 |
# File 'lib/deis_client.rb', line 134 def config(app_id) perform :config, app: app_id end |
#containers(app_id) ⇒ Object
126 127 128 |
# File 'lib/deis_client.rb', line 126 def containers(app_id) perform :containers, app: app_id end |
#create_app(id = nil) ⇒ Object
102 103 104 105 106 107 108 |
# File 'lib/deis_client.rb', line 102 def create_app(id = nil) if id perform :create_app, {}, id: id else perform :create_app end end |
#create_build(app_id, image) ⇒ Object
158 159 160 |
# File 'lib/deis_client.rb', line 158 def create_build(app_id, image) perform :create_build, { app: app_id }, image: image end |
#delete_app(id) ⇒ Object
110 111 112 |
# File 'lib/deis_client.rb', line 110 def delete_app(id) perform :delete_app, app: id end |
#domains(app_id) ⇒ Object
142 143 144 |
# File 'lib/deis_client.rb', line 142 def domains(app_id) perform :domains, app: app_id end |
#login ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/deis_client.rb', line 87 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
166 167 168 |
# File 'lib/deis_client.rb', line 166 def release(app_id, release) perform :releases, app: app_id, release: release end |
#releases(app_id) ⇒ Object
162 163 164 |
# File 'lib/deis_client.rb', line 162 def releases(app_id) perform :releases, app: app_id end |
#remove_domain(app_id, domain) ⇒ Object
150 151 152 |
# File 'lib/deis_client.rb', line 150 def remove_domain(app_id, domain) perform :remove_domain, { app: app_id, domain: domain } end |
#rollback_release(app_id, release) ⇒ Object
170 171 172 |
# File 'lib/deis_client.rb', line 170 def rollback_release(app_id, release) perform :rollback_release, { app: app_id }, release: release end |
#scale(app_id, type_number_hash) ⇒ Object
130 131 132 |
# File 'lib/deis_client.rb', line 130 def scale(app_id, type_number_hash) perform :scale, { app: app_id }, type_number_hash end |
#set_config(app_id, values) ⇒ Object
138 139 140 |
# File 'lib/deis_client.rb', line 138 def set_config(app_id, values) perform :set_config, { app: app_id }, values: values end |