Class: Aliyun::Oss::Struct::Bucket
- Defined in:
- lib/aliyun/oss/struct/bucket.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
reference to client.
-
#creation_date ⇒ Object
Createion date of Bucket.
-
#location ⇒ Object
Bucket Location.
-
#name ⇒ Object
Bucket Name.
Instance Method Summary collapse
-
#acl! ⇒ String
Get the acl.
-
#cors! ⇒ Array<Aliyun::Oss::Struct::Cors>
Get the CORS.
-
#disable_cors ⇒ true
Disable CORS for bucket.
-
#disable_lifecycle ⇒ true
Used to disable lifecycle for bucket.
-
#disable_logging ⇒ true
Used to disable access logging.
-
#disable_website ⇒ true
Used to disable website hostted mode.
-
#enable_cors(*args) ⇒ true
Set CORS for bucket.
-
#enable_lifecycle(*args) ⇒ true
Used to enable and set lifecycle for bucket.
-
#enable_logging(*args) ⇒ true
Used to enable access logging.
-
#enable_website(*args) ⇒ true
Used to enable static website hosted mode.
- #host ⇒ Object
-
#lifecycle! ⇒ Array<Aliyun::Oss::Struct::Lifecycle?]
Get the lifecycle configuration.
-
#location! ⇒ String
Get the location.
-
#logging! ⇒ Object
Get Logging configration for bucket.
-
#preflight(*args) ⇒ true
(also: #options)
OPTIONS Object.
-
#referer! ⇒ Aliyun::Oss::Struct::Referer
Get the referer configuration.
-
#set_acl(*args) ⇒ true
Set ACL for bucket.
-
#set_referer(*args) ⇒ true
Used to set referer for bucket.
-
#website! ⇒ Aliyun::Oss::Rule::Website
Get the website configuration.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Aliyun::Oss::Struct::Base
Instance Attribute Details
#client ⇒ Object
reference to client
15 16 17 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 15 def client @client end |
#creation_date ⇒ Object
Createion date of Bucket
12 13 14 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 12 def creation_date @creation_date end |
#location ⇒ Object
Bucket Location
9 10 11 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 9 def location @location end |
#name ⇒ Object
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
70 71 72 73 74 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 70 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
93 94 95 96 97 98 99 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 93 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_cors ⇒ true
Disable CORS for bucket
118 119 120 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 118 def disable_cors !!client.bucket_disable_cors end |
#disable_lifecycle ⇒ true
Used to disable lifecycle for bucket
216 217 218 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 216 def disable_lifecycle !!client.bucket_disable_lifecycle end |
#disable_logging ⇒ true
Used to disable access logging.
61 62 63 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 61 def disable_logging !!client.bucket_disable_logging end |
#disable_website ⇒ true
Used to disable website hostted mode.
154 155 156 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 154 def disable_website !!client.bucket_disable_website end |
#enable_cors(*args) ⇒ true
Set CORS for bucket
109 110 111 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 109 def enable_cors(*args) !!client.bucket_enable_cors(*args) end |
#enable_lifecycle(*args) ⇒ true
Used to enable and set lifecycle for bucket
207 208 209 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 207 def enable_lifecycle(*args) !!client.bucket_enable_lifecycle(*args) end |
#enable_logging(*args) ⇒ true
Used to enable access logging.
50 51 52 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 50 def enable_logging(*args) !!client.bucket_enable_logging(*args) end |
#enable_website(*args) ⇒ true
Used to enable static website hosted mode.
145 146 147 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 145 def enable_website(*args) !!client.bucket_enable_website(*args) end |
#host ⇒ Object
17 18 19 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 17 def host "#{location}.aliyuncs.com" end |
#lifecycle! ⇒ Array<Aliyun::Oss::Struct::Lifecycle?]
Get the lifecycle configuration
190 191 192 193 194 195 196 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 190 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
26 27 28 29 30 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 26 def location! result = client.bucket_get_location.parsed_response Utils.dig_value(result, 'LocationConstraint', '__content__') || Utils.dig_value(result, 'LocationConstraint') end |
#logging! ⇒ Object
Get Logging configration for bucket
return [true]
37 38 39 40 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 37 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
228 229 230 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 228 def preflight(*args) !!client.bucket_preflight(*args) end |
#referer! ⇒ Aliyun::Oss::Struct::Referer
Get the referer configuration
163 164 165 166 167 168 169 170 171 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 163 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
84 85 86 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 84 def set_acl(*args) !!client.bucket_set_acl(*args) end |
#set_referer(*args) ⇒ true
Used to set referer for bucket.
181 182 183 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 181 def set_referer(*args) !!client.bucket_set_referer(*args) end |
#website! ⇒ Aliyun::Oss::Rule::Website
Get the website configuration
127 128 129 130 131 132 133 134 135 |
# File 'lib/aliyun/oss/struct/bucket.rb', line 127 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 |