Sha256: 393f112aee88f6b0d91f8e8ffd260dde2b854f1a242d5f9b53254ee1b62eb85a

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

module Fog
  module Storage
    class GoogleJSON
      ##
      # Represents a Google Storage bucket
      class Directory < Fog::Model
        identity :key, :aliases => ["Name", "name", :name]

        attribute :acl
        attribute :billing
        attribute :cors
        attribute :default_object_acl, aliases => "defaultObjectAcl"
        attribute :etag
        attribute :id
        attribute :kind
        attribute :labels
        attribute :lifecycle
        attribute :location
        attribute :logging
        attribute :metageneration
        attribute :name
        attribute :owner
        attribute :project_number, aliases => "projectNumber"
        attribute :self_link, aliases => "selfLink"
        attribute :storage_class, aliases => "storageClass"
        attribute :time_created, aliases => "timeCreated"
        attribute :updated
        attribute :versioning
        attribute :website

        def destroy
          requires :key
          service.delete_bucket(key)
          true
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          false
        end

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

        def public_url
          requires :key
          "#{GOOGLE_STORAGE_BUCKET_BASE_URL}#{key}"
        end

        def save
          requires :key
          service.put_bucket(key, attributes)
          true
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-google-1.1.0 lib/fog/storage/google_json/models/directory.rb
fog-google-1.0.1 lib/fog/storage/google_json/models/directory.rb
fog-google-1.0.0 lib/fog/storage/google_json/models/directory.rb