B2 Application key

class b2sdk.v2.ApplicationKey(key_name, application_key_id, capabilities, account_id, expiration_timestamp_millis=None, bucket_id=None, name_prefix=None, options=None)[source]

Dataclass for storing info about an application key returned by delete-key or list-keys.

Parameters:
classmethod from_api_response(response)[source]

Create an ApplicationKey object from a delete-key or list-key response (a parsed json object).

Parameters:

response (dict) –

Return type:

ApplicationKey

__init__(key_name, application_key_id, capabilities, account_id, expiration_timestamp_millis=None, bucket_id=None, name_prefix=None, options=None)
Parameters:
  • key_name (str) – name of the key, assigned by user

  • application_key_id (str) – key id, used to authenticate

  • capabilities (list[str]) – list of capabilities assigned to this key

  • account_id (str) – account’s id

  • expiration_timestamp_millis (Optional[int]) – expiration time of the key

  • bucket_id (Optional[str]) – if restricted to a bucket, this is the bucket’s id

  • name_prefix (Optional[str]) – if restricted to some files, this is their prefix

  • options (Optional[list[str]]) – reserved for future use

as_dict()

Represent the key as a dict, like the one returned by B2 cloud

has_capabilities(capabilities)

checks whether the key has ALL of the given capabilities

Return type:

bool

classmethod parse_response_dict(response)
Parameters:

response (dict) –

class b2sdk.v2.FullApplicationKey(key_name, application_key_id, application_key, capabilities, account_id, expiration_timestamp_millis=None, bucket_id=None, name_prefix=None, options=None)[source]

Dataclass for storing info about an application key, including the actual key, as returned by create-key.

Parameters:
__init__(key_name, application_key_id, application_key, capabilities, account_id, expiration_timestamp_millis=None, bucket_id=None, name_prefix=None, options=None)[source]
Parameters:
  • key_name (str) – name of the key, assigned by user

  • application_key_id (str) – key id, used to authenticate

  • application_key (str) – the actual secret key

  • capabilities (list[str]) – list of capabilities assigned to this key

  • account_id (str) – account’s id

  • expiration_timestamp_millis (Optional[int]) – expiration time of the key

  • bucket_id (Optional[str]) – if restricted to a bucket, this is the bucket’s id

  • name_prefix (Optional[str]) – if restricted to some files, this is their prefix

  • options (Optional[list[str]]) – reserved for future use

classmethod from_create_response(response)[source]

Create a FullApplicationKey object from a create-key response (a parsed json object).

Parameters:

response (dict) –

Return type:

FullApplicationKey

classmethod parse_response_dict(response)[source]
Parameters:

response (dict) –

as_dict()[source]

Represent the key as a dict, like the one returned by B2 cloud

has_capabilities(capabilities)

checks whether the key has ALL of the given capabilities

Return type:

bool