lib/fog/aws/requests/data_pipeline/create_pipeline.rb in fog-aws-0.13.0 vs lib/fog/aws/requests/data_pipeline/create_pipeline.rb in fog-aws-1.0.0

- old
+ new

@@ -22,17 +22,38 @@ response = request({ :body => Fog::JSON.encode(params), :headers => { 'X-Amz-Target' => 'DataPipeline.CreatePipeline' }, }) - - Fog::JSON.decode(response.body) end end class Mock def create_pipeline(unique_id, name, description=nil, tags=nil) - Fog::Mock.not_implemented + 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