Class: Fog::Storage::AWS::Directory
- Inherits:
-
Model
- Object
- Model
- Fog::Storage::AWS::Directory
show all
- Defined in:
- lib/fog/aws/models/storage/directory.rb
Constant Summary
collapse
- VALID_ACLS =
['private', 'public-read', 'public-read-write', 'authenticated-read']
Instance Attribute Summary collapse
Attributes inherited from Model
#collection, #service
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#connection, #connection=, #prepare_service_value
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Attribute Details
#acl ⇒ Object
Returns the value of attribute acl.
12
13
14
|
# File 'lib/fog/aws/models/storage/directory.rb', line 12
def acl
@acl
end
|
Instance Method Details
#destroy ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/fog/aws/models/storage/directory.rb', line 27
def destroy
requires :key
service.delete_bucket(key)
true
rescue Excon::Errors::NotFound
false
end
|
#files ⇒ Object
44
45
46
|
# File 'lib/fog/aws/models/storage/directory.rb', line 44
def files
@files ||= Fog::Storage::AWS::Files.new(:directory => self, :service => service)
end
|
#location ⇒ Object
35
36
37
|
# File 'lib/fog/aws/models/storage/directory.rb', line 35
def location
@location ||= (bucket_location || self.service.region)
end
|
#location=(new_location) ⇒ Object
NOTE: you can’t change the region once the bucket is created
40
41
42
|
# File 'lib/fog/aws/models/storage/directory.rb', line 40
def location=(new_location)
@location = new_location
end
|
#payer ⇒ Object
48
49
50
51
52
|
# File 'lib/fog/aws/models/storage/directory.rb', line 48
def payer
requires :key
data = service.get_request_payment(key)
data.body['Payer']
end
|
#payer=(new_payer) ⇒ Object
54
55
56
57
58
|
# File 'lib/fog/aws/models/storage/directory.rb', line 54
def payer=(new_payer)
requires :key
service.put_request_payment(key, new_payer)
@payer = new_payer
end
|
#persisted? ⇒ Boolean
110
111
112
113
114
|
# File 'lib/fog/aws/models/storage/directory.rb', line 110
def persisted?
attributes[:is_persisted] || !!attributes[:creation_date]
end
|
#public=(new_public) ⇒ Object
75
76
77
78
|
# File 'lib/fog/aws/models/storage/directory.rb', line 75
def public=(new_public)
self.acl = new_public ? 'public-read' : 'private'
new_public
end
|
#public_url ⇒ Object
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/fog/aws/models/storage/directory.rb', line 80
def public_url
requires :key
if service.get_bucket_acl(key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
service.request_url(
:bucket_name => key
)
else
nil
end
end
|
#save ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/fog/aws/models/storage/directory.rb', line 91
def save
requires :key
options = {}
options['x-amz-acl'] = acl if acl
if !persisted? && location != DEFAULT_REGION
options['LocationConstraint'] = location
end
service.put_bucket(key, options)
attributes[:is_persisted] = true
true
end
|
#versioning=(new_versioning) ⇒ Object
66
67
68
69
|
# File 'lib/fog/aws/models/storage/directory.rb', line 66
def versioning=(new_versioning)
requires :key
service.put_bucket_versioning(key, new_versioning ? 'Enabled' : 'Suspended')
end
|
#versioning? ⇒ Boolean
60
61
62
63
64
|
# File 'lib/fog/aws/models/storage/directory.rb', line 60
def versioning?
requires :key
data = service.get_bucket_versioning(key)
data.body['VersioningConfiguration']['Status'] == 'Enabled'
end
|
#versions ⇒ Object
71
72
73
|
# File 'lib/fog/aws/models/storage/directory.rb', line 71
def versions
@versions ||= Fog::Storage::AWS::Versions.new(:directory => self, :service => service)
end
|