Class: Fog::Storage::OracleCloud::Mock
- Inherits:
-
Object
- Object
- Fog::Storage::OracleCloud::Mock
- Defined in:
- lib/fog/oraclecloud/storage.rb,
lib/fog/oraclecloud/requests/storage/get_container.rb,
lib/fog/oraclecloud/requests/storage/list_containers.rb,
lib/fog/oraclecloud/requests/storage/create_container.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_container(name) ⇒ Object
- #data ⇒ Object
- #get_container(name) ⇒ Object
- #get_container_with_objects(name) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_containers ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
76 77 78 79 80 81 |
# File 'lib/fog/oraclecloud/storage.rb', line 76 def initialize(={}) @username = [:oracle_username] @password = [:oracle_password] @identity_domain = [:oracle_domain] @api_endpoint = [:oracle_compute_api] end |
Class Method Details
.data ⇒ Object
83 84 85 86 87 |
# File 'lib/fog/oraclecloud/storage.rb', line 83 def self.data @data ||= { :containers => {} } end |
.reset ⇒ Object
89 90 91 |
# File 'lib/fog/oraclecloud/storage.rb', line 89 def self.reset @data = nil end |
Instance Method Details
#create_container(name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
93 94 95 |
# File 'lib/fog/oraclecloud/storage.rb', line 93 def data self.class.data end |
#get_container(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# 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 Fog::Compute::OracleCloud::NotFound.new("Storage Container #{name} does not exist"); end end |
#get_container_with_objects(name) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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 ⇒ Object
16 17 18 19 20 21 22 23 |
# 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 |