mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #1569 from rackspace/storage_account
[rackspace|storage] added account model
This commit is contained in:
commit
a33c664937
4 changed files with 66 additions and 0 deletions
24
lib/fog/rackspace/models/storage/account.rb
Normal file
24
lib/fog/rackspace/models/storage/account.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Storage
|
||||
class Rackspace
|
||||
class Account < Fog::Model
|
||||
attribute :meta_temp_url_key, :aliases => 'X-Account-Meta-Temp-Url-Key'
|
||||
attribute :container_count, :aliases => 'X-Account-Container-Count', :type => :integer
|
||||
attribute :bytes_used, :aliases => 'X-Account-Bytes-Used', :type => :integer
|
||||
attribute :object_count, :aliases => 'X-Account-Object-Count', :type => :integer
|
||||
|
||||
def save
|
||||
service.post_set_meta_temp_url_key meta_temp_url_key
|
||||
true
|
||||
end
|
||||
|
||||
def reload
|
||||
response = service.head_containers
|
||||
merge_attributes response.headers
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -14,6 +14,7 @@ module Fog
|
|||
collection :directories
|
||||
model :file
|
||||
collection :files
|
||||
model :account
|
||||
|
||||
request_path 'fog/rackspace/requests/storage'
|
||||
request :copy_object
|
||||
|
@ -99,6 +100,11 @@ module Fog
|
|||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
||||
end
|
||||
|
||||
def account
|
||||
account = Fog::Storage::Rackspace::Account.new(:service => self)
|
||||
account.reload
|
||||
end
|
||||
|
||||
def ssl?
|
||||
!rackspace_cdn_ssl.nil?
|
||||
end
|
||||
|
|
28
tests/rackspace/models/storage/account_tests.rb
Normal file
28
tests/rackspace/models/storage/account_tests.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
Shindo.tests('Fog::Rackspace::Storage | account', ['rackspace']) do
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
@account = Fog::Storage[:rackspace].account
|
||||
|
||||
tests('load') do
|
||||
headers = @account.service.head_containers.headers
|
||||
|
||||
returns(headers['X-Account-Meta-Temp-Url-Key']) { @account.meta_temp_url_key }
|
||||
returns(headers['X-Account-Container-Count'].to_i) { @account.container_count }
|
||||
returns(headers['X-Account-Bytes-Used'].to_i) { @account.bytes_used }
|
||||
returns(headers['X-Account-Object-Count'].to_i) { @account.object_count }
|
||||
end
|
||||
|
||||
tests('reload') do
|
||||
@account.reload
|
||||
end
|
||||
|
||||
tests('save') do
|
||||
key = "testing-update-#{Time.now.to_i}"
|
||||
@account.meta_temp_url_key = "testing-update-#{Time.now.to_i}"
|
||||
@account.save
|
||||
|
||||
headers = @account.service.head_containers.headers
|
||||
returns(key) { headers['X-Account-Meta-Temp-Url-Key'] }
|
||||
end
|
||||
end
|
8
tests/rackspace/storage_tests.rb
Normal file
8
tests/rackspace/storage_tests.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
Shindo.tests('Fog::Storage::Rackspace', ['rackspace']) do |variable|
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
tests('account').succeeds do
|
||||
Fog::Storage[:rackspace].account
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue