Class: Fog::Storage::Rackspace::Directory
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::Rackspace::Directory
- Defined in:
- lib/fog/rackspace/models/storage/directory.rb
Instance Attribute Summary collapse
-
#bytes ⇒ Integer
readonly
The number of bytes used by the directory.
-
#cdn_name ⇒ String
The CDN CNAME to be used instead of the default CDN directory URI.
-
#count ⇒ Integer
readonly
The number of objects in the directory.
-
#key ⇒ String
readonly
The name of the directory.
-
#public ⇒ Object
writeonly
Required for compatibility with other Fog providers.
-
#public_url ⇒ String
Returns the public url for the directory.
Instance Method Summary collapse
-
#destroy ⇒ Boolean
Destroy the directory and remove it from CDN.
-
#files ⇒ Fog::Storage::Rackspace::Files
Returns collection of files in directory.
-
#ios_url ⇒ String
URL used to stream video to iOS devices.
-
#metadata ⇒ Fog::Storage::Rackspace::Metadata
Retrieve directory metadata.
-
#metadata=(hash) ⇒ Object
Set directory metadata.
-
#public? ⇒ Boolean
Is directory published to CDN.
-
#reload ⇒ Fog::Storage::Rackspace::Directory
Reload directory with latest data from Cloud Files.
-
#save ⇒ Boolean
Create or update directory and associated metadata.
-
#streaming_url ⇒ String
URL used to stream resources.
Instance Attribute Details
#bytes ⇒ Integer (readonly)
Returns The number of bytes used by the directory.
15 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 15 attribute :bytes, :aliases => 'X-Container-Bytes-Used', :type => :integer |
#cdn_name ⇒ String
This value does not persist and will need to be specified each time a directory is created or retrieved
Returns The CDN CNAME to be used instead of the default CDN directory URI. The CDN CNAME will need to be setup setup in DNS and point to the default CDN directory URI.
26 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 26 attribute :cdn_cname |
#count ⇒ Integer (readonly)
Returns The number of objects in the directory.
19 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 19 attribute :count, :aliases => 'X-Container-Object-Count', :type => :integer |
#key ⇒ String (readonly)
Returns The name of the directory.
11 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 11 identity :key, :aliases => 'name' |
#public=(value) ⇒ Object (writeonly)
Required for compatibility with other Fog providers. Not Used.
30 31 32 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 30 def public=(value) @public = value end |
#public_url ⇒ String
Returns the public url for the directory. If the directory has not been published to the CDN, this method will return nil as it is not publically accessible. This method will return the approprate url in the following order:
-
If the service used to access this directory was created with the option :rackspace_cdn_ssl => true, this method will return the SSL-secured URL.
-
If the cdn_cname attribute is populated this method will return the cname.
-
return the default CDN url.
128 129 130 131 132 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 128 def public_url return nil if urls.empty? return urls[:ssl_uri] if service.ssl? cdn_cname || urls[:uri] end |
Instance Method Details
#destroy ⇒ Boolean
Directory must be empty before it is destroyed.
Destroy the directory and remove it from CDN
65 66 67 68 69 70 71 72 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 65 def destroy requires :key service.delete_container(key) service.cdn.publish_container(self, false) if cdn_enabled? true rescue Excon::Errors::NotFound false end |
#files ⇒ Fog::Storage::Rackspace::Files
Returns collection of files in directory
80 81 82 83 84 85 86 87 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 80 def files @files ||= begin Fog::Storage::Rackspace::Files.new( :directory => self, :service => service ) end end |
#ios_url ⇒ String
URL used to stream video to iOS devices. Cloud Files will auto convert to the approprate format.
141 142 143 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 141 def ios_url urls[:ios_uri] end |
#metadata ⇒ Fog::Storage::Rackspace::Metadata
Retrieve directory metadata
49 50 51 52 53 54 55 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 49 def unless attributes[:metadata] response = service.head_container(key) attributes[:metadata] = Fog::Storage::Rackspace::Metadata.from_headers(self, response.headers) end attributes[:metadata] end |
#metadata=(hash) ⇒ Object
Set directory metadata
38 39 40 41 42 43 44 45 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 38 def (hash) if hash.is_a? Fog::Storage::Rackspace::Metadata attributes[:metadata] = hash else attributes[:metadata] = Fog::Storage::Rackspace::Metadata.new(self, hash) end attributes[:metadata] end |
#public? ⇒ Boolean
Is directory published to CDN
95 96 97 98 99 100 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 95 def public? if @public.nil? @public ||= (key && public_url) ? true : false end @public end |
#reload ⇒ Fog::Storage::Rackspace::Directory
Reload directory with latest data from Cloud Files
108 109 110 111 112 113 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 108 def reload @public = nil @urls = nil @files = nil super end |
#save ⇒ Boolean
If public attribute is true, directory will be CDN enabled
Create or update directory and associated metadata
164 165 166 167 168 169 170 171 172 173 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 164 def save requires :key create_or_update_container if cdn_enabled? @urls = service.cdn.publish_container(self, public?) else raise Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided") if public? end true end |
#streaming_url ⇒ String
URL used to stream resources
152 153 154 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 152 def streaming_url urls[:streaming_uri] end |