Class: Conductor::Workflow

Inherits:
Model
  • Object
show all
Defined in:
lib/nf-conductor/http/workflow.rb

Instance Attribute Summary

Attributes inherited from Model

#response, #status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

build

Constructor Details

#initialize(response) ⇒ Workflow

Returns a new instance of Workflow.



3
4
5
# File 'lib/nf-conductor/http/workflow.rb', line 3

def initialize(response)
  super(response)
end

Class Method Details

.decide_workflow(workflow_id) ⇒ Object

PUT /workflow/decide/workflowId Starts the decision task for a workflow



74
75
76
77
# File 'lib/nf-conductor/http/workflow.rb', line 74

def decide_workflow(workflow_id)
  response = Connection.new.put("/workflow/decide/#{workflow_id}")
  Workflow.build(response)
end

.delete_workflow(workflow_id) ⇒ Object

DELETE /workflow/workflowId/remove Removes the workflow from the system



129
130
131
132
# File 'lib/nf-conductor/http/workflow.rb', line 129

def delete_workflow(workflow_id)
  response = Connection.new.delete("/workflow/#{workflow_id}/remove")
  Workflow.build(response)
end

.get_correlated_workflows(workflow_name, correlation_id, include_closed: false, include_tasks: false) ⇒ Object

GET /workflow/name/correlated/correlationId Lists workflows for the given correlation id



34
35
36
37
38
39
# File 'lib/nf-conductor/http/workflow.rb', line 34

def get_correlated_workflows(workflow_name, correlation_id, include_closed: false, include_tasks: false)
  response = Connection.new.get(
    "/workflow/#{workflow_name}/correlated/#{correlation_id}?includeClosed=#{include_closed}&includeTasks=#{include_tasks}"
  )
  Workflow.build(response)
end

.get_running_workflow(workflow_name, version: nil, start_time: nil, end_time: nil) ⇒ Object

GET /workflow/running/name Retrieve all the running workflows



62
63
64
65
66
67
68
69
70
# File 'lib/nf-conductor/http/workflow.rb', line 62

def get_running_workflow(workflow_name, version: nil, start_time: nil, end_time: nil)
  query_string = "/workflow/running/#{workflow_name}?"
  query_string += "version=#{version}" if version
  query_string += "&startTime=#{start_time}" if start_time
  query_string += "&endTime=#{end_time}" if end_time

  response = Connection.new.get(query_string)
  Workflow.build(response)
end

.get_workflow(workflow_id, include_tasks: true) ⇒ Object

GET /workflow/workflowId Gets the workflow by workflow id



53
54
55
56
57
58
# File 'lib/nf-conductor/http/workflow.rb', line 53

def get_workflow(workflow_id, include_tasks: true)
  response = Connection.new.get(
    "/workflow/#{workflow_id}?includeTasks=#{include_tasks}"
  )
  Workflow.build(response)
end

.pause_workflow(workflow_id) ⇒ Object

PUT /workflow/workflowId/pause Pauses the workflow



81
82
83
84
# File 'lib/nf-conductor/http/workflow.rb', line 81

def pause_workflow(workflow_id)
  response = Connection.new.put("/workflow/#{workflow_id}/pause")
  Workflow.build(response)
end

.rerun_workflow(workflow_id, rerun_body: {}) ⇒ Object

POST /workflow/workflowId/rerun Reruns the workflow from a specific task



105
106
107
108
109
110
111
# File 'lib/nf-conductor/http/workflow.rb', line 105

def rerun_workflow(workflow_id, rerun_body: {})
  response = Connection.new.post(
    "/workflow/#{workflow_id}/rerun",
    { body: rerun_body.to_json }
  )
  Workflow.build(response)
end

.reset_callbacks_for_workflow(workflow_id) ⇒ Object

POST /workflow/workflowId/resetcallbacks Resets callback times of all in_progress tasks to 0



136
137
138
139
# File 'lib/nf-conductor/http/workflow.rb', line 136

def reset_callbacks_for_workflow(workflow_id)
  response = Connection.new.post("/workflow/#{workflow_id}/resetcallbacks")
  Workflow.build(response)
end

.restart_workflow(workflow_id) ⇒ Object

POST /workflow/workflowId/restart Restarts a completed workflow



115
116
117
118
# File 'lib/nf-conductor/http/workflow.rb', line 115

def restart_workflow(workflow_id)
  response = Connection.new.post("/workflow/#{workflow_id}/restart")
  Workflow.build(response)
end

.resume_workflow(workflow_id) ⇒ Object

PUT /workflow/workflowId/resume Resumes the workflow



88
89
90
91
# File 'lib/nf-conductor/http/workflow.rb', line 88

def resume_workflow(workflow_id)
  response = Connection.new.put("/workflow/#{workflow_id}/resume")
  Workflow.build(response)
end

.retry_workflow(workflow_id) ⇒ Object

POST /workflow/workflowId/retry Retries the last failed task



122
123
124
125
# File 'lib/nf-conductor/http/workflow.rb', line 122

def retry_workflow(workflow_id)
  response = Connection.new.post("/workflow/#{workflow_id}/retry")
  Workflow.build(response)
end

.search_workflows(start: nil, size: nil, sort: nil, free_text: nil, query: nil) ⇒ Object

GET /workflow/search



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/nf-conductor/http/workflow.rb', line 142

def search_workflows(start: nil, size: nil, sort: nil, free_text: nil, query: nil)
  query_string = "/workflow/search?"
  query_string += "start=#{start}" if start
  query_string += "&size=#{size}" if size
  query_string += "&sort=#{sort}" if sort
  query_string += "&freeText=#{free_text}" if free_text
  query_string += "&query=#{query}" if query

  response = Connection.new.get(query_string)
  Workflow.build(response)
end

.skip_task_for_workflow(workflow_id, task_name, task_body: {}) ⇒ Object

PUT /workflow/workflowId/skiptask/taskReferenceName Skips a given task from a current running workflow



95
96
97
98
99
100
101
# File 'lib/nf-conductor/http/workflow.rb', line 95

def skip_task_for_workflow(workflow_id, task_name, task_body: {})
  response = Connection.new.put(
    "/workflow/#{workflow_id}/skiptask/#{task_name}",
    { body: task_body.to_json }
  )
  Workflow.build(response)
end

.start_workflow(name, version: nil, correlation_id: nil, body: {}) ⇒ Object

POST /workflow/name Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/nf-conductor/http/workflow.rb', line 10

def start_workflow(name, version: nil, correlation_id: nil, body: {})
  query_string = "/workflow/#{name}?"
  query_string += "version=#{version}" if version
  query_string += "&correlationId=#{correlation_id}" if correlation_id

  response = Connection.new.post(
    query_string,
    { body: body.to_json }
  )
  Workflow.build(response)
end

.start_workflow_with_domains(workflow) ⇒ Object

POST /workflow Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain



24
25
26
27
28
29
30
# File 'lib/nf-conductor/http/workflow.rb', line 24

def start_workflow_with_domains(workflow)
  response = Connection.new.post(
    "/workflow",
    { body: workflow.to_json }
  )
  Workflow.build(response)
end

.terminate_workflow(workflow_id, reason: nil) ⇒ Object

DELETE /workflow/workflowId Terminate workflow execution



43
44
45
46
47
48
49
# File 'lib/nf-conductor/http/workflow.rb', line 43

def terminate_workflow(workflow_id, reason: nil)
  query_string = "/workflow/#{workflow_id}?"
  query_string += "reason=#{reason}" if reason

  response = Connection.new.delete(query_string)
  Workflow.build(response)
end