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
|
module Fog
module AWS
class DataPipeline
class Real
# Create a pipeline
# http://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
# * Tags <~Hash> - Key/value string pairs to categorize the pipeline
# * Description <~String> - Description of the pipeline
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
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
end
class Mock
def create_pipeline(unique_id, name, description=nil, tags=nil)
response = Excon::Response.new
if existing_pipeline = self.data[:pipelines][unique_id]
{"pipelineId" => existing_pipeline["pipelineId"]}
else
pipeline_id = Fog::AWS::Mock.data_pipeline_id
mapped_tags = if tags
tags.map { |k,v| {"key" => k.to_s, "value" => v.to_s}}
else
[]
end
pipeline = {
"name" => name,
"description" => description,
"fields" => mapped_tags,
"pipelineId" => pipeline_id,
}
self.data[:pipelines][unique_id] = pipeline
response.body = {"pipelineId" => pipeline_id}
end
response
end
end
end
end
end
|