Class: SwiftStorage::Container
- Defined in:
- lib/swift_storage/container.rb
Constant Summary
Constants included from Headers
Headers::ACCOUNT_TEMP_URL_KEY, Headers::AUTH_KEY, Headers::AUTH_TOKEN, Headers::AUTH_USER, Headers::CACHE_CONTROL, Headers::CONNECTION, Headers::CONTAINER_READ, Headers::CONTAINER_WRITE, Headers::CONTENT_DISPOSITION, Headers::CONTENT_TYPE, Headers::DELETE_AFTER, Headers::DELETE_AT, Headers::DESTINATION, Headers::EXPIRES, Headers::OBJECT_MANIFEST, Headers::PROXY_CONNECTION, Headers::STORAGE_TOKEN, Headers::STORAGE_URL
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#acl ⇒ Struct
Read the container meta data.
-
#create ⇒ Object
Create the container.
-
#objects ⇒ SwiftStorage::ObjectCollection
Returns the object collection for this container.
- #relative_path ⇒ Object
-
#write(write_acl: nil, read_acl: nil) ⇒ Object
Write the container meta data.
Methods inherited from Node
#clear_cache, #delete, #delete_if_exists, #exists?, #get_lines, #headers, #initialize, #metadata, #request, #service, #to_s
Methods included from Utils
Constructor Details
This class inherits a constructor from SwiftStorage::Node
Instance Method Details
#acl ⇒ Struct
Read the container meta data
54 55 56 57 58 |
# File 'lib/swift_storage/container.rb', line 54 def acl r = headers.read.split(',') rescue nil w = headers.write.split(',') rescue nil struct(:read => r, :write => w) end |
#create ⇒ Object
Create the container
20 21 22 |
# File 'lib/swift_storage/container.rb', line 20 def create request(relative_path, :method => :put) end |
#objects ⇒ SwiftStorage::ObjectCollection
Returns the object collection for this container
14 15 16 |
# File 'lib/swift_storage/container.rb', line 14 def objects @objects ||= SwiftStorage::ObjectCollection.new(self) end |
#relative_path ⇒ Object
5 6 7 |
# File 'lib/swift_storage/container.rb', line 5 def relative_path name end |
#write(write_acl: nil, read_acl: nil) ⇒ Object
This overrides all ACL set on the container.
Write the container meta data
Each ACL is a string in the following format:
team:jon
give access to user "jon" of account "team"
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/swift_storage/container.rb', line 38 def write(write_acl: nil, read_acl: nil) h = {} read_acl = read_acl.join(',') if read_acl.respond_to?(:to_ary) write_acl = write_acl.join(',') if write_acl.respond_to?(:to_ary) h[CONTAINER_READ] = read_acl h[CONTAINER_WRITE] = write_acl request(relative_path, :method => :post, :headers => h) end |