swh.objstorage.backends.azure module

swh.objstorage.backends.azure.get_container_url(account_name: str, account_key: str, container_name: str, access_policy: str = 'read_only', expiry: datetime.timedelta = datetime.timedelta(days=365), **kwargs) → str[source]

Get the full url, for the given container on the given account, with a Shared Access Signature granting the specified access policy.

Parameters
  • account_name – name of the storage account for which to generate the URL

  • account_key – shared account key of the storage account used to generate the SAS

  • container_name – name of the container for which to grant access in the storage account

  • access_policy – one of read_only, append_only, full

  • expiry – the interval in the future with which the signature will expire

Returns

the full URL of the container, with the shared access signature.

class swh.objstorage.backends.azure.AzureCloudObjStorage(container_url: Optional[str] = None, account_name: Optional[str] = None, api_secret_key: Optional[str] = None, container_name: Optional[str] = None, compression='gzip', **kwargs)[source]

Bases: swh.objstorage.objstorage.ObjStorage

ObjStorage backend for Azure blob storage accounts.

Parameters
  • container_url – the URL of the container in which the objects are stored.

  • account_name – (deprecated) the name of the storage account under which objects are stored

  • api_secret_key – (deprecated) the shared account key

  • container_name – (deprecated) the name of the container under which objects are stored

  • compression – the compression algorithm used to compress objects in storage

Notes

The container url should contain the credentials via a “Shared Access Signature”. The get_container_url() helper can be used to generate such a URL from the account’s access keys. The account_name, api_secret_key and container_name arguments are deprecated.

get_container_client(hex_obj_id)[source]

Get the container client for the container that contains the object with internal id hex_obj_id

This is used to allow the PrefixedAzureCloudObjStorage to dispatch the client according to the prefix of the object id.

get_blob_client(hex_obj_id)[source]

Get the azure blob client for the given hex obj id

get_all_container_clients()[source]

Get all active block_blob_services

check_config(*, check_write)[source]

Check the configuration for this object storage

add(content, obj_id=None, check_presence=True)[source]

Add an obj in storage if it’s not there already.

restore(content, obj_id=None)[source]

Restore a content.

get(obj_id)[source]

Retrieve blob’s content if found.

check(obj_id)[source]

Check the content integrity.

delete(obj_id)[source]

Delete an object.

class swh.objstorage.backends.azure.PrefixedAzureCloudObjStorage(accounts: Dict[str, Union[str, Dict[str, str]]], compression='gzip', **kwargs)[source]

Bases: swh.objstorage.backends.azure.AzureCloudObjStorage

ObjStorage with azure capabilities, striped by prefix.

accounts is a dict containing entries of the form:

<prefix>: <container_url_for_prefix>

get_container_client(hex_obj_id)[source]

Get the block_blob_service and container that contains the object with internal id hex_obj_id

get_all_container_clients()[source]

Get all active container clients