activate_pipeline(id)
click to toggle source
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
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
def data
self.class.data[@region][@aws_access_key_id]
end
deactivate_pipeline(id, cancel_active=true)
click to toggle source
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
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
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
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
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
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
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
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
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
def reset
self.class.reset
end
stringify_keys(object)
click to toggle source
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