Source code for pyenbc.remote.azure_drive

"""
Common API to upload, download data from Azure

.. versionadded:: 1.1


:githublink:`%|py|7`
"""
from .cloud_transfer import CloudTransfer
from .azure_connection import AzureClient


[docs]class AzureDrive(CloudTransfer): """ defines a common API for a remote storage .. versionadded:: 1.1 :githublink:`%|py|16` """
[docs] def __init__(self, blob, key, fLOG=None, container="backup"): """ constructor :param blob: blob storage :param key: key :param container: container name :param fLOG: logging function :githublink:`%|py|26` """ CloudTransfer.__init__(self, blob, key, fLOG) self._client = AzureClient(blob, key) self._container = container
[docs] def connect(self): """ connect :githublink:`%|py|34` """ self._service = self._client.open_blob_service()
[docs] def close(self): """ close the connection :githublink:`%|py|40` """ pass
[docs] def upload_data(self, remote_path, data): """ upload binary data :param remote_path: path on the remote drive :param data: bytes :return: boolean :githublink:`%|py|50` """ self._client.upload_data( self._service, self._container, remote_path, data)
[docs] def download_data(self, remote_path): """ download binary data :param remote_path: path on the remote drive :return: data (bytes) :githublink:`%|py|60` """ return self._client.download_data(self._service, self._container, remote_path)