Sha256: aa06a6cc081185dc06c948cae71ed2860d5b25ab98d16c102dc0d1a232520ad4

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

require 'fog/huaweicloud/models/model'
require 'fog/storage/huaweicloud/models/files'

module Fog
  module Storage
    class HuaweiCloud
      class Directory < Fog::HuaweiCloud::Model
        identity  :key, :aliases => 'name'

        attribute :bytes, :aliases => 'X-Container-Bytes-Used'
        attribute :count, :aliases => 'X-Container-Object-Count'

        attr_writer :public

        def destroy
          requires :key
          service.delete_container(key)
          true
        rescue Excon::Errors::NotFound
          false
        end

        def files
          @files ||= begin
            Fog::Storage::HuaweiCloud::Files.new(
              :directory => self,
              :service   => service
            )
          end
        end

        def public_url
          requires :key

          @public_url ||= begin
            service.public_url(key)
          rescue Fog::Storage::HuaweiCloud::NotFound => err
            nil
          end
        end

        def save
          requires :key
          service.put_container(key, :public => @public)
          true
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/storage/huaweicloud/models/directory.rb
fog-huaweicloud-0.0.2 lib/fog/storage/huaweicloud/models/directory.rb
fog-huaweicloud-0.1.3 lib/fog/storage/huaweicloud/models/directory.rb
fog-huaweicloud-0.1.2 lib/fog/storage/huaweicloud/models/directory.rb