Class: Aliyun::Oss::Struct::Bucket

Inherits:
Base
  • Object
show all
Defined in:
lib/aliyun/oss/struct/bucket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Aliyun::Oss::Struct::Base

Instance Attribute Details

#clientObject

reference to client



15
16
17
# File 'lib/aliyun/oss/struct/bucket.rb', line 15

def client
  @client
end

#creation_dateObject

Createion date of Bucket



12
13
14
# File 'lib/aliyun/oss/struct/bucket.rb', line 12

def creation_date
  @creation_date
end

#locationObject

Bucket Location



9
10
11
# File 'lib/aliyun/oss/struct/bucket.rb', line 9

def location
  @location
end

#nameObject

Bucket Name



6
7
8
# File 'lib/aliyun/oss/struct/bucket.rb', line 6

def name
  @name
end

Instance Method Details

#acl!String

Get the acl

Returns:

  • (String)

See Also:



64
65
66
67
68
# File 'lib/aliyun/oss/struct/bucket.rb', line 64

def acl!
  result = client.bucket_get_acl.parsed_response
  acl_keys = %w(AccessControlPolicy AccessControlList Grant)
  Utils.dig_value(result, *acl_keys)
end

#cors!Array<Aliyun::Oss::Struct::Cors>

Get the CORS



88
89
90
91
92
93
94
# File 'lib/aliyun/oss/struct/bucket.rb', line 88

def cors!
  result = client.bucket_get_cors.parsed_response
  cors_keys = %w(CORSConfiguration CORSRule)
  Utils.wrap(Utils.dig_value(result, *cors_keys)).map do |cors|
    Struct::Cors.new(cors)
  end
end

#disable_corstrue

Disable CORS for bucket

Returns:

  • (true)

See Also:



120
121
122
# File 'lib/aliyun/oss/struct/bucket.rb', line 120

def disable_cors
  !!client.bucket_disable_cors
end

#disable_lifecycletrue

Used to disable lifecycle for bucket

Returns:

  • (true)

See Also:



230
231
232
# File 'lib/aliyun/oss/struct/bucket.rb', line 230

def disable_lifecycle
  !!client.bucket_disable_lifecycle
end

#disable_loggingtrue

Used to disable access logging.

Returns:

  • (true)

See Also:



55
56
57
# File 'lib/aliyun/oss/struct/bucket.rb', line 55

def disable_logging
  !!client.bucket_disable_logging
end

#disable_websiteResponse

Used to disable website hostted mode.

Returns:

  • (Response)

See Also:



163
164
165
# File 'lib/aliyun/oss/struct/bucket.rb', line 163

def disable_website
  !!client.bucket_disable_website
end

#enable_cors(*args) ⇒ true

Set CORS for bucket

Returns:

  • (true)

See Also:



107
108
109
# File 'lib/aliyun/oss/struct/bucket.rb', line 107

def enable_cors(*args)
  !!client.bucket_enable_cors(*args)
end

#enable_lifecycle(*args) ⇒ true

Used to enable and set lifecycle for bucket

Returns:

  • (true)

See Also:



219
220
221
# File 'lib/aliyun/oss/struct/bucket.rb', line 219

def enable_lifecycle(*args)
  !!client.bucket_enable_lifecycle(*args)
end

#enable_logging(*args) ⇒ true

Used to enable access logging.

Returns:

  • (true)

See Also:



44
45
46
# File 'lib/aliyun/oss/struct/bucket.rb', line 44

def enable_logging(*args)
  !!client.bucket_enable_logging(*args)
end

#enable_website(*args) ⇒ true

Used to enable static website hosted mode.

Returns:

  • (true)

See Also:



150
151
152
# File 'lib/aliyun/oss/struct/bucket.rb', line 150

def enable_website(*args)
  !!client.bucket_enable_website(*args)
end

#lifecycle!Array<Aliyun::Oss::Struct::Lifecycle?]

Get the lifecycle configuration

Returns:

  • (Array<Aliyun::Oss::Struct::Lifecycle?])

    Array<Aliyun::Oss::Struct::Lifecycle?]

See Also:



202
203
204
205
206
207
208
# File 'lib/aliyun/oss/struct/bucket.rb', line 202

def lifecycle!
  result = client.bucket_get_lifecycle.parsed_response
  lifecycle_keys = %w(LifecycleConfiguration Rule)
  Utils.wrap(Utils.dig_value(result, *lifecycle_keys)).map do |lifecycle|
    Struct::LifeCycle.new(lifecycle)
  end
end

#location!String

Get the location

Returns:

  • (String)

See Also:



22
23
24
25
# File 'lib/aliyun/oss/struct/bucket.rb', line 22

def location!
  result = client.bucket_get_location.parsed_response
  Utils.dig_value(result, 'LocationConstraint', '__content__')
end

#logging!Object

Get Logging configration for bucket

return [true]



32
33
34
35
# File 'lib/aliyun/oss/struct/bucket.rb', line 32

def logging!
  result = client.bucket_get_logging.parsed_response
  Struct::Logging.new(Utils.dig_value(result, 'BucketLoggingStatus'))
end

#preflight(*args) ⇒ true Also known as: options

OPTIONS Object

Returns:

  • (true)

See Also:



245
246
247
# File 'lib/aliyun/oss/struct/bucket.rb', line 245

def preflight(*args)
  !!client.bucket_preflight(*args)
end

#referer!Aliyun::Oss::Struct::Referer

Get the referer configuration



172
173
174
175
176
177
178
179
180
# File 'lib/aliyun/oss/struct/bucket.rb', line 172

def referer!
  result = client.bucket_get_referer.parsed_response
  allow_empty = %w(RefererConfiguration AllowEmptyReferer)
  referers = %w(RefererConfiguration RefererList Referer)
  Aliyun::Oss::Struct::Referer.new(
    allow_empty: Utils.dig_value(result, *allow_empty),
    referers: Utils.dig_value(result, *referers)
  )
end

#set_acl(*args) ⇒ true

Set ACL for bucket

Returns:

  • (true)

See Also:



79
80
81
# File 'lib/aliyun/oss/struct/bucket.rb', line 79

def set_acl(*args)
  !!client.bucket_set_acl(*args)
end

#set_referer(*args) ⇒ true

Used to set referer for bucket.

Returns:

  • (true)

See Also:

  • Client#set_referer


193
194
195
# File 'lib/aliyun/oss/struct/bucket.rb', line 193

def set_referer(*args)
  !!client.bucket_set_referer(*args)
end

#website!Aliyun::Oss::Rule::Website

Get the website configuration

Returns:

  • (Aliyun::Oss::Rule::Website)

See Also:



129
130
131
132
133
134
135
136
137
# File 'lib/aliyun/oss/struct/bucket.rb', line 129

def website!
  result = client.bucket_get_website.parsed_response
  suffix_keys = %w(WebsiteConfiguration IndexDocument Suffix)
  error_keys = %w(WebsiteConfiguration ErrorDocument Key)
  Aliyun::Oss::Struct::Website.new(
    suffix: Utils.dig_value(result, *suffix_keys),
    error_key: Utils.dig_value(result, *error_keys)
  )
end