Class: Fog::Storage::AzureRM::Directory
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::AzureRM::Directory
- Defined in:
- lib/fog/azurerm/models/storage/directory.rb
Overview
This class is giving implementation of create and delete a container.
Constant Summary collapse
- VALID_ACLS =
['container', 'blob', 'unknown', nil].freeze
Instance Attribute Summary collapse
-
#acl ⇒ String
Get the the permission.
Instance Method Summary collapse
-
#destroy ⇒ Boolean
Destroy directory.
-
#files ⇒ Fog::Storage::AzureRM::Files
Get files under this directory.
-
#persisted? ⇒ Boolean
Check whether the directory is created.
-
#public=(new_public) ⇒ Boolean
Set the container permission to public or private.
-
#public_url(options = {}) ⇒ String
Get the public URL of the directory.
-
#save(options = {}) ⇒ Boolean
Create/Update the directory.
Instance Attribute Details
#acl ⇒ String
Get the the permission
required attributes: key
49 50 51 52 53 54 55 56 |
# 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 |
Instance Method Details
#destroy ⇒ Boolean
Destroy directory.
required attributes: key
64 65 66 67 68 |
# File 'lib/fog/azurerm/models/storage/directory.rb', line 64 def destroy requires :key service.delete_container(key) end |
#files ⇒ Fog::Storage::AzureRM::Files
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.
76 77 78 |
# File 'lib/fog/azurerm/models/storage/directory.rb', line 76 def files @files ||= Fog::Storage::AzureRM::Files.new(directory: self, service: service) end |
#persisted? ⇒ Boolean
Check whether the directory is created.
143 144 145 146 147 |
# 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 |
#public=(new_public) ⇒ Boolean
Set the container permission to public or private
86 87 88 89 |
# File 'lib/fog/azurerm/models/storage/directory.rb', line 86 def public=(new_public) attributes[:acl] = new_public ? 'container' : nil new_public end |
#public_url(options = {}) ⇒ String
Get the public URL of the directory
required attributes: key
100 101 102 103 104 |
# File 'lib/fog/azurerm/models/storage/directory.rb', line 100 def public_url( = {}) requires :key service.get_container_url(key, ) if acl == 'container' end |
#save(options = {}) ⇒ Boolean
Create/Update the directory
required attributes: key
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/fog/azurerm/models/storage/directory.rb', line 116 def save( = {}) requires :key is_create = .delete(:is_create) if is_create.nil? || is_create = {} [:public_access_level] = acl if acl != 'unknown' [:metadata] = if container = service.create_container(key, ) else service.put_container_acl(key, acl) if acl != 'unknown' service.(key, ) if container = service.get_container_properties(key) end attributes[:is_persisted] = true data = parse_storage_object(container) merge_attributes(data) true end |