Class: B2::Bucket

Inherits:
Base
  • Object
show all
Defined in:
lib/b2/bucket.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#download_url

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from B2::Base

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def 
  @account_id
end

#authorization_tokenObject

Returns the value of attribute authorization_token.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def authorization_token
  @authorization_token
end

#bucket_idObject

Returns the value of attribute bucket_id.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def bucket_id
  @bucket_id
end

#bucket_nameObject

Returns the value of attribute bucket_name.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def bucket_name
  @bucket_name
end

#bucket_typeObject

Returns the value of attribute bucket_type.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def bucket_type
  @bucket_type
end

#bucketsObject

Returns the value of attribute buckets.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def buckets
  @buckets
end

#filesObject

Returns the value of attribute files.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def files
  @files
end

#upload_urlObject

Returns the value of attribute upload_url.



3
4
5
# File 'lib/b2/bucket.rb', line 3

def upload_url
  @upload_url
end

Instance Method Details

#create(bucket_name, bucket_type) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/b2/bucket.rb', line 5

def create(bucket_name, bucket_type)
  body = {
    accountId: B2.,
    bucketName: bucket_name,
    bucketType: bucket_type
  }
  response = post('/b2_create_bucket', body: body.to_json)
  assign_return_value(response)
end

#delete(bucket_id) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/b2/bucket.rb', line 15

def delete(bucket_id)
  body = {
    accountId: B2.,
    bucketId: bucket_id
  }

  response = post('/b2_delete_bucket', body: body.to_json)
  assign_return_value(response)
end

#get_upload_url(bucket_id) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/b2/bucket.rb', line 43

def get_upload_url(bucket_id)
  body = {
    bucketId: bucket_id
  }

  response = post('/b2_get_upload_url', body: body.to_json)
  assign_return_value(response)
end

#listObject



25
26
27
28
29
30
# File 'lib/b2/bucket.rb', line 25

def list
  body = {accountId: B2.}

  response = post('/b2_list_buckets', body: body.to_json)
  assign_return_value(response)
end

#list_file_names(bucket_id, startFileName: nil, maxFileCount: nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/b2/bucket.rb', line 52

def list_file_names(bucket_id, startFileName: nil, maxFileCount: nil)
  body = {
    bucketId: bucket_id
  }
  body.merge!(startFileName: startFileName) if startFileName
  body.merge!(maxFileCount: maxFileCount) if maxFileCount

  response = post('/b2_list_file_names', body: body.to_json)
  assign_return_value(response)
end

#list_file_versions(bucket_id, startFileName: nil, startFileId: nil, maxFileCount: nil) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/b2/bucket.rb', line 63

def list_file_versions(bucket_id, startFileName: nil, startFileId: nil, maxFileCount: nil)
  body = {
    bucketId: bucket_id
  }
  body.merge!(startFileName: startFileName) if startFileName
  body.merge!(maxFileCount: maxFileCount) if maxFileCount
  body.merge!(startFileId: startFileId) if startFileId

  response = post('/b2_list_file_versions', body: body.to_json)
  assign_return_value(response)
end

#update_bucket(bucket_id, bucket_type) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/b2/bucket.rb', line 32

def update_bucket(bucket_id, bucket_type)
  body = {
    accountId: B2.,
    bucketId: bucket_id,
    bucketType: bucket_type
  }

  response = post('/b2_update_bucket', body: body.to_json)
  assign_return_value(response)
end