Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::SimpleWorkflow::HistoryEvent

Inherits:
Object
  • Object
show all
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:

  • By enumerating events from the execution

    workflow_execution.events.each do |event|
      # ...
    end
    
  • 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

Instance Method Summary collapse

Constructor Details

#initialize(workflow_execution, details) ⇒ HistoryEvent

Returns a new instance of HistoryEvent

Parameters:

  • workflow_execution (WorkflowExecution)
  • details (Hash, String)

    A hash or JSON string describing the history event.

[View source]

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

#attributesAttributes (readonly)

Returns an object that provides hash-like access to the history event attributes.

Returns:

  • (Attributes)

    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_atTime (readonly)

Returns When the event history was created.

Returns:

  • (Time)

    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_idInteger (readonly) Also known as: id

Returns the event id.

Returns:

  • (Integer)

    Returns the event id.


93
94
95
# File 'lib/aws/simple_workflow/history_event.rb', line 93

def event_id
  @event_id
end

#event_typeString (readonly)

Returns the name of the history event type.

Returns:

  • (String)

    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_executionWorkflowExecution (readonly)

Returns The workflow execution this history event belongs to.

Returns:


87
88
89
# File 'lib/aws/simple_workflow/history_event.rb', line 87

def workflow_execution
  @workflow_execution
end

Instance Method Details

#to_hHash

Returns a hash representation of the event.

Returns:

  • (Hash)

    Returns a hash representation of the event.

[View source]

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_jsonString

Returns a JSON representation of this workflow execution.

Returns:

  • (String)

    Returns a JSON representation of this workflow execution.

[View source]

115
116
117
# File 'lib/aws/simple_workflow/history_event.rb', line 115

def to_json
  @details.to_json
end