Sha256: c04c074f8b11cd67c079043fbf52cc2f48abac2dc6d71d8ae4e9f91415765473

Contents?: true

Size: 1.97 KB

Versions: 56

Compression:

Stored size: 1.97 KB

Contents

module Fog
  module AWS
    class DataPipeline

      class Real

        # Put raw pipeline definition JSON
        # http://docs.aws.amazon.com/datapipeline/latest/APIReference/API_PutPipelineDefinition.html
        # ==== Parameters
        # * PipelineId <~String> - The ID of the pipeline
        # * PipelineObjects <~String> - Objects in the pipeline
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        def put_pipeline_definition(id, objects)
          params = {
            'pipelineId' => id,
            'pipelineObjects' => transform_objects(objects),
          }

          response = request({
            :body => Fog::JSON.encode(params),
            :headers => { 'X-Amz-Target' => 'DataPipeline.PutPipelineDefinition' },
          })

          Fog::JSON.decode(response.body)
        end

        # Take a list of pipeline object hashes as specified in the Data Pipeline JSON format
        # and transform it into the format expected by the API
        private
        def transform_objects(objects)
          output = []

          objects.each do |object|
            new_object = {}
            new_object['id'] = object.delete('id')
            new_object['name'] = object.delete('name') || new_object['id']

            new_object['fields'] = []
            object.each do |key, value|
              if value.is_a?(Hash)
                new_object['fields'] << { 'key' => key, 'refValue' => value['ref'] }

              elsif value.is_a?(Array)
                value.each do |v|
                  new_object['fields'] << { 'key' => key, 'stringValue' => v }
                end

              else
                new_object['fields'] << { 'key' => key, 'stringValue' => value }

              end
            end

            output << new_object
          end

          output
        end

      end

      class Mock
        def put_pipeline_definition(id, objects)
          Fog::Mock.not_implemented
        end
      end

    end
  end
end

Version data entries

56 entries across 56 versions & 6 rubygems

Version Path
fog-maestrodev-1.19.0.20140212012611 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-1.19.0 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb