class Fog::Storage::AzureRM::Directory
This class is giving implementation of create and delete a container.
Constants
- VALID_ACLS
Attributes
Public Instance Methods
Get the the permission
required attributes: key
@return [String] Permission.
# File lib/fog/azurerm/models/storage/directory.rb, line 49 def acl requires :key return attributes[:acl] if attributes[:acl] != 'unknown' || !persisted? data = service.get_container_acl(key) attributes[:acl] = data[0] end
Destroy directory.
required attributes: key
@return [Boolean] True if successful
# File lib/fog/azurerm/models/storage/directory.rb, line 64 def destroy requires :key service.delete_container(key) end
Get files under this directory. If you have set max_results or max_keys when getting this directory by directories.get, files may be incomplete. You need to use files.all to get all files under this directory.
@return [Fog::Storage::AzureRM::Files] Files
.
# File lib/fog/azurerm/models/storage/directory.rb, line 76 def files @files ||= Fog::Storage::AzureRM::Files.new(directory: self, service: service) end
Check whether the directory is created.
@return [Boolean] True if the file is created. Otherwise return false.
# File lib/fog/azurerm/models/storage/directory.rb, line 143 def persisted? # is_persisted is true in case of directories.get or after #save # last_modified is set in case of directories.all attributes[:is_persisted] || !attributes[:last_modified].nil? end
Set the container permission to public or private
@param [Boolean] True: public(container); False: private(nil)
@return [Boolean] True if public; Otherwise return false.
# File lib/fog/azurerm/models/storage/directory.rb, line 86 def public=(new_public) attributes[:acl] = new_public ? 'container' : nil new_public end
Get the public URL of the directory
required attributes: key
@param options [Hash] @option options [String] scheme Sets which URL to get, http or https. Options: https or http. Default is https.
@return [String] A public URL.
# File lib/fog/azurerm/models/storage/directory.rb, line 100 def public_url(options = {}) requires :key service.get_container_url(key, options) if acl == 'container' end
Create/Update the directory
required attributes: key
@param options [Hash] @option options [Boolean] is_create Sets whether to create or update the directory. Default is true(create).
Will update metadata and acl when is_create is set to false.
@return [Boolean] True if successful.
# File lib/fog/azurerm/models/storage/directory.rb, line 116 def save(options = {}) requires :key is_create = options.delete(:is_create) if is_create.nil? || is_create options = {} options[:public_access_level] = acl if acl != 'unknown' options[:metadata] = metadata if metadata container = service.create_container(key, options) else service.put_container_acl(key, acl) if acl != 'unknown' service.put_container_metadata(key, metadata) if metadata container = service.get_container_properties(key) end attributes[:is_persisted] = true data = parse_storage_object(container) merge_attributes(data) true end