Class: Pipely::FogClient

Inherits:
Struct
  • Object
show all
Defined in:
lib/pipely/fog_client.rb

Overview

Uses Fog to communicate with the AWS Data Pipeline service

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pipeline_idObject

Returns the value of attribute pipeline_id

Returns:

  • (Object)

    the current value of pipeline_id



6
7
8
# File 'lib/pipely/fog_client.rb', line 6

def pipeline_id
  @pipeline_id
end

Instance Method Details

#definitionObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pipely/fog_client.rb', line 8

def definition
  objects = data_pipeline.get_pipeline_definition(pipeline_id)

  flattened_objects = []

  objects['pipelineObjects'].each do |object|
    h = {
      id: object['id'],
      name: object['name'],
    }

    object['fields'].each do |field|
      k = field['key']
      if field['refValue']
        h[k] ||= []
        h[k] << { ref: field['refValue'] }
      else
        h[k] = field['stringValue']
      end
    end

    flattened_objects << h
  end

  { objects: flattened_objects }.to_json
end

#task_states_by_scheduled_startObject



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
# File 'lib/pipely/fog_client.rb', line 35

def task_states_by_scheduled_start
  task_states_by_scheduled_start = {}

  all_instances.each do |pipeline_object|
    component_id = status = scheduled_start = nil

    pipeline_object['fields'].each do |field|
      case field['key']
      when '@componentParent'
        component_id = field['refValue']
      when '@status'
        status = field['stringValue']
      when '@scheduledStartTime'
        scheduled_start = field['stringValue']
      end
    end

    task_states_by_scheduled_start[scheduled_start] ||= {}
    task_states_by_scheduled_start[scheduled_start][component_id] = {
      execution_state: status
    }
  end

  task_states_by_scheduled_start
end