b2sdk.session – B2 Session

class b2sdk.session.TokenType(value)[source]

Bases: enum.Enum

An enumeration.

API = 'api'
API_TOKEN_ONLY = 'api_token_only'
UPLOAD_PART = 'upload_part'
UPLOAD_SMALL = 'upload_small'
class b2sdk.session.B2Session(account_info=None, cache=None, raw_api=None)[source]

Bases: object

A facade that supplies the correct api_url and account_auth_token to methods of underlying raw_api and reauthorizes if necessary.

__init__(account_info=None, cache=None, raw_api=None)[source]

Initialize Session using given account info.

Parameters
authorize_automatically()[source]

Perform automatic account authorization, retrieving all account data from account info object passed during initialization.

authorize_account(realm, application_key_id, application_key)[source]

Perform account authorization.

Parameters
cancel_large_file(file_id)[source]
create_bucket(account_id, bucket_name, bucket_type, bucket_info=None, cors_rules=None, lifecycle_rules=None)[source]
create_key(account_id, capabilities, key_name, valid_duration_seconds, bucket_id, name_prefix)[source]
delete_key(application_key_id)[source]
delete_bucket(account_id, bucket_id)[source]
delete_file_version(file_id, file_name)[source]
download_file_from_url(url, range_=None)[source]
finish_large_file(file_id, part_sha1_array)[source]
get_download_authorization(bucket_id, file_name_prefix, valid_duration_in_seconds)[source]
get_file_info_by_id(file_id: str) → Dict[str, Any][source]
get_file_info_by_name(bucket_name: str, file_name: str) → Dict[str, Any][source]
get_upload_url(bucket_id)[source]
get_upload_part_url(file_id)[source]
hide_file(bucket_id, file_name)[source]
list_buckets(account_id, bucket_id=None, bucket_name=None)[source]
list_file_names(bucket_id, start_file_name=None, max_file_count=None, prefix=None)[source]
list_file_versions(bucket_id, start_file_name=None, start_file_id=None, max_file_count=None, prefix=None)[source]
list_keys(account_id, max_key_count=None, start_application_key_id=None)[source]
list_parts(file_id, start_part_number, max_part_count)[source]
list_unfinished_large_files(bucket_id, start_file_id=None, max_file_count=None, prefix=None)[source]
start_large_file(bucket_id, file_name, content_type, file_info)[source]
update_bucket(account_id, bucket_id, bucket_type=None, bucket_info=None, cors_rules=None, lifecycle_rules=None, if_revision_is=None)[source]
upload_file(bucket_id, file_name, content_length, content_type, content_sha1, file_infos, data_stream)[source]
upload_part(file_id, part_number, content_length, sha1_sum, input_stream)[source]
get_download_url_by_id(file_id)[source]
get_download_url_by_name(bucket_name, file_name)[source]
copy_file(source_file_id, new_file_name, bytes_range=None, metadata_directive=None, content_type=None, file_info=None, destination_bucket_id=None)[source]
copy_part(source_file_id, large_file_id, part_number, bytes_range=None)[source]