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

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. (see #bucket_set_acl)

Returns:

  • (true)

See Also:



33
34
35
# File 'lib/aliyun/oss/client/buckets.rb', line 33

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

#delete(*args) ⇒ true

Delete bucket

Parameters:

  • name (String)

    bucket name want to delete

Returns:

  • (true)

See Also:



44
45
46
# File 'lib/aliyun/oss/client/buckets.rb', line 44

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

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

List buckets

Parameters:

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

    options

Options Hash (options):

  • :prefix (String)

    Filter buckets with prefix

  • :marker (String)

    Bucket name should after marker in alphabetical order

  • :max-keys (Integer) — default: 100

    Limit number of buckets, the maxinum should <= 1000

Returns:

See Also:



13
14
15
16
17
18
19
20
21
22
23
24
# 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|
    Struct::Bucket.new(bucket_hash).tap do |bucket|
      dup_client = client.clone
      dup_client.bucket = bucket.name
      bucket.client = dup_client
    end
  end
end