Class: Retab::WorkflowRun

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/workflow_runs/workflow_run.rb

Constant Summary collapse

HASH_ATTRS =
{
  id: :id,
  workflow: :workflow,
  trigger: :trigger,
  lifecycle: :lifecycle,
  timing: :timing,
  inputs: :inputs
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

deep_symbolize, #inspect, normalize, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ WorkflowRun

Returns a new instance of WorkflowRun.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/retab/workflow_runs/workflow_run.rb', line 26

def initialize(json)
  super()
  hash = self.class.normalize(json)
  @id = hash[:id]
  @workflow = hash[:workflow] ? Retab::WorkflowSnapshotRef.new(hash[:workflow]) : nil
  @trigger = hash[:trigger] ? (
    case hash[:trigger][:type]
    when "api"
      Retab::ApiTrigger.new(hash[:trigger])
    when "email"
      Retab::EmailTrigger.new(hash[:trigger])
    when "manual"
      Retab::ManualTrigger.new(hash[:trigger])
    when "restart"
      Retab::RestartTrigger.new(hash[:trigger])
    when "schedule"
      Retab::ScheduleTrigger.new(hash[:trigger])
    when "webhook"
      Retab::WebhookTrigger.new(hash[:trigger])
    else
      hash[:trigger]
    end
  ) : nil
  @lifecycle = hash[:lifecycle] ? (
    case hash[:lifecycle][:status]
    when "awaiting_review"
      Retab::AwaitingReviewRun.new(hash[:lifecycle])
    when "cancelled"
      Retab::CancelledTerminal.new(hash[:lifecycle])
    when "completed"
      Retab::CompletedTerminal.new(hash[:lifecycle])
    when "error"
      Retab::ErrorTerminal.new(hash[:lifecycle])
    when "pending"
      Retab::PendingRun.new(hash[:lifecycle])
    when "running"
      Retab::RunningRun.new(hash[:lifecycle])
    else
      hash[:lifecycle]
    end
  ) : nil
  @timing = hash[:timing] ? Retab::RunTiming.new(hash[:timing]) : nil
  @inputs = hash[:inputs] ? Retab::RunInputs.new(hash[:inputs]) : nil
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



17
18
19
# File 'lib/retab/workflow_runs/workflow_run.rb', line 17

def id
  @id
end

#inputsObject

Returns the value of attribute inputs.



17
18
19
# File 'lib/retab/workflow_runs/workflow_run.rb', line 17

def inputs
  @inputs
end

#lifecycleObject

Returns the value of attribute lifecycle.



17
18
19
# File 'lib/retab/workflow_runs/workflow_run.rb', line 17

def lifecycle
  @lifecycle
end

#timingObject

Returns the value of attribute timing.



17
18
19
# File 'lib/retab/workflow_runs/workflow_run.rb', line 17

def timing
  @timing
end

#triggerObject

Returns the value of attribute trigger.



17
18
19
# File 'lib/retab/workflow_runs/workflow_run.rb', line 17

def trigger
  @trigger
end

#workflowObject

Returns the value of attribute workflow.



17
18
19
# File 'lib/retab/workflow_runs/workflow_run.rb', line 17

def workflow
  @workflow
end