Initialize connection to DataPipeline
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
datapipeline = DataPipeline.new( :aws_access_key_id => your_aws_access_key_id, :aws_secret_access_key => your_aws_secret_access_key )
options<~Hash> - config arguments for connection. Defaults to {}.
region<~String> - optional region to use. For instance, 'eu-west-1', 'us-east-1' and etc.
DataPipeline object with connection to AWS.
# File lib/fog/aws/data_pipeline.rb, line 103 def initialize(options={}) @use_iam_profile = options[:use_iam_profile] @instrumentor = options[:instrumentor] @instrumentor_name = options[:instrumentor_name] || 'fog.aws.data_pipeline' @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::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) setup_credentials(options) end
Activate a pipeline docs.aws.amazon.com/datapipeline/latest/APIReference/API_ActivatePipeline.html
PipelineId <~String> - The ID of the pipeline to activate
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/activate_pipeline.rb, line 12 def activate_pipeline(id) params = { 'pipelineId' => id } response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.ActivatePipeline' } }) end
Create a pipeline docs.aws.amazon.com/datapipeline/latest/APIReference/API_CreatePipeline.html
UniqueId <~String> - A unique ID for of the pipeline
Name <~String> - The name of the pipeline
Tags <~Hash> - Key/value string pairs to categorize the pipeline
Description <~String> - Description of the pipeline
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/create_pipeline.rb, line 15 def create_pipeline(unique_id, name, description=nil, tags=nil) params = { 'uniqueId' => unique_id, 'name' => name, } params['tags'] = tags.map {|k,v| {"key" => k.to_s, "value" => v.to_s}} unless tags.nil? || tags.empty? params['Description'] = description if description response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.CreatePipeline' }, }) end
Activate a pipeline docs.aws.amazon.com/datapipeline/latest/APIReference/API_DectivatePipeline.html
PipelineId <~String> - The ID of the pipeline to activate
' cancelActive <~Boolean> - Indicates whether to cancel any running objects. The default is true, which sets the state of any running objects to CANCELED. If this value is false, the pipeline is deactivated after all running objects finish.
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/deactivate_pipeline.rb, line 13 def deactivate_pipeline(id, cancel_active=true) params = { 'pipelineId' => id, 'cancelActive' => cancel_active } response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.DectivatePipeline' } }) end
Delete a pipeline docs.aws.amazon.com/datapipeline/latest/APIReference/API_DeletePipeline.html
PipelineId <~String> - The id of the pipeline to delete
success<~Boolean> - Whether the delete was successful
# File lib/fog/aws/requests/data_pipeline/delete_pipeline.rb, line 11 def delete_pipeline(id) params = { 'pipelineId' => id } response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.DeletePipeline' }, }) 200 == response.status end
Queries a pipeline for the names of objects that match a specified set of conditions. docs.aws.amazon.com/datapipeline/latest/APIReference/API_DescribeObjects.html
PipelineId <~String> - The ID of the pipeline
ObjectIds <~Array> - Identifiers of the pipeline objects that contain the definitions
to be described. You can pass as many as 25 identifiers in a single call to DescribeObjects.
Options <~Hash> - A Hash of additional options desrcibed in the API docs.
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/describe_objects.rb, line 16 def describe_objects(id, objectIds, options={}) params = options.merge({ 'pipelineId' => id, 'objectIds' => objectIds, }) response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.DescribeObjects' }, }) end
Describe pipelines docs.aws.amazon.com/datapipeline/latest/APIReference/API_DescribePipelines.html
PipelineIds <~String> - ID of pipeline to retrieve information for
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/describe_pipelines.rb, line 12 def describe_pipelines(ids) params = {} params['pipelineIds'] = ids response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.DescribePipelines' }, }) end
Get pipeline definition JSON docs.aws.amazon.com/datapipeline/latest/APIReference/API_GetPipelineDefinition.html
PipelineId <~String> - The ID of the pipeline
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/get_pipeline_definition.rb, line 12 def get_pipeline_definition(id) params = { 'pipelineId' => id, } response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.GetPipelineDefinition' }, }) end
List all pipelines docs.aws.amazon.com/datapipeline/latest/APIReference/API_ListPipelines.html
Marker <~String> - The starting point for the results to be returned.
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/list_pipelines.rb, line 12 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' }, }) end
# File lib/fog/aws/data_pipeline.rb, line 120 def owner_id @owner_id ||= security_groups.get('default').owner_id end
Put raw pipeline definition JSON docs.aws.amazon.com/datapipeline/latest/APIReference/API_PutPipelineDefinition.html
PipelineId <~String> - The ID of the pipeline
PipelineObjects <~String> - Objects in the pipeline
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb, line 57 def put_pipeline_definition(id, pipeline_objects, options={}) params = { 'pipelineId' => id, 'pipelineObjects' => transform_objects(pipeline_objects), }.merge(options) response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.PutPipelineDefinition' }, }) end
Queries a pipeline for the names of objects that match a specified set of conditions. docs.aws.amazon.com/datapipeline/latest/APIReference/API_QueryObjects.html
PipelineId <~String> - The ID of the pipeline
Sphere <~String> - Specifies whether the query applies to components or instances.
Allowable values: COMPONENT, INSTANCE, ATTEMPT.
Marker <~String> - The starting point for the results to be returned.
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/aws/requests/data_pipeline/query_objects.rb, line 15 def query_objects(id, sphere, options={}) params = { 'pipelineId' => id, 'sphere' => sphere, } params['marker'] = options[:marker] if options[:marker] response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.QueryObjects' }, }) end
# File lib/fog/aws/data_pipeline.rb, line 124 def reload @connection.reset end
# File lib/fog/aws/data_pipeline.rb, line 169 def _request(params) response = @connection.request(params) unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response rescue Excon::Error::BadRequest => error match = Fog::AWS::Errors.match_error(error) raise if match.empty? if %w(PipelineNotFoundException PipelineDeletedException).include?(match[:code]) raise Fog::AWS::DataPipeline::NotFound.slurp(error, match[:message]) end end
# File lib/fog/aws/data_pipeline.rb, line 139 def request(params) refresh_credentials_if_expired # Params for all DataPipeline requests params.merge!({ :expects => 200, :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) if @instrumentor @instrumentor.instrument("#{@instrumentor_name}.request", params) do _request(params) end else _request(params) end end
# File lib/fog/aws/data_pipeline.rb, line 130 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