create_action(definition)
click to toggle source
def create_action(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "actions"
)
end
create_action_execution(action, input = {}, params = {})
click to toggle source
def create_action_execution(action, input = {}, params = {})
data = {:name => action}
data[:input] = Fog::JSON.encode(input) unless input.empty?
data[:params] = Fog::JSON.encode(params) unless params.empty?
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "action_executions"
)
end
create_cron_trigger(name, workflow_identifier, workflow_input = nil, workflow_params = nil, pattern = "* * * * *", first_time = nil, count = nil)
click to toggle source
def create_cron_trigger(name,
workflow_identifier,
workflow_input = nil,
workflow_params = nil,
pattern = "* * * * *",
first_time = nil,
count = nil)
data = {
:name => name,
:pattern => pattern,
:first_execution_time => first_time,
:remaining_executions => count
}
if workflow_identifier
data[:workflow_id] = workflow_identifier
end
if workflow_input
data[:workflow_input] = Fog::JSON.encode(workflow_input)
end
if workflow_params
data[:workflow_params] = Fog::JSON.encode(workflow_params)
end
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "cron_triggers"
)
end
create_environment(definition)
click to toggle source
def create_environment(definition)
unless definition["variables"].nil?
definition["variables"] = Fog::JSON.encode(definition["variables"])
end
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "environments"
)
end
create_execution(workflow, input = {})
click to toggle source
def create_execution(workflow, input = {})
data = {:workflow_name => workflow}
data[:input] = Fog::JSON.encode(input) unless input.empty?
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "executions"
)
end
create_workbook(definition)
click to toggle source
def create_workbook(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "workbooks"
)
end
create_workflow(definition)
click to toggle source
def create_workflow(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "workflows"
)
end
delete_action(name)
click to toggle source
def delete_action(name)
request(
:expects => 204,
:method => "DELETE",
:path => "actions/#{URI.encode(name)}"
)
end
delete_action_execution(id)
click to toggle source
def delete_action_execution(id)
request(
:expects => 204,
:method => "DELETE",
:path => "action_executions/#{id}"
)
end
delete_cron_trigger(name)
click to toggle source
def delete_cron_trigger(name)
request(
:expects => 204,
:method => "DELETE",
:path => "cron_triggers/#{URI.encode(name)}"
)
end
delete_environment(name)
click to toggle source
def delete_environment(name)
request(
:expects => 204,
:method => "DELETE",
:path => "environments/#{URI.encode(name)}"
)
end
delete_execution(id)
click to toggle source
def delete_execution(id)
request(
:expects => 204,
:method => "DELETE",
:path => "executions/#{id}"
)
end
delete_workbook(name)
click to toggle source
def delete_workbook(name)
request(
:expects => 204,
:method => "DELETE",
:path => "workbooks/#{URI.encode(name)}"
)
end
delete_workflow(identifier)
click to toggle source
def delete_workflow(identifier)
request(
:expects => 204,
:method => "DELETE",
:path => "workflows/#{identifier}"
)
end
get_action(name)
click to toggle source
def get_action(name)
request(
:expects => 200,
:method => "GET",
:path => "actions/#{URI.encode(name)}"
)
end
get_action_execution(execution_id)
click to toggle source
def get_action_execution(execution_id)
request(
:expects => 200,
:method => "GET",
:path => "action_executions/#{execution_id}"
)
end
get_cron_trigger(name)
click to toggle source
def get_cron_trigger(name)
request(
:expects => 200,
:method => "GET",
:path => "cron_triggers/#{URI.encode(name)}"
)
end
get_environment(name)
click to toggle source
def get_environment(name)
request(
:expects => 200,
:method => "GET",
:path => "environments/#{URI.encode(name)}"
)
end
get_execution(execution_id)
click to toggle source
def get_execution(execution_id)
request(
:expects => 200,
:method => "GET",
:path => "executions/#{execution_id}"
)
end
get_task(id)
click to toggle source
def get_task(id)
request(
:expects => 200,
:method => "GET",
:path => "tasks/#{id}"
)
end
get_workbook(name)
click to toggle source
def get_workbook(name)
request(
:expects => 200,
:method => "GET",
:path => "workbooks/#{URI.encode(name)}"
)
end
get_workflow(identifier)
click to toggle source
def get_workflow(identifier)
request(
:expects => 200,
:method => "GET",
:path => "workflows/#{identifier}"
)
end
list_action_executions()
click to toggle source
def list_action_executions
request(
:expects => 200,
:method => "GET",
:path => "action_executions"
)
end
list_actions(params = {})
click to toggle source
def list_actions(params = {})
body = Fog::JSON.encode(params)
request(
:body => body,
:expects => 200,
:method => "GET",
:path => "actions"
)
end
list_cron_triggers()
click to toggle source
def list_cron_triggers
request(
:expects => 200,
:method => "GET",
:path => "cron_triggers"
)
end
list_environments()
click to toggle source
def list_environments
request(
:expects => 200,
:method => "GET",
:path => "environments"
)
end
list_executions()
click to toggle source
def list_executions
request(
:expects => 200,
:method => "GET",
:path => "executions"
)
end
list_services()
click to toggle source
def list_services
request(
:expects => 200,
:method => "GET",
:path => "services"
)
end
list_tasks(workflow_execution_id)
click to toggle source
def list_tasks(workflow_execution_id)
request(
:expects => 200,
:method => "GET",
:path => "executions/#{workflow_execution_id}/tasks"
)
end
list_workbooks()
click to toggle source
def list_workbooks
request(
:expects => 200,
:method => "GET",
:path => "workbooks"
)
end
list_workflows(params = {})
click to toggle source
def list_workflows(params = {})
body = Fog::JSON.encode(params)
request(
:body => body,
:expects => 200,
:method => "GET",
:path => "workflows"
)
end
request(params)
click to toggle source
def request(params)
response = @connection.request(
params.merge(
:headers => {
'Content-Type' => 'application/json',
'X-Auth-Token' => @auth_token
}.merge!(params[:headers] || {}),
:path => "#{@path}/#{params[:path]}"
)
)
rescue Excon::Errors::Unauthorized => error
if error.response.body != "Bad username or password"
@openstack_must_reauthenticate = true
authenticate
retry
else
raise error
end
rescue Excon::Errors::HTTPStatusError => error
raise case error
when Excon::Errors::NotFound
Fog::Workflow::OpenStack::NotFound.slurp(error)
else
error
end
else
unless response.body.empty?
response.body = Fog::JSON.decode(response.body)
end
response
end
rerun_task(task_ex_id)
click to toggle source
def rerun_task(task_ex_id)
rerun_payload = {
:id => task_ex_id,
:state => 'RUNNING',
:reset => true
}
body = Fog::JSON.encode(rerun_payload)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "tasks/#{task_ex_id}"
)
end
update_action(definition)
click to toggle source
def update_action(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "actions"
)
end
update_action_execution(id, name, value)
click to toggle source
def update_action_execution(id, name, value)
data = {:id => id}
data[name] = Fog::JSON.encode(value)
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "action_executions"
)
end
update_environment(definition)
click to toggle source
def update_environment(definition)
unless definition["variables"].nil?
definition["variables"] = Fog::JSON.encode(definition["variables"])
end
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "environments"
)
end
update_execution(id, name, value)
click to toggle source
def update_execution(id, name, value)
data = {:id => id}
data[name] = Fog::JSON.encode(value)
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "executions"
)
end
update_workbook(definition)
click to toggle source
def update_workbook(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "workbooks"
)
end
update_workflow(definition)
click to toggle source
def update_workflow(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "workflows"
)
end
validate_action(definition)
click to toggle source
def validate_action(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "POST",
:path => "actions/validate"
)
end
validate_workbook(definition)
click to toggle source
def validate_workbook(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "POST",
:path => "workbooks/validate"
)
end
validate_workflow(definition)
click to toggle source
def validate_workflow(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "POST",
:path => "workflows/validate"
)
end