class Fog::Storage::OracleCloud::Mock

Public Class Methods

data() click to toggle source
# File lib/fog/oraclecloud/storage.rb, line 83
def self.data 
  @data ||= {
    :containers => {}
  }
end
new(options={}) click to toggle source
# File lib/fog/oraclecloud/storage.rb, line 76
def initialize(options={})
  @username = options[:oracle_username]
  @password = options[:oracle_password]
  @identity_domain   = options[:oracle_domain]
  @api_endpoint   = options[:oracle_compute_api]
end
reset() click to toggle source
# File lib/fog/oraclecloud/storage.rb, line 89
def self.reset
  @data = nil
end

Public Instance Methods

create_container(name) click to toggle source
# File lib/fog/oraclecloud/requests/storage/create_container.rb, line 19
def create_container (name)
  response = Excon::Response.new

  self.data[:containers][name] = {
    'name' => name,
    'count' => 0,
    'bytes' => 0
  }
  response.status = 201
  response.headers = {
    'Content-Length' => 0,
    'X-Container-Bytes-Used' => 0,
    'X-Container-Object-Count' => 0,
    'Date'=>Time.now.strftime('%Y-%m-%dT%H:%M:%S'),
    'X-Timestamp'=>Time.now.to_i,
    'X-Trans-id'=>SecureRandom.uuid
  }
  response
end
data() click to toggle source
# File lib/fog/oraclecloud/storage.rb, line 93
def data 
  self.class.data
end
get_container(name) click to toggle source
# File lib/fog/oraclecloud/requests/storage/get_container.rb, line 24
def get_container(name)
  response = Excon::Response.new

  if container = self.data[:containers][name] 
    response.status = 200
    response.body = container
    response
  else;
    raise Excon::Error::NotFound.new("Storage Container #{name} does not exist");
  end
end
get_container_with_objects(name) click to toggle source
# File lib/fog/oraclecloud/requests/storage/get_container.rb, line 36
def get_container_with_objects(name)
  response = Excon::Response.new

  if container = self.data[:containers][name] 
    response.status = 200
    response.body = [{
      "hash": "aea0077f346227c91cd68e955721e262",
      "last_modified": "2016-07-30T03:39:24.477480",
      "bytes": 513,
      "name": "Ausemon/1df0886e-3133-498f-9472-79632485b311/logs/web.1/36322757-7666-429a-87cc-3c320caf8afa/server.out.zip",
      "content_type": "application/zip"
    },
    {
      "hash": "2c35a8adaf8e7a3375e1354264135f94",
      "last_modified": "2016-07-30T12:51:26.124600",
      "bytes": 6524,
      "name": "Ausemon/1df0886e-3133-498f-9472-79632485b311/logs/web.1/6ad56533-791f-4a79-8e5d-bbef854a2b50/server.out.zip",
      "content_type": "application/zip"
    }]
    response
  else;
    raise Fog::Compute::OracleCloud::NotFound.new("Storage Container #{name} does not exist");
  end 
end
list_containers() click to toggle source
# File lib/fog/oraclecloud/requests/storage/list_containers.rb, line 16
def list_containers
  response = Excon::Response.new

  containers = self.data[:containers].values

  response.body = containers
  response
end