class Fog::AWS::DataPipeline::Mock
Attributes
region[RW]
Public Class Methods
data()
click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 28 def self.data @data ||= Hash.new do |hash, region| hash[region] = Hash.new do |region_hash, key| region_hash[key] = { :pipelines => {}, :pipeline_definitions => {}, } end end end
new(options={})
click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 53 def initialize(options={}) @region = options[:region] || "us-east-1" @aws_access_key_id = options[:aws_access_key_id] @aws_secret_access_key = options[:aws_secret_access_key] end
reset()
click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 39 def self.reset @data = nil end
Public Instance Methods
activate_pipeline(id)
click to toggle source
# File lib/fog/aws/requests/data_pipeline/activate_pipeline.rb, line 23 def activate_pipeline(id) response = Excon::Response.new pipeline = find_pipeline(id) pipeline[:active] = true response.body = {} response end
create_pipeline(unique_id, name, description=nil, tags=nil)
click to toggle source
# File lib/fog/aws/requests/data_pipeline/create_pipeline.rb, line 31 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
data()
click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 43 def data self.class.data[@region][@aws_access_key_id] end
deactivate_pipeline(id, cancel_active=true)
click to toggle source
# File lib/fog/aws/requests/data_pipeline/deactivate_pipeline.rb, line 24 def deactivate_pipeline(id, cancel_active=true) response = Excon::Response.new pipeline = find_pipeline(id) pipeline[:active] = false response.body = {} response end
delete_pipeline(id)
click to toggle source
# File lib/fog/aws/requests/data_pipeline/delete_pipeline.rb, line 24 def delete_pipeline(id) response = Excon::Response.new pipeline = find_pipeline(id) pipeline[:deleted] = true true end
describe_objects(id, objects, options={})
click to toggle source
# File lib/fog/aws/requests/data_pipeline/describe_objects.rb, line 30 def describe_objects(id, objects, options={}) response = Excon::Response.new find_pipeline(id) pipeline_objects = self.data[:pipeline_definitions][id]["pipelineObjects"].select { |o| objects.include?(o["id"]) } response.body = { "hasMoreResults" => false, "marker" => options[:marker], "pipelineObjects" => [ { "fields" => pipeline_objects } ] } response end
describe_pipelines(ids)
click to toggle source
# File lib/fog/aws/requests/data_pipeline/describe_pipelines.rb, line 24 def describe_pipelines(ids) response = Excon::Response.new response.body = {"pipelineDescriptionList" => self.data[:pipelines].values.select { |p| !p[:deleted] && ids.include?(p["pipelineId"]) } } response end
find_pipeline(id)
click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 70 def find_pipeline(id) pipeline = self.data[:pipelines].values.detect { |p| p["pipelineId"] == id } if pipeline.nil? || pipeline[:deleted] raise Fog::AWS::DataPipeline::NotFound.new("Pipeline with id: #{id} does not exist") end pipeline end
get_pipeline_definition(id)
click to toggle source
# File lib/fog/aws/requests/data_pipeline/get_pipeline_definition.rb, line 25 def get_pipeline_definition(id) response = Excon::Response.new pipeline = find_pipeline(id) response.body = self.data[:pipeline_definitions][id] || {"pipelineObjects" => []} response end
list_pipelines(options={})
click to toggle source
# File lib/fog/aws/requests/data_pipeline/list_pipelines.rb, line 24 def list_pipelines(options={}) response = Excon::Response.new response.body = {"pipelineIdList" => self.data[:pipelines].values.map { |p| {"id" => p["pipelineId"], "name" => p["name"]} } } response end
put_pipeline_definition(id, pipeline_objects, _options={})
click to toggle source
# File lib/fog/aws/requests/data_pipeline/put_pipeline_definition.rb, line 73 def put_pipeline_definition(id, pipeline_objects, _options={}) response = Excon::Response.new options = _options.dup pipeline = find_pipeline(id) stringified_objects = if pipeline_objects.any? transform_objects(stringify_keys(pipeline_objects)) else options.each { |k,v| options[k] = transform_objects(stringify_keys(v)) } end if stringified_objects.is_a?(Array) stringified_objects = {"pipelineObjects" => stringified_objects} end self.data[:pipeline_definitions][id] = stringified_objects response.body = {"errored" => false, "validationErrors" => [], "validationWarnings" => []} response end
query_objects(id, sphere, options={})
click to toggle source
# File lib/fog/aws/requests/data_pipeline/query_objects.rb, line 30 def query_objects(id, sphere, options={}) response = Excon::Response.new find_pipeline(id) response.body = {"hasMoreResults" => false, "ids" => ["Default"]} response end
reset()
click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 47 def reset self.class.reset end
stringify_keys(object)
click to toggle source
# File lib/fog/aws/data_pipeline.rb, line 59 def stringify_keys(object) case object when Hash object.inject({}) { |h,(k,v)| h[k.to_s] = stringify_keys(v); h } when Array object.map { |v| stringify_keys(v) } else object end end