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:
account_info (
Optional
[AbstractAccountInfo
]) –cache (
Optional
[AbstractCache
]) –api_config (
B2HttpApiConfig
) –
- SQLITE_ACCOUNT_INFO_CLASS
alias of
SqliteAccountInfo
- __init__(account_info=None, cache=None, api_config=<b2sdk._internal.api_config.B2HttpApiConfig object>)[source]
Initialize Session using given account info.
- Parameters:
account_info (
Optional
[AbstractAccountInfo
]) – an instance ofUrlPoolAccountInfo
, or any custom class derived fromAbstractAccountInfo
To learn more about Account Info objects, see hereSqliteAccountInfo
cache (
Optional
[AbstractCache
]) – 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
: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:
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, is_file_lock_enabled=None, replication=None)[source]
- create_key(account_id, capabilities, key_name, valid_duration_seconds, bucket_id, name_prefix)[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
]) –
- 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=None, file_retention=None, legal_hold=None, custom_upload_timestamp=None)[source]
- Parameters:
server_side_encryption (
Optional
[EncryptionSetting
]) –file_retention (
Optional
[FileRetentionSetting
]) –
- 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:
lifecycle_rules (
Optional
[list
[LifecycleRule
]]) –default_server_side_encryption (
Optional
[EncryptionSetting
]) –default_retention (
Optional
[BucketRetentionSetting
]) –replication (
Optional
[ReplicationConfiguration
]) –
- 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:
server_side_encryption (
Optional
[EncryptionSetting
]) –file_retention (
Optional
[FileRetentionSetting
]) –
- upload_part(file_id, part_number, content_length, sha1_sum, input_stream, server_side_encryption=None)[source]
- Parameters:
server_side_encryption (
Optional
[EncryptionSetting
]) –
- 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:
destination_server_side_encryption (
Optional
[EncryptionSetting
]) –source_server_side_encryption (
Optional
[EncryptionSetting
]) –file_retention (
Optional
[FileRetentionSetting
]) –
- 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:
destination_server_side_encryption (
Optional
[EncryptionSetting
]) –source_server_side_encryption (
Optional
[EncryptionSetting
]) –
- update_file_retention(file_id, file_name, file_retention, bypass_governance=False)[source]
- Parameters:
file_retention (
FileRetentionSetting
) –bypass_governance (
bool
) –