Class: Eso::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/eso/step.rb

Overview

Object representation of a step, which are attributes of Workflows and Integration Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid: nil, service_name:, workflow: nil, type_name:, previous_type_name: StepNames::EMPTY, configuration_params: nil) ⇒ Step

Constructor for Step.

Parameters:

  • uuid (String) (defaults to: nil)

    UUID of this Step. This is created on the server side upon creation through the API.

  • service_name (String)

    The name of step this is.

  • workflow (Workflow) (defaults to: nil)

    The workflow this step belongs to.

  • configuration_params (Hash) (defaults to: nil)

    Hash of the parameters for this step.



21
22
23
24
25
26
27
# File 'lib/eso/step.rb', line 21

def initialize(uuid: nil, service_name:, workflow: nil, type_name:, previous_type_name: StepNames::EMPTY, configuration_params: nil)
  @uuid = uuid if uuid
  @serviceName = service_name
  @stepConfiguration = StepConfiguration.new(type_name, previous_type_name)
  @stepConfiguration.configurationParams = configuration_params if configuration_params
  @stepConfiguration.workflowID = workflow.id if workflow
end

Instance Attribute Details

#serviceNameObject

Type of this step. Should be one of Eso::ServiceNames



9
10
11
# File 'lib/eso/step.rb', line 9

def serviceName
  @serviceName
end

#stepConfigurationObject

The configuration for this step.



12
13
14
# File 'lib/eso/step.rb', line 12

def stepConfiguration
  @stepConfiguration
end

#uuidObject

UUID of this step. This is generated on creation on the server.



6
7
8
# File 'lib/eso/step.rb', line 6

def uuid
  @uuid
end

Instance Method Details

#add_filter(filter) ⇒ Object

Add the specified filter to this step. The filter is converted to a hash and saved as such instead of being saved as a ESO::Filter object.

Parameters:

  • filter (Filter)

    The filter to add to this step.



140
141
142
# File 'lib/eso/step.rb', line 140

def add_filter(filter)
  @stepConfiguration.configurationParams[:properties].merge! filter.to_hash
end

#add_property(name, value) ⇒ Step

Convenience method which calls the #add_property method of the @stepConfiguration, but returns the Step

Returns:

  • (Step)

    Returns this Step for chaining



123
124
125
126
# File 'lib/eso/step.rb', line 123

def add_property(name, value)
  @stepConfiguration.add_property(name, value)
  self
end

#configuration_paramsHash

Return the configuration parameters for this step.

Returns:

  • (Hash)

    Hash of the configuration parameters for this step.



33
34
35
# File 'lib/eso/step.rb', line 33

def configuration_params
  @stepConfiguration.configurationParams
end

#configuration_params=(config_params) ⇒ Hash

Set the the configuration parameters for this step.

Parameters:

  • config_params (Hash)

    of the new configuration parameters you would like to set.

Returns:

  • (Hash)

    Hash of the updated configuration parameters for this step.



42
43
44
# File 'lib/eso/step.rb', line 42

def configuration_params=(config_params)
  @stepConfiguration.configurationParams = config_params
end

#filtersArray

Returns all configured filters for this step.

Returns:

  • (Array)

    An array of the currently configured filters for this step, each represented as a hash.



110
111
112
113
114
115
116
117
118
# File 'lib/eso/step.rb', line 110

def filters
  rv = {}
  self.properties.each_pair do |key, value|
    if value[:properties]
      rv[key] = value if value[:properties].has_key?(:operators)
    end
  end
  rv
end

#previous_type_nameString

Return the previous type name for this step.

Returns:

  • (String)

    The previous type name for this step.



67
68
69
# File 'lib/eso/step.rb', line 67

def previous_type_name
  @stepConfiguration.previousTypeName
end

#previous_type_name=(action_name) ⇒ String

Set the previous type name for this step.

Parameters:

  • The (String)

    new previous type name that you would like to set. See Eso::StepNames for valid names.

Returns:

  • (String)

    Hash of the configuration parameters for this step.



76
77
78
# File 'lib/eso/step.rb', line 76

def previous_type_name=(action_name)
  @stepConfiguration.previousTypeName = action_name
end

#propertiesHash{}

Return the properties of this step.

Returns:

  • (Hash{})

    Hash of the properties for this step.



84
85
86
# File 'lib/eso/step.rb', line 84

def properties
  @stepConfiguration.configurationParams[:properties]
end

#properties=(new_properties) ⇒ Hash

Set the properties of this step.

Parameters:

  • The (Hash)

    new properties to set for this step.

Returns:

  • (Hash)

    Hash of the newly configured properties for this step.



93
94
95
# File 'lib/eso/step.rb', line 93

def properties=(new_properties)
  @stepConfiguration.configurationParams[:properties] = new_properties
end

#site_idString|nil

Determine the siteID of this step, if it exists

Returns:

  • (String|nil)

    The String siteID value or nil if no siteID



100
101
102
103
104
# File 'lib/eso/step.rb', line 100

def site_id
  if @stepConfiguration.configurationParams[:properties][:siteID]
    @stepConfiguration.configurationParams[:properties][:siteID][:value]
  end
end

#to_hashHash

Return this step as a hash.

Returns:

  • (Hash)

    Hash interpretation of this step.



156
157
158
159
160
161
162
163
164
# File 'lib/eso/step.rb', line 156

def to_hash
  hash = {}
  instance_variables.each do |var|
    value = instance_variable_get(var)
    value = value.to_h if value.respond_to?('to_h')
    hash[var.to_s.delete('@')] = value
  end
  hash
end

#to_jsonString

Return this step in a JSON digestible format.

Returns:

  • (String)

    JSON interpretation of this step.



148
149
150
# File 'lib/eso/step.rb', line 148

def to_json
  self.to_hash.to_json
end

#type_nameString

Return the type name for this step.

Returns:

  • (String)

    The currently configured type name.



50
51
52
# File 'lib/eso/step.rb', line 50

def type_name
  @stepConfiguration.typeName
end

#type_name=(wf_action_name) ⇒ String

Set the type name for this step.

Parameters:

  • The (String)

    new type_name that you would like to set this to. See Eso::StepNames for valid names.

Returns:

  • (String)

    The newly set type name.



59
60
61
# File 'lib/eso/step.rb', line 59

def type_name=(wf_action_name)
  @stepConfiguration.typeName = wf_action_name
end

#update_property(name, value) ⇒ Step

Convenience method which calls the #add_property method of the @stepConfiguration, but returns the Step

Returns:

  • (Step)

    Returns this Step for chaining



131
132
133
134
# File 'lib/eso/step.rb', line 131

def update_property(name, value)
  @stepConfiguration.add_property(name, value)
  self
end