Class: AWS::SimpleWorkflow::HistoryEvent
- Inherits:
-
Object
- Object
- AWS::SimpleWorkflow::HistoryEvent
- Defined in:
- lib/aws/simple_workflow/history_event.rb
Overview
Getting History Events
History events belong to workflow executions. You can get them from an execution two ways:
1) By enumerating events from the execution
workflow_execution.events.each do |event|
# ...
end
2) By enumerating events from the context of a DecisionTask:
workflow_execution.decision_tasks.poll do |decision_task|
decision_task.events.each do |event|
end
end
History Event Attributes
All history events respond to the following 4 methods:
For a complete list of event types and a complete list of attributes returned with each event type, see the service API documentation.
Because the service returns attributes with camelCase name the structure returned by #attributes allows you to access attributes by their snake_case name or their camelCase name:
event.attributes.workflow_type
event.attributes['workflowType']
See Attributes for more information about working with the returned attributes.
Defined Under Namespace
Classes: Attributes
Instance Attribute Summary collapse
-
#attributes ⇒ Attributes
readonly
Returns an object that provides hash-like access to the history event attributes.
-
#created_at ⇒ Time
readonly
When the event history was created.
-
#event_id ⇒ Integer
(also: #id)
readonly
Returns the event id.
-
#event_type ⇒ String
readonly
Returns the name of the history event type.
-
#workflow_execution ⇒ WorkflowExecution
readonly
The workflow execution this history event belongs to.
Instance Method Summary collapse
-
#initialize(workflow_execution, details) ⇒ HistoryEvent
constructor
A new instance of HistoryEvent.
-
#to_h ⇒ Hash
Returns a hash representation of the event.
-
#to_json ⇒ String
Returns a JSON representation of this workflow execution.
Constructor Details
#initialize(workflow_execution, details) ⇒ HistoryEvent
Returns a new instance of HistoryEvent.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/aws/simple_workflow/history_event.rb', line 68 def initialize workflow_execution, details @workflow_execution = workflow_execution @details = details.is_a?(String) ? JSON.parse(details) : details @event_type = @details['eventType'] @event_id = @details['eventId'] @created_at = Time.at(@details['eventTimestamp']) attributes_key = "#{event_type}EventAttributes" attributes_key[0] = attributes_key[0,1].downcase attribute_data = @details[attributes_key] || {} @attributes = Attributes.new(workflow_execution, attribute_data) super end |
Instance Attribute Details
#attributes ⇒ Attributes (readonly)
Returns an object that provides hash-like access to the history event attributes.
101 102 103 |
# File 'lib/aws/simple_workflow/history_event.rb', line 101 def attributes @attributes end |
#created_at ⇒ Time (readonly)
Returns When the event history was created.
97 98 99 |
# File 'lib/aws/simple_workflow/history_event.rb', line 97 def created_at @created_at end |
#event_id ⇒ Integer (readonly) Also known as: id
Returns the event id.
93 94 95 |
# File 'lib/aws/simple_workflow/history_event.rb', line 93 def event_id @event_id end |
#event_type ⇒ String (readonly)
Returns the name of the history event type.
90 91 92 |
# File 'lib/aws/simple_workflow/history_event.rb', line 90 def event_type @event_type end |
#workflow_execution ⇒ WorkflowExecution (readonly)
Returns The workflow execution this history event belongs to.
87 88 89 |
# File 'lib/aws/simple_workflow/history_event.rb', line 87 def workflow_execution @workflow_execution end |
Instance Method Details
#to_h ⇒ Hash
Returns a hash representation of the event.
104 105 106 107 108 109 110 111 |
# File 'lib/aws/simple_workflow/history_event.rb', line 104 def to_h { :event_type => event_type, :event_id => event_id, :created_at => created_at, :attributes => attributes.to_h, } end |
#to_json ⇒ String
Returns a JSON representation of this workflow execution.
115 116 117 |
# File 'lib/aws/simple_workflow/history_event.rb', line 115 def to_json @details.to_json end |