b2sdk._internal.session – B2 Session

class b2sdk._internal.session.TokenType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

API = 'api'
API_TOKEN_ONLY = 'api_token_only'
UPLOAD_PART = 'upload_part'
UPLOAD_SMALL = 'upload_small'
class b2sdk._internal.session.B2Session(account_info=None, cache=None, api_config=<b2sdk._internal.api_config.B2HttpApiConfig object>)[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.

Parameters:
SQLITE_ACCOUNT_INFO_CLASS

alias of SqliteAccountInfo

B2HTTP_CLASS

alias of B2Http

__init__(account_info=None, cache=None, api_config=<b2sdk._internal.api_config.B2HttpApiConfig object>)[source]

Initialize Session using given account info.

Parameters:

:param api_config

Parameters:

api_config (B2HttpApiConfig) –

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, default_server_side_encryption=None, is_file_lock_enabled=None, replication=None)[source]
Parameters:
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, bypass_governance=False)[source]
Parameters:

bypass_governance (bool) –

download_file_from_url(url, range_=None, encryption=None)[source]
Parameters:

encryption (Optional[EncryptionSetting]) –

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)[source]
Parameters:

file_id (str) –

Return type:

dict[str, Any]

get_file_info_by_name(bucket_name, file_name)[source]
Parameters:
  • bucket_name (str) –

  • file_name (str) –

Return type:

dict[str, Any]

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, server_side_encryption=None, file_retention=None, legal_hold=None, custom_upload_timestamp=None)[source]
Parameters:
update_bucket(account_id, bucket_id, bucket_type=None, bucket_info=None, cors_rules=None, lifecycle_rules=None, if_revision_is=None, default_server_side_encryption=None, default_retention=None, replication=None, is_file_lock_enabled=None)[source]
Parameters:
upload_file(bucket_id, file_name, content_length, content_type, content_sha1, file_info, data_stream, server_side_encryption=None, file_retention=None, legal_hold=None, custom_upload_timestamp=None)[source]
Parameters:
upload_part(file_id, part_number, content_length, sha1_sum, input_stream, server_side_encryption=None)[source]
Parameters:

server_side_encryption (Optional[EncryptionSetting]) –

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, destination_server_side_encryption=None, source_server_side_encryption=None, file_retention=None, legal_hold=None)[source]
Parameters:
copy_part(source_file_id, large_file_id, part_number, bytes_range=None, destination_server_side_encryption=None, source_server_side_encryption=None)[source]
Parameters:
update_file_retention(file_id, file_name, file_retention, bypass_governance=False)[source]
Parameters:
Parameters:

legal_hold (LegalHold) –

get_bucket_notification_rules(bucket_id)[source]
set_bucket_notification_rules(bucket_id, rules)[source]