class Fog::AWS::DataPipeline::Real

Attributes

region[R]

Public Class Methods

new(options={}) click to toggle source

Initialize connection to DataPipeline

Notes

options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection

Examples

datapipeline = DataPipeline.new(
 :aws_access_key_id => your_aws_access_key_id,
 :aws_secret_access_key => your_aws_secret_access_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

    • region<~String> - optional region to use. For instance, 'eu-west-1', 'us-east-1' and etc.

Returns

# File lib/fog/aws/data_pipeline.rb, line 51
def initialize(options={})
  @use_iam_profile = options[:use_iam_profile]
  @connection_options     = options[:connection_options] || {}

  @version    = '2012-10-29'
  @region     = options[:region]      || 'us-east-1'
  @host       = options[:host]        || "datapipeline.#{@region}.amazonaws.com"
  @path       = options[:path]        || '/'
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || 443
  @scheme     = options[:scheme]      || 'https'
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)

  setup_credentials(options)
end

Public Instance Methods

activate_pipeline(id) click to toggle source

Activate a pipeline docs.aws.amazon.com/datapipeline/latest/APIReference/API_ActivatePipeline.html

Parameters

  • PipelineId <~String> - The ID of the pipeline to activate

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/data_pipeline/activate_pipeline.rb, line 14
def activate_pipeline(id)
  params = { 'pipelineId' => id }

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

  Fog::JSON.decode(response.body)
end
create_pipeline(unique_id, name, description=nil) click to toggle source

Create a pipeline docs.aws.amazon.com/datapipeline/latest/APIReference/API_CreatePipeline.html

Parameters

  • UniqueId <~String> - A unique ID for of the pipeline

  • Name <~String> - The name of the pipeline

  • Description <~String> - Description of the pipeline

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/data_pipeline/create_pipeline.rb, line 16
def create_pipeline(unique_id, name, description=nil)
  params = {
    'uniqueId' => unique_id,
    'name' => name,
  }
  params['Description'] = description if description

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

  Fog::JSON.decode(response.body)
end
delete_pipeline(id) click to toggle source

Delete a pipeline docs.aws.amazon.com/datapipeline/latest/APIReference/API_DeletePipeline.html

Parameters

  • PipelineId <~String> - The id of the pipeline to delete

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/data_pipeline/delete_pipeline.rb, line 14
def delete_pipeline(id)
  params = { 'pipelineId' => id }

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

  Fog::JSON.decode(response.body)
end
describe_pipelines(ids) click to toggle source

Describe pipelines docs.aws.amazon.com/datapipeline/latest/APIReference/API_DescribePipelines.html

Parameters

  • PipelineIds <~String> - ID of pipeline to retrieve information for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/data_pipeline/describe_pipelines.rb, line 14
def describe_pipelines(ids)
  params = {}
  params['pipelineIds'] = ids

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

  Fog::JSON.decode(response.body)
end
list_pipelines(options={}) click to toggle source

List all pipelines docs.aws.amazon.com/datapipeline/latest/APIReference/API_ListPipelines.html

Parameters

  • Marker <~String> - The starting point for the results to be returned.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

# File lib/fog/aws/requests/data_pipeline/list_pipelines.rb, line 14
def list_pipelines(options={})
  params = {}
  params['Marker'] = options[:marker] if options[:marker]

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

  Fog::JSON.decode(response.body)
end
owner_id() click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 67
def owner_id
  @owner_id ||= security_groups.get('default').owner_id
end
put_pipeline_definition(id, objects) click to toggle source

Put raw pipeline definition JSON 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>:

# File lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb, line 15
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
reload() click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 71
def reload
  @connection.reset
end

Private Instance Methods

request(params) click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 86
def request(params)
  refresh_credentials_if_expired

  # Params for all DataPipeline requests
  params.merge!({
    :expects => 200,
    :host => @host,
    :method => :post,
    :path => '/',
  })

  date = Fog::Time.now
  params[:headers] = {
    'Date' => date.to_date_header,
    'Host' => @host,
    'X-Amz-Date' => date.to_iso8601_basic,
    'Content-Type' => 'application/x-amz-json-1.1',
    'Content-Length' => params[:body].bytesize.to_s,
  }.merge!(params[:headers] || {})
  params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
  params[:headers]['Authorization'] = @signer.sign(params, date)

  response = @connection.request(params)
  response
end
setup_credentials(options) click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 77
def setup_credentials(options)
  @aws_access_key_id      = options[:aws_access_key_id]
  @aws_secret_access_key  = options[:aws_secret_access_key]
  @aws_session_token     = options[:aws_session_token]
  @aws_credentials_expire_at = options[:aws_credentials_expire_at]

  @signer = Fog::AWS::SignatureV4.new(@aws_access_key_id, @aws_secret_access_key, @region, 'datapipeline')
end
transform_objects(objects) click to toggle source

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

# File lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb, line 32
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