class AnsibleTowerClient::JobTemplateV2

Public Instance Methods

launch(options = {}) click to toggle source
# File lib/ansible_tower_client/v2/job_template_v2.rb, line 3
def launch(options = {})
  launch_url = "#{url}launch/"
  options = options.dup
  new_limit = options.delete(:limit) || options.delete('limit')
  response = with_temporary_changes(new_limit) do
    api.post(launch_url, options).body
  end

  job = JSON.parse(response)
  api.jobs.find(job['job'])
end

Private Instance Methods

patch(body) click to toggle source
# File lib/ansible_tower_client/v2/job_template_v2.rb, line 28
def patch(body)
  api.patch do |req|
    req.url(url)
    req.headers['Content-Type'] = 'application/json'
    req.body = body
  end
end
with_temporary_changes(in_limit) { || ... } click to toggle source
# File lib/ansible_tower_client/v2/job_template_v2.rb, line 17
def with_temporary_changes(in_limit)
  old_limit = limit
  new_limit = in_limit
  patch("{ \"limit\": \"#{new_limit}\" }")
  begin
    yield
  ensure
    patch("{ \"limit\": \"#{old_limit}\" }")
  end
end