b2sdk.account_info.abstract
– Account info abstract¶
-
class
b2sdk.account_info.abstract.
AbstractAccountInfo
[source]¶ Bases:
object
Holder for all account-related information that needs to be kept between API calls, and between invocations of the command-line tool. This includes: account ID, application key ID, application key, auth tokens, API URL, download URL, and uploads URLs.
This class must be THREAD SAFE because it may be used by multiple threads running in the same Python process. It also needs to be safe against multiple processes running at the same time.
-
DEFAULT_ALLOWED
= {'bucketId': None, 'bucketName': None, 'capabilities': ['listKeys', 'writeKeys', 'deleteKeys', 'listBuckets', 'writeBuckets', 'deleteBuckets', 'listFiles', 'readFiles', 'shareFiles', 'writeFiles', 'deleteFiles'], 'namePrefix': None}¶
-
REALM_URLS
= {'dev': 'http://api.backblazeb2.xyz:8180', 'production': 'https://api.backblazeb2.com', 'staging': 'https://api.backblaze.net'}¶
-
classmethod
allowed_is_valid
(allowed)[source]¶ Makes sure that all of the required fields are present, and that bucketId is set if bucketName is.
If the bucketId is for a bucket that no longer exists, or the capabilities do not allow listBuckets, then we won’t have a bucketName.
-
abstract
clear_bucket_upload_data
(bucket_id)[source]¶ Removes all upload URLs for the given bucket.
- Parameters
bucket_id (str) – a bucket ID
-
abstract
clear_large_file_upload_urls
(file_id)[source]¶ Clear a pool of URLs for a given file ID
- Parameters
file_id (str) – a file ID
-
abstract
get_account_auth_token
()[source]¶ Returns account_auth_token or raises MissingAccountData exception
- Return type
-
abstract
get_account_id
()[source]¶ Returns account ID or raises MissingAccountData exception
- Return type
-
get_account_id_or_app_key_id
()[source]¶ Returns the application key ID used to authenticate
- Return type
Deprecated since version 0.1.6: Use
get_application_key_id()
instead.
-
abstract
get_allowed
()[source]¶ An ‘allowed’ dict, as returned by
b2_authorize_account
. NeverNone
; for account info that was saved before ‘allowed’ existed, returnsDEFAULT_ALLOWED
.- Return type
-
abstract
get_application_key
()[source]¶ Returns application_key or raises MissingAccountData exception
- Return type
-
abstract
get_application_key_id
()[source]¶ Returns the application key ID used to authenticate
- Return type
-
abstract
get_bucket_id_or_none_from_bucket_name
(bucket_name)[source]¶ Looks up the bucket ID for a given bucket name.
-
abstract
get_download_url
()[source]¶ Returns download_url or raises MissingAccountData exception
- Return type
-
abstract
get_minimum_part_size
()[source]¶ Return the minimum number of bytes in a part of a large file
- Returns
number of bytes
- Return type
-
abstract
put_bucket_upload_url
(bucket_id, upload_url, upload_auth_token)[source]¶ Add an (upload_url, upload_auth_token) pair to the pool available for the bucket.
-
abstract
put_large_file_upload_url
(file_id, upload_url, upload_auth_token)[source]¶ Put large file upload URL into a pool
-
abstract
refresh_entire_bucket_name_cache
(name_id_iterable)[source]¶ Removes all previous name-to-id mappings and stores new ones.
- Parameters
name_id_iterable (list) – a list of tuples of the form (name, id)
-
abstract
remove_bucket_name
(bucket_name)[source]¶ Removes one entry from the bucket name cache.
- Parameters
bucket_name (str) – a bucket name
-
abstract
save_bucket
(bucket)[source]¶ Remembers the ID for a bucket name.
- Parameters
bucket (b2sdk.bucket.Bucket) – a Bucket object
-
set_auth_data
(account_id, auth_token, api_url, download_url, minimum_part_size, application_key, realm, allowed=None, application_key_id=None)[source]¶ Stores the results of
b2_authorize_account
.All of the information returned by
b2_authorize_account
is saved, because all of it is needed by some command.The allowed structure is the one returned
b2_authorize_account
, with the addition of a bucketName field. For keys with bucket restrictions, the name of the bucket is looked up and stored, too. The console_tool does everything by bucket name, so it’s convenient to have the restricted bucket name handy.- Parameters
account_id (str) – user account ID
auth_token (str) – user authentication token
api_url (str) – an API URL
download_url (str) – path download URL
minimum_part_size (int) – minimum size of the file part
application_key (str) – application key
realm (str) – a realm to authorize account in
allowed (dict) – the structure to use for old account info that was saved without ‘allowed’
application_key_id (str) – application key ID
Changed in version 0.1.5: account_id_or_app_key_id renamed to get_application_key_id
-