class B2::Bucket
Attributes
account_id[RW]
bucket_id[RW]
bucket_name[RW]
bucket_type[RW]
buckets[RW]
files[RW]
upload_url[RW]
Public Instance Methods
create(bucket_name, bucket_type)
click to toggle source
# File lib/b2/bucket.rb, line 5 def create(bucket_name, bucket_type) body = { accountId: B2.account_id, bucketName: bucket_name, bucketType: bucket_type } response = post('/b2_create_bucket', body: body.to_json) assign_return_value(response) end
delete(bucket_id)
click to toggle source
# File lib/b2/bucket.rb, line 15 def delete(bucket_id) body = { accountId: B2.account_id, bucketId: bucket_id } response = post('/b2_delete_bucket', body: body.to_json) assign_return_value(response) end
get_upload_url(bucket_id)
click to toggle source
# 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
list()
click to toggle source
# File lib/b2/bucket.rb, line 25 def list body = {accountId: B2.account_id} response = post('/b2_list_buckets', body: body.to_json) assign_return_value(response) end
list_file_names(bucket_id, startFileName: nil, maxFileCount: nil)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/b2/bucket.rb, line 32 def update_bucket(bucket_id, bucket_type) body = { accountId: B2.account_id, bucketId: bucket_id, bucketType: bucket_type } response = post('/b2_update_bucket', body: body.to_json) assign_return_value(response) end
Private Instance Methods
assign_return_value(response)
click to toggle source
# File lib/b2/bucket.rb, line 76 def assign_return_value(response) if response.code.eql?(200) self.bucket_id = response["bucketId"] self.account_id = response["accountId"] self.bucket_name = response["bucketName"] self.bucket_type = response["bucketType"] self.buckets = response["buckets"] self.upload_url = response["uploadUrl"] self.authorization_token = response["authorizationToken"] self.files = response["files"] end response end