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
account_info – an instance of
UrlPoolAccountInfo
, or any custom class derived fromAbstractAccountInfo
To learn more about Account Info objects, see hereSqliteAccountInfo
cache – an instance of the one of the following classes:
DummyCache
,InMemoryCache
,AuthInfoCache
, or any custom class derived fromAbstractCache
It is used by B2Api to cache the mapping between bucket name and bucket ids. default isDummyCache
raw_api – an instance of one of the following classes:
B2RawApi
,RawSimulator
, or any custom class derived fromAbstractRawApi
It makes network-less unit testing simple by usingRawSimulator
, in tests andB2RawApi
in production. default isB2RawApi
Perform automatic account authorization, retrieving all account data from account info object passed during initialization.
Perform account authorization.
- Parameters
realm (str) – a realm to authorize account in (usually just “production”)
application_key_id (str) – application key ID
application_key (str) – user’s application key
-
create_bucket
(account_id, bucket_name, bucket_type, bucket_info=None, cors_rules=None, lifecycle_rules=None, default_server_side_encryption=None)[source]¶
-
create_key
(account_id, capabilities, key_name, valid_duration_seconds, bucket_id, name_prefix)[source]¶
-
list_file_versions
(bucket_id, start_file_name=None, start_file_id=None, max_file_count=None, prefix=None)[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: Optional[b2sdk.encryption.setting.EncryptionSetting] = None)[source]¶
-
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: Optional[b2sdk.encryption.setting.EncryptionSetting] = None)[source]¶
-
upload_file
(bucket_id, file_name, content_length, content_type, content_sha1, file_infos, data_stream, server_side_encryption: Optional[b2sdk.encryption.setting.EncryptionSetting] = None)[source]¶
-
upload_part
(file_id, part_number, content_length, sha1_sum, input_stream, server_side_encryption: Optional[b2sdk.encryption.setting.EncryptionSetting] = None)[source]¶
-