Sha256: c3ef4859bc90fca88c90c241701f16410967901dd4faaceb7d06dd3d9d7cf2b4

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

module Fog
  module Storage
    class AzureRM
      # This class is giving implementation of listing containers.
      class Directories < Fog::Collection
        model Directory

        def all(options = { metadata: true })
          containers = []
          service.list_containers(options).each do |container|
            hash = Directory.parse container
            hash['public_access_level'] = 'unknown'
            containers << hash
          end
          load containers
        end

        def get(identity)
          container = all(prefix: identity, metadata: true).find { |item| item.key == identity }
          return if container.nil?

          access_control_list = service.get_container_access_control_list(identity)[0]
          container.public_access_level = if access_control_list.is_a? Hash
                                            access_control_list['public_access_level']
                                          else
                                            access_control_list.public_access_level
                                          end
          container
        end

        def get_metadata(name, options = {})
          service.get_container_metadata(name, options)
        end

        def set_metadata(name, metadata, options = {})
          service.set_container_metadata(name, metadata, options)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.1.0 lib/fog/azurerm/models/storage/directories.rb