File: pipeline.rb

package info (click to toggle)
ruby-fog-aws 3.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,816 kB
  • sloc: ruby: 68,587; makefile: 6
file content (61 lines) | stat: -rw-r--r-- 1,446 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
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
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
module Fog
  module AWS
    class DataPipeline
      class Pipeline < Fog::Model
        identity  :id, :aliases => 'pipelineId'
        attribute :name
        attribute :description
        attribute :tags
        attribute :user_id, :aliases => 'userId'
        attribute :account_id, :aliases => 'accountId'
        attribute :state, :aliases => 'pipelineState'
        attribute :unique_id, :aliases => 'uniqueId'

        def initialize(attributes={})
          # Extract the 'fields' portion of a response to attributes
          if attributes.include?('fields')
            string_fields = attributes['fields'].select { |f| f.include?('stringValue') }
            field_attributes = Hash[string_fields.map { |f| [f['key'][/^@(.+)$/, 1], f['stringValue']] }]
            merge_attributes(field_attributes)
          end

          super
        end

        def save
          requires :name
          requires :unique_id

          data = service.create_pipeline(unique_id, name, nil, tags)
          merge_attributes(data)

          true
        end

        def activate
          requires :id

          service.activate_pipeline(id)

          true
        end

        def put(objects)
          requires :id

          service.put_pipeline_definition(id, objects)

          true
        end

        def destroy
          requires :id

          service.delete_pipeline(id)

          true
        end
      end
    end
  end
end