class Ancor::CLI::Client
Constants
- CONTENT_TYPE_JSON
- CONTENT_TYPE_YAML
Public Class Methods
new(options)
click to toggle source
# File lib/ancor/cli/client.rb, line 7 def initialize(options) host = options.fetch(:host) port = options.fetch(:port) url = "http://#{host}:#{port}/v1/" @connection = Faraday.new(url: url) do |faraday| faraday.response :logger if options[:debug] faraday.adapter Faraday.default_adapter end end
Public Instance Methods
add_env(slug)
click to toggle source
# File lib/ancor/cli/client.rb, line 71 def add_env(slug) request_body = { slug: slug } post 'environments', CONTENT_TYPE_JSON, request_body.to_json end
add_instance(role_slug)
click to toggle source
# File lib/ancor/cli/client.rb, line 52 def add_instance(role_slug) request_body = { role: role_slug } post 'instances', CONTENT_TYPE_JSON, request_body.to_json end
commit(slug)
click to toggle source
# File lib/ancor/cli/client.rb, line 23 def commit(slug) request_body = { commit: true } put "environments/#{slug}", CONTENT_TYPE_JSON, request_body.to_json end
list_envs()
click to toggle source
# File lib/ancor/cli/client.rb, line 36 def list_envs get 'environments' end
list_goals()
click to toggle source
# File lib/ancor/cli/client.rb, line 32 def list_goals get 'goals' end
list_instances()
click to toggle source
# File lib/ancor/cli/client.rb, line 48 def list_instances get 'instances' end
list_roles()
click to toggle source
# File lib/ancor/cli/client.rb, line 40 def list_roles get 'roles' end
list_tasks()
click to toggle source
# File lib/ancor/cli/client.rb, line 44 def list_tasks get 'tasks' end
plan(slug, arml_spec)
click to toggle source
# File lib/ancor/cli/client.rb, line 28 def plan(slug, arml_spec) post "environments/#{slug}/plan", CONTENT_TYPE_YAML, arml_spec end
remove_env(slug)
click to toggle source
# File lib/ancor/cli/client.rb, line 76 def remove_env(slug) @connection.delete "environments/#{slug}" end
remove_instance(old_id)
click to toggle source
# File lib/ancor/cli/client.rb, line 57 def remove_instance(old_id) @connection.delete "instances/#{old_id}" end
replace_all_instances(role_slug)
click to toggle source
# File lib/ancor/cli/client.rb, line 66 def replace_all_instances(role_slug) request_body = { role: role_slug } post "instances/#{role_slug}/replace_all", CONTENT_TYPE_JSON, request_body.to_json end
replace_instance(old_id)
click to toggle source
# File lib/ancor/cli/client.rb, line 61 def replace_instance(old_id) request_body = { replace: true } put "instances/#{old_id}", CONTENT_TYPE_JSON, request_body.to_json end
version()
click to toggle source
# File lib/ancor/cli/client.rb, line 19 def version get '' end
Private Instance Methods
get(url)
click to toggle source
@param [String] url @return [Faraday::Response]
# File lib/ancor/cli/client.rb, line 84 def get(url) @connection.get url end
post(url, content_type, body)
click to toggle source
@param [String] url @param [String] content_type @param [String] body @return [Faraday::Response]
# File lib/ancor/cli/client.rb, line 92 def post(url, content_type, body) @connection.post do |req| req.url url req.headers['Content-Type'] = content_type req.body = body end end
put(url, content_type, body)
click to toggle source
# File lib/ancor/cli/client.rb, line 100 def put(url, content_type, body) @connection.put do |req| req.url url req.headers['Content-Type'] = content_type req.body = body end end