class OrchestratorClient
Constants
- VERSION
Attributes
config[RW]
http[R]
Public Class Methods
new(overrides, load_files=false)
click to toggle source
# File lib/orchestrator_client.rb, line 17 def initialize(overrides, load_files=false) @config = Config.new(overrides, load_files) @config.validate @http = create_http(config.root_url) end
Public Instance Methods
command()
click to toggle source
# File lib/orchestrator_client.rb, line 62 def command @command ||= OrchestratorClient::Command.new(self) end
create_http(root_url)
click to toggle source
# File lib/orchestrator_client.rb, line 23 def create_http(root_url) Faraday.new(url: root_url) do |f| f.headers['Content-Type'] = 'application/json' f.headers['X-Authentication'] = config.token f.headers['User-Agent'] = config['User-Agent'] f.ssl['ca_file'] = config['cacert'] f.ssl['version'] = :TLSv1_2 # Do not use net-http-persistent on windows if !!File::ALT_SEPARATOR f.adapter :net_http else f.adapter :net_http_persistent, pool_size: 5 do |http| http.idle_timeout = 30 http.read_timeout = config['read-timeout'] if config['read-timeout'] end end end end
get(location)
click to toggle source
# File lib/orchestrator_client.rb, line 42 def get(location) res = http.get(location) if res.status != 200 raise OrchestratorClient::ApiError.make_error_from_response(res) end JSON.parse(res.body) end
jobs()
click to toggle source
# File lib/orchestrator_client.rb, line 66 def jobs @jobs ||= OrchestratorClient::Jobs.new(self) end
new_job(options, type = :deploy)
click to toggle source
# File lib/orchestrator_client.rb, line 70 def new_job(options, type = :deploy) OrchestratorClient::Job.new(self, options, type) end
post(location, body)
click to toggle source
# File lib/orchestrator_client.rb, line 52 def post(location, body) res = http.post(location, body.to_json) unless Set.new([202, 200]).include? res.status raise OrchestratorClient::ApiError.make_error_from_response(res) end JSON.parse(res.body) end
root()
click to toggle source
# File lib/orchestrator_client.rb, line 86 def root get(url) end
run_task(options)
click to toggle source
# File lib/orchestrator_client.rb, line 74 def run_task(options) if options[:plan_job] || options['plan_job'] type = :plan_task else type = :task end job = OrchestratorClient::Job.new(self, options, type) job.start job.wait job.nodes['items'] end