Module: Aliyun::Oss::Api::BucketProperty

Included in:
Client
Defined in:
lib/aliyun/oss/api/bucket_property.rb

Instance Method Summary collapse

Instance Method Details

#bucket_disable_corsResponse

Used to disable cors and clear rules for bucket

Returns:

  • (Response)

Raises:

See Also:



167
168
169
170
# File 'lib/aliyun/oss/api/bucket_property.rb', line 167

def bucket_disable_cors
  query = { 'cors' => false }
  http.delete('/', query: query, bucket: bucket)
end

#bucket_disable_lifecycleObject

Used to disable lifecycle for bucket.



128
129
130
131
# File 'lib/aliyun/oss/api/bucket_property.rb', line 128

def bucket_disable_lifecycle
  query = { 'lifecycle' => false }
  http.delete('/', query: query, bucket: bucket)
end

#bucket_disable_loggingResponse

Used to disable access logging.

Returns:

  • (Response)

Raises:

See Also:



45
46
47
48
# File 'lib/aliyun/oss/api/bucket_property.rb', line 45

def bucket_disable_logging
  query = { 'logging' => false }
  http.delete('/', query: query, bucket: bucket)
end

#bucket_disable_websiteResponse

Used to disable website hostted mode.

Returns:

  • (Response)

Raises:

See Also:



75
76
77
78
# File 'lib/aliyun/oss/api/bucket_property.rb', line 75

def bucket_disable_website
  query = { 'website' => false }
  http.delete('/', query: query, bucket: bucket)
end

#bucket_enable_cors(rules = []) ⇒ Response

Used to enable CORS and set rules for bucket

Parameters:

Returns:

  • (Response)

Raises:

See Also:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/aliyun/oss/api/bucket_property.rb', line 144

def bucket_enable_cors(rules = [])
  query = { 'cors' => true }

  rules = Utils.wrap(rules)

  rules.each do |rule|
    unless rule.valid?
      fail Aliyun::Oss::InvalidCorsRuleError, rule.inspect
    end
  end

  body = XmlGenerator.generate_cors_rules(rules)

  http.put('/', query: query, body: body, bucket: bucket)
end

#bucket_enable_lifecycle(rules = []) ⇒ Response

Used to enable and set lifecycle for bucket

Parameters:

Returns:

  • (Response)

Raises:

See Also:



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/aliyun/oss/api/bucket_property.rb', line 109

def bucket_enable_lifecycle(rules = [])
  query = { 'lifecycle' => true }

  rules = Utils.wrap(rules)

  rules.each do |rule|
    unless rule.valid?
      fail Aliyun::Oss::InvalidLifeCycleRuleError, rule.inspect
    end
  end

  body = XmlGenerator.generate_lifecycle_rules(rules)

  http.put('/', query: query, body: body, bucket: bucket)
end

#bucket_enable_logging(target_bucket, target_prefix = nil) ⇒ Response

Used to enable access logging.

Parameters:

  • target_bucket (String)

    specifies the bucket where you want Aliyun OSS to store server access logs.

  • target_prefix (String) (defaults to: nil)

    this element lets you specify a prefix for the objects that the log files will be stored.

Returns:

  • (Response)

Raises:

See Also:



29
30
31
32
33
34
35
36
# File 'lib/aliyun/oss/api/bucket_property.rb', line 29

def bucket_enable_logging(target_bucket, target_prefix = nil)
  query = { 'logging' => true }

  body = XmlGenerator.generate_enable_logging_xml(target_bucket,
                                                  target_prefix)

  http.put('/', query: query, body: body, bucket: bucket)
end

#bucket_enable_website(suffix, key = nil) ⇒ Response

Used to enable static website hosted mode.

Parameters:

  • suffix (String)

    A suffix that is appended to a request that is for a directory on the website endpoint (e.g. if the suffix is index.html and you make a request to samplebucket/images/ the data that is returned will be for the object with the key name images/index.html) The suffix must not be empty and must not include a slash character.

  • key (String) (defaults to: nil)

    The object key name to use when a 4XX class error occurs

