Module: Aliyun::Oss::Client::Buckets

Included in:
BucketsService
Defined in:
lib/aliyun/oss/client/buckets.rb

Instance Method Summary collapse

Instance Method Details

#create(*args) ⇒ true

Create bucket

Examples:

oss.client.bucket_create('oss-sdk-dev-hangzhou-xxx')

Parameters:

  • name (String)

    Specify bucket name

  • location (String)

    Specify the bucket’s data center location, can be one of below: oss-cn-hangzhou,oss-cn-qingdao,oss-cn-beijing,oss-cn-hongkong, oss-cn-shenzhen,oss-cn-shanghai,oss-us-west-1 ,oss-ap-southeast-1

  • acl (String)

    Specify the bucket’s access. Api::BucketProperty#bucket_set_acl

Returns:

  • (true)

Raises:

See Also:



30
31
32
# File 'lib/aliyun/oss/client/buckets.rb', line 30

def create(*args)
  !!client.bucket_create(*args)
end

#delete(*args) ⇒ true

Delete bucket

Parameters:

  • name (String)

    bucket name want to delete

Returns:

  • (true)

Raises:

See Also:



42
43
44
# File 'lib/aliyun/oss/client/buckets.rb', line 42

def delete(*args)
  !!client.bucket_delete(*args)
end

#list(options = {}) ⇒ Array<Aliyun::Oss::Struct::Bucket>

List buckets

Parameters:

  • options (Hash) (defaults to: {})

    options

Returns:

Raises:

See Also:



13
14
15
16
17
18
19
20
# File 'lib/aliyun/oss/client/buckets.rb', line 13

def list(options = {})
  result = client.list_buckets(options).parsed_response

  bucket_keys = %w(ListAllMyBucketsResult Buckets Bucket)
  Utils.wrap(Utils.dig_value(result, *bucket_keys)).map do |bucket_hash|
    build_bucket(bucket_hash, client)
  end
end