Class: 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.
Attributes inherited from Model
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.
Methods inherited from Model
#initialize, #inspect, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Attribute Details
#bytes ⇒ Integer (readonly)
Returns The number of bytes used by the directory.
17 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 17 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.
28 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 28 attribute :cdn_cname |
#count ⇒ Integer (readonly)
Returns The number of objects in the directory.
21 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 21 attribute :count, :aliases => 'X-Container-Object-Count', :type => :integer |
#key ⇒ String (readonly)
Returns The name of the directory.
13 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 13 identity :key, :aliases => 'name' |
#public=(value) ⇒ Object (writeonly)
Required for compatibility with other Fog providers. Not Used.
32 33 34 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 32 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.
130 131 132 133 134 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 130 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
67 68 69 70 71 72 73 74 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 67 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
82 83 84 85 86 87 88 89 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 82 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.
143 144 145 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 143 def ios_url urls[:ios_uri] end |
#metadata ⇒ Fog::Storage::Rackspace::Metadata
Retrieve directory metadata
51 52 53 54 55 56 57 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 51 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
40 41 42 43 44 45 46 47 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 40 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
97 98 99 100 101 102 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 97 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
110 111 112 113 114 115 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 110 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
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 166 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
154 155 156 |
# File 'lib/fog/rackspace/models/storage/directory.rb', line 154 def streaming_url urls[:streaming_uri] end |