Returns:

  • (Response)

Raises:

See Also:



60
61
62
63
64
65
66
# File 'lib/aliyun/oss/api/bucket_property.rb', line 60

def bucket_enable_website(suffix, key = nil)
  query = { 'website' => true }

  body = XmlGenerator.generate_enable_website_xml(suffix, key)

  http.put('/', query: query, body: body, bucket: bucket)
end

#bucket_get_aclResponse

Get ACL for bucket

Returns:

  • (Response)

See Also:



177
178
179
180
# File 'lib/aliyun/oss/api/bucket_property.rb', line 177

def bucket_get_acl
  query = { 'acl' => true }
  http.get('/', query: query, bucket: bucket)
end

#bucket_get_corsResponse

Get the CORS rules of bucket

Returns:

  • (Response)

See Also:



239
240
241
242
# File 'lib/aliyun/oss/api/bucket_property.rb', line 239

def bucket_get_cors
  query = { 'cors' => true }
  http.get('/', query: query, bucket: bucket)
end

#bucket_get_lifecycleResponse

Get the lifecycle configuration of bucket

Returns:

  • (Response)

See Also:



229
230
231
232
# File 'lib/aliyun/oss/api/bucket_property.rb', line 229

def bucket_get_lifecycle
  query = { 'lifecycle' => true }
  http.get('/', query: query, bucket: bucket)
end

#bucket_get_locationResponse

Get the location information of the Bucket’s data center

Returns:

  • (Response)

See Also:



187
188
189
190
# File 'lib/aliyun/oss/api/bucket_property.rb', line 187

def bucket_get_location
  query = { 'location' => true }
  http.get('/', query: query, bucket: bucket)
end

#bucket_get_loggingResponse

Get the log configuration of Bucket

Returns:

  • (Response)

Raises:

See Also:



199
200
201
202
# File 'lib/aliyun/oss/api/bucket_property.rb', line 199

def bucket_get_logging
  query = { 'logging' => true }
  http.get('/', query: query, bucket: bucket)
end

#bucket_get_refererResponse

Get the referer configuration of bucket

Returns:

  • (Response)

See Also:



219
220
221
222
# File 'lib/aliyun/oss/api/bucket_property.rb', line 219

def bucket_get_referer
  query = { 'referer' => true }
  http.get('/', query: query, bucket: bucket)
end

#bucket_get_websiteResponse

Get the bucket state of static website hosting.

Returns:

  • (Response)

See Also:



209
210
211
212
# File 'lib/aliyun/oss/api/bucket_property.rb', line 209

def bucket_get_website
  query = { 'website' => true }
  http.get('/', query: query, bucket: bucket)
end

#bucket_set_acl(acl) ⇒ Response

Used to modify the bucket access.

Parameters:

  • acl (String)

    supported value: public-read-write | public-read | private

Returns:

  • (Response)

Raises:

See Also:



13
14
15
16
17
# File 'lib/aliyun/oss/api/bucket_property.rb', line 13

def bucket_set_acl(acl)
  query = { 'acl' => true }
  headers = { 'x-oss-acl' => acl }
  http.put('/', query: query, headers: headers, bucket: bucket)
end

#bucket_set_referer(referers = [], allowed_empty = false) ⇒ Response

Used to set referer for bucket.

Parameters:

  • referers (Array<String>) (defaults to: [])

    white list for allowed referer.

  • allowed_empty (Boolean) (defaults to: false)

    whether allow empty refer.

Returns:

  • (Response)

Raises:

See Also:



90
91
92
93
94
95
96
# File 'lib/aliyun/oss/api/bucket_property.rb', line 90

def bucket_set_referer(referers = [], allowed_empty = false)
  query = { 'referer' => true }

  body = XmlGenerator.generate_set_referer_xml(referers, allowed_empty)

  http.put('/', query: query, body: body, bucket: bucket)
end