Class: Kontena::StacksClient
- Inherits:
-
Client
- Object
- Client
- Kontena::StacksClient
show all
- Defined in:
- lib/kontena/stacks_client.rb
Constant Summary
collapse
- ACCEPT_JSON =
{ 'Accept' => 'application/json' }
- ACCEPT_YAML =
{ 'Accept' => 'application/yaml' }
- CT_YAML =
{ 'Content-Type' => 'application/yaml' }
Constants inherited
from Client
Client::ACCEPT, Client::AUTHORIZATION, Client::CLIENT_ID, Client::CLIENT_SECRET, Client::CONTENT_JSON, Client::CONTENT_TYPE, Client::CONTENT_URLENCODED, Client::JSON_REGEX
Instance Attribute Summary
Attributes inherited from Client
#api_url, #default_headers, #host, #http_client, #last_response, #logger, #options, #path_prefix, #token
Instance Method Summary
collapse
Methods inherited from Client
#authentication_ok?, #basic_auth_header, #bearer_authorization_header, #client_id, #client_secret, #delete, #exchange_code, #get, #get_stream, #initialize, #patch, #post, #put, #refresh_request_params, #refresh_token, #request, #server_version, #token_account, #token_expired?
Instance Method Details
#destroy(stack_name, version = nil) ⇒ Object
37
38
39
|
# File 'lib/kontena/stacks_client.rb', line 37
def destroy(stack_name, version = nil)
delete(path_to(stack_name, version), {})
end
|
#path_to(stack_name, version = nil) ⇒ Object
10
11
12
|
# File 'lib/kontena/stacks_client.rb', line 10
def path_to(stack_name, version = nil)
version ? "/stack/#{stack_name}/version/#{version}" : "/stack/#{stack_name}"
end
|
#pull(stack_name, version = nil) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/kontena/stacks_client.rb', line 26
def pull(stack_name, version = nil)
get(path_to(stack_name, version), {}, ACCEPT_YAML)
rescue StandardError => ex
ex.message << " : #{path_to(stack_name, version)}"
raise ex, ex.message
end
|
#push(stack_name, version, data) ⇒ Object
14
15
16
|
# File 'lib/kontena/stacks_client.rb', line 14
def push(stack_name, version, data)
post('/stack/', data, {}, CT_YAML)
end
|
#search(query) ⇒ Object
33
34
35
|
# File 'lib/kontena/stacks_client.rb', line 33
def search(query)
get('/search', { q: query }, {}, ACCEPT_JSON)['stacks']
end
|
#show(stack_name, stack_version = nil) ⇒ Object
18
19
20
|
# File 'lib/kontena/stacks_client.rb', line 18
def show(stack_name, stack_version = nil)
get("#{path_to(stack_name, stack_version)}", {}, ACCEPT_JSON)
end
|
#versions(stack_name) ⇒ Object
22
23
24
|
# File 'lib/kontena/stacks_client.rb', line 22
def versions(stack_name)
get("#{path_to(stack_name, nil)}/versions", {}, ACCEPT_JSON)['versions']
end
|