1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
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(attr = {})
@files ||= begin
Fog::Storage::GoogleJSON::Files.new(
attr.merge(: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
|