Class: VcoWorkflows::WorkflowToken
- Inherits:
-
Object
- Object
- VcoWorkflows::WorkflowToken
- Defined in:
- lib/vcoworkflows/workflowtoken.rb
Overview
WorkflowToken is used for workflow execution results, and contains as much data on the given workflow execution instance as vCO can provide.
Instance Attribute Summary collapse
- #content_exception ⇒ String readonly
- #current_item_name ⇒ String readonly
- #current_item_state ⇒ String readonly
-
#end_date ⇒ String
readonly
Execution end date.
- #global_state ⇒ String readonly
-
#href ⇒ String
readonly
Execution href.
-
#id ⇒ String
readonly
Workflow execution ID.
-
#input_parameters ⇒ VcoWorkflows::WorkflowParameter{}
readonly
Workflow execution input parameters.
-
#json_content ⇒ String
readonly
Source JSON.
-
#name ⇒ String
readonly
Workflow name.
-
#output_parameters ⇒ VcoWorkflows::WorkflowParameter{}
readonly
Workflow execution output parameters.
-
#start_date ⇒ String
readonly
Execution start date.
-
#started_by ⇒ String
readonly
Execution started by.
-
#state ⇒ String
readonly
Execution state.
-
#workflow_id ⇒ String
readonly
Workflow ID.
Instance Method Summary collapse
-
#alive? ⇒ Boolean
Is the workflow execution still alive?.
-
#initialize(workflow_service, workflow_id, execution_id) ⇒ VcoWorkflows::WorkflowToken
constructor
Create a new workflow token.
-
#running? ⇒ Boolean
Is the workflow actively running?.
-
#to_json ⇒ String
Convert this object to a JSON document (string).
-
#to_s ⇒ String
Convert this object to a string representation.
-
#waiting? ⇒ Boolean
Is the workflow in a waiting state?.
Constructor Details
#initialize(workflow_service, workflow_id, execution_id) ⇒ VcoWorkflows::WorkflowToken
Create a new workflow token
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 77 def initialize(workflow_service, workflow_id, execution_id) @service = workflow_service @workflow_id = workflow_id @json_content = @service.get_execution(workflow_id, execution_id) token = JSON.parse(@json_content) # rubocop:disable SpaceAroundOperators @id = token.key?('id') ? token['id'] : nil @name = token.key?('name') ? token['name'] : nil @state = token.key?('state') ? token['state'] : nil @href = token.key?('href') ? token['href'] : nil @start_date = token.key?('start-date') ? token['start-date'] : nil @end_date = token.key?('end-date') ? token['end-date'] : nil @started_by = token.key?('started-by') ? token['started-by'] : nil @current_item_name = token.key?('current-item-display-name') ? token['current-item-display-name'] : nil @current_item_state = token.key?('current-item-state') ? token['current-item-state'] : nil @global_state = token.key?('global-state') ? token['global-state'] : nil @content_exception = token.key?('content-exeption') ? token['content-exception'] : nil # rubocop:enable SpaceAroundOperators if token.key?('input-parameters') @input_parameters = VcoWorkflows::Workflow.parse_parameters(token['input-parameters']) else @input_parameters = {} end if token.key?('output-parameters') @output_parameters = VcoWorkflows::Workflow.parse_parameters(token['output-parameters']) else @output_parameters = {} end end |
Instance Attribute Details
#content_exception ⇒ String (readonly)
51 52 53 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 51 def content_exception @content_exception end |
#current_item_name ⇒ String (readonly)
45 46 47 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 45 def current_item_name @current_item_name end |
#current_item_state ⇒ String (readonly)
48 49 50 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 48 def current_item_state @current_item_state end |
#end_date ⇒ String (readonly)
Execution end date
38 39 40 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 38 def end_date @end_date end |
#global_state ⇒ String (readonly)
54 55 56 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 54 def global_state @global_state end |
#href ⇒ String (readonly)
Execution href
30 31 32 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 30 def href @href end |
#id ⇒ String (readonly)
Workflow execution ID
14 15 16 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 14 def id @id end |
#input_parameters ⇒ VcoWorkflows::WorkflowParameter{} (readonly)
Workflow execution input parameters
58 59 60 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 58 def input_parameters @input_parameters end |
#json_content ⇒ String (readonly)
Source JSON
66 67 68 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 66 def json_content @json_content end |
#name ⇒ String (readonly)
Workflow name
22 23 24 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 22 def name @name end |
#output_parameters ⇒ VcoWorkflows::WorkflowParameter{} (readonly)
Workflow execution output parameters
62 63 64 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 62 def output_parameters @output_parameters end |
#start_date ⇒ String (readonly)
Execution start date
34 35 36 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 34 def start_date @start_date end |
#started_by ⇒ String (readonly)
Execution started by
42 43 44 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 42 def started_by @started_by end |
#state ⇒ String (readonly)
Execution state
26 27 28 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 26 def state @state end |
#workflow_id ⇒ String (readonly)
Workflow ID
18 19 20 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 18 def workflow_id @workflow_id end |
Instance Method Details
#alive? ⇒ Boolean
Is the workflow execution still alive?
114 115 116 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 114 def alive? running? || waiting? end |
#running? ⇒ Boolean
Is the workflow actively running?
120 121 122 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 120 def running? state.eql?('running') end |
#to_json ⇒ String
Convert this object to a JSON document (string)
153 154 155 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 153 def to_json JSON.pretty_generate(JSON.parse(@json_content)) end |
#to_s ⇒ String
Convert this object to a string representation
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 134 def to_s string = "Execution ID: #{@id}\n" string << "Name: #{@name}\n" string << "Workflow ID: #{@workflow_id}\n" string << "State: #{@state}\n" string << "Start Date: #{Time.at(@start_date / 1000)}\n" string << "End Date: #{end_date.nil? ? '' : Time.at(@end_date / 1000)}\n" string << "Started By: #{@started_by}\n" string << "Content Exception: #{@content_exception}\n" unless @content_exception.nil? string << "\nInput Parameters:\n" @input_parameters.each_value { |wf_param| string << " #{wf_param}" if wf_param.set? } if @input_parameters.size > 0 string << "\nOutput Parameters:" << "\n" @output_parameters.each_value { |wf_param| string << " #{wf_param}" } if @output_parameters.size > 0 string end |
#waiting? ⇒ Boolean
Is the workflow in a waiting state?
126 127 128 |
# File 'lib/vcoworkflows/workflowtoken.rb', line 126 def waiting? state.match(/waiting/).nil? ? false : true end |