Sha256: cada5a79747cb8c0a11c0e36d8f7fd91f90927b9adb4d82fd14259cb688e190c
Contents?: true
Size: 1.21 KB
Versions: 15
Compression:
Stored size: 1.21 KB
Contents
require_relative 'client' module Kontena class StacksClient < Client ACCEPT_JSON = { 'Accept' => 'application/json' } ACCEPT_YAML = { 'Accept' => 'application/yaml' } CT_YAML = { 'Content-Type' => 'application/yaml' } def full_uri(stack_name, version = nil) URI.join(api_url, path_to(stack_name, version)).to_s end def path_to(stack_name, version = nil) version ? "/stack/#{stack_name}/version/#{version}" : "/stack/#{stack_name}" end def push(stack_name, version, data) post('/stack/', data, {}, CT_YAML) end def show(stack_name, stack_version = nil) get("#{path_to(stack_name, stack_version)}", {}, ACCEPT_JSON) end def versions(stack_name) get("#{path_to(stack_name, nil)}/versions", {}, ACCEPT_JSON)['versions'] end 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 def search(query) get('/search', { q: query }, {}, ACCEPT_JSON)['stacks'] end def destroy(stack_name, version = nil) delete(path_to(stack_name, version), {}) end end end
Version data entries
15 entries across 15 versions & 1 rubygems