Sha256: 73e76bbe556d5b5ec2ec31a49e9025447a2298106c6cd2054039ecfb60addb68

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

require 'fog/core/collection'
require 'fog/azurerm/models/storage/container'

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

        def all(options = { :metadata => true })
          containers = []
          service.list_containers(options).each do |container|
            hash = Container.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.name == 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_container_metadata(name)
          service.get_container_metadata(name)
        end

        def set_container_metadata(name, metadata)
          service.set_container_metadata(name, metadata)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.6 lib/fog/azurerm/models/storage/containers.rb
fog-azure-rm-0.0.5 lib/fog/azurerm/models/storage/containers.rb
fog-azure-rm-0.0.4 lib/fog/azurerm/models/storage/containers.rb