b2sdk.account_info.upload_url_pool – Upload URL pool

class b2sdk.account_info.upload_url_pool.UploadUrlPool[source]

Bases: object

For each key (either a bucket id or large file id), holds a pool of (url, auth_token) pairs, with thread-safe methods to add and remove them.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

clear_for_key(key)[source]

Remove an intem from the pool by key

Parameters

key – bucket ID or large file ID

put(key, url, auth_token)[source]

Adds the url and auth token to the pool for the given key.

Parameters
  • key – bucket ID or large file ID

  • url (str) – bucket or file URL

  • auth_token (str) – authentication token

take(key)[source]

Returns (url, auth_token) if one is available, or (None, None) if not.

Parameters

key – bucket ID or large file ID

Return type

tuple

class b2sdk.account_info.upload_url_pool.UrlPoolAccountInfo[source]

Bases: b2sdk.account_info.abstract.AbstractAccountInfo

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, auth tokens, API URL, download URL, and uploads URLs.

This concrete implementation uses an instance of UploadUrlPool as an underlying storage

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

abstract clear()[source]

Remove all stored information

clear_bucket_upload_data(bucket_id)[source]

Removes all upload URLs for the given bucket.

Parameters

bucket_id (str) – a bucket ID

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

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.

Parameters
  • bucket_id (str) – a bucket ID

  • upload_url (str) – an upload URL

  • upload_auth_token (str) – an upload authentication token

Return type

tuple

put_large_file_upload_url(file_id, upload_url, upload_auth_token)[source]

Put large file upload URL into a pool

Parameters
  • file_id (str) – a file ID

  • upload_url (str) – an upload URL

  • upload_auth_token (str) – an upload authentication token

take_bucket_upload_url(bucket_id)[source]

Returns a pair (upload_url, upload_auth_token) that has been removed from the pool for this bucket, or (None, None) if there are no more left.

Parameters

bucket_id (str) – a bucket ID

Return type

tuple

take_large_file_upload_url(file_id)[source]

Take large file upload URL from a pool

Parameters

file_id (str) – a file ID