def tagged_resources(resources)
Array(resources).map do |resource_id|
if match = resource_id.match(/^(\w+)-[a-z0-9]{8}/i)
id = match.captures.first
else
raise(Fog::Service::NotFound.new("Unknown resource id #{resource_id}"))
end
if MOCKED_TAG_TYPES.has_key? id
type = MOCKED_TAG_TYPES[id]
else
raise(Fog::Service::NotFound.new("Mocking tags of resource #{resource_id} has not been implemented"))
end
case type
when 'image'
unless visible_images.has_key? resource_id
raise(Fog::Service::NotFound.new("Cannot tag #{resource_id}, the image does not exist"))
end
when 'vpc'
if self.data[:vpcs].select {|v| v['vpcId'] == resource_id }.empty?
raise(Fog::Service::NotFound.new("Cannot tag #{resource_id}, the vpc does not exist"))
end
when 'route_table'
unless self.data[:route_tables].detect { |r| r['routeTableId'] == resource_id }
raise(Fog::Service::NotFound.new("Cannot tag #{resource_id}, the route table does not exist"))
end
else
unless self.data["#{type}s""#{type}s"][resource_id]
raise(Fog::Service::NotFound.new("Cannot tag #{resource_id}, the #{type} does not exist"))
end
end
{ 'resourceId' => resource_id, 'resourceType' => type }
end
end