From 33128e6d6ab6be49e3ed6e8ba0317cd7f9049479 Mon Sep 17 00:00:00 2001 From: Dylan Gonzales Date: Wed, 26 Oct 2022 16:47:49 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=97=20auto-resolve=20dns=20(#43)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/changelog/iotStorageClient.md | 4 ++ .../static/packages/iotStorageClient.md | 6 +-- .../static/packages/iotStorageClientAsync.md | 6 +-- iot-storage-client/CHANGELOG.md | 4 ++ .../iot/storage/client/_aioclient.py | 10 ----- .../iot/storage/client/_client.py | 10 ----- .../iot/storage/client/_helpers.py | 42 ++++++------------- .../iot/storage/client/_version.py | 2 +- 8 files changed, 23 insertions(+), 61 deletions(-) diff --git a/docs/public/static/changelog/iotStorageClient.md b/docs/public/static/changelog/iotStorageClient.md index d11c7fc..357cd63 100644 --- a/docs/public/static/changelog/iotStorageClient.md +++ b/docs/public/static/changelog/iotStorageClient.md @@ -4,6 +4,10 @@ title: iot-storage-client Changelog # Release History for iot-storage-client +### 1.2.1 (10/26/2022) + +- Default Azure Private Link/Endpoints to leverage DNS resolution + ### 1.2.0 (09/22/2022) - Instantiate clients that interact via Azure Private Links/Endpoints diff --git a/docs/public/static/packages/iotStorageClient.md b/docs/public/static/packages/iotStorageClient.md index b88c4af..e4a9488 100644 --- a/docs/public/static/packages/iotStorageClient.md +++ b/docs/public/static/packages/iotStorageClient.md @@ -93,7 +93,7 @@ A wrapper client to interact with the Azure Blob Service at the account level. This client provides operations to list, create and delete storage containers and blobs within the account. ```python -IoTStorageClient(credential_type, location_type, account_name, credential, module=None, host=None, port=None, private=False) +IoTStorageClient(credential_type, location_type, account_name, credential, module=None, host=None, port=None) ``` **Parameters** @@ -126,10 +126,6 @@ IoTStorageClient(credential_type, location_type, account_name, credential, modul The open port of the Azure storage account when it lives on an IoT Edge device. -- `private` Optional[bool] - - Does this client connect to an Azure storage account over a private endpoint? - ### Container Exists Method Check if a container exists. diff --git a/docs/public/static/packages/iotStorageClientAsync.md b/docs/public/static/packages/iotStorageClientAsync.md index dc3b734..1e3cee3 100644 --- a/docs/public/static/packages/iotStorageClientAsync.md +++ b/docs/public/static/packages/iotStorageClientAsync.md @@ -93,7 +93,7 @@ A wrapper client to interact with the Azure Blob Service asynchronously at the a This client provides operations to list, create and delete storage containers and blobs within the account. ```python -IoTStorageClientAsync(credential_type, location_type, account_name, credential, module=None, host=None, port=None, private=False) +IoTStorageClientAsync(credential_type, location_type, account_name, credential, module=None, host=None, port=None) ``` **Parameters** @@ -126,10 +126,6 @@ IoTStorageClientAsync(credential_type, location_type, account_name, credential, The open port of the Azure storage account when it lives on an IoT Edge device. -- `private` Optional[bool] - - Does this client connect to an Azure storage account over a private endpoint? - ### Container Exists Method Check if a container exists. diff --git a/iot-storage-client/CHANGELOG.md b/iot-storage-client/CHANGELOG.md index 8face07..7683c43 100644 --- a/iot-storage-client/CHANGELOG.md +++ b/iot-storage-client/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 1.2.1 (10/26/2022) + +- Default Azure Private Link/Endpoints to leverage DNS resolution + ## 1.2.0 (09/22/2022) - Instantiate clients that interact via Azure Private Links/Endpoints diff --git a/iot-storage-client/iot/storage/client/_aioclient.py b/iot-storage-client/iot/storage/client/_aioclient.py index 36bad25..0ee14e1 100644 --- a/iot-storage-client/iot/storage/client/_aioclient.py +++ b/iot-storage-client/iot/storage/client/_aioclient.py @@ -37,7 +37,6 @@ class IoTStorageClientAsync: module: Optional[str] = None host: Optional[str] = None port: Optional[str] = None - private: Optional[bool] = False service_client: BlobServiceClient container_client: ContainerClient @@ -52,7 +51,6 @@ def __init__( module: Optional[str] = None, host: Optional[str] = None, port: Optional[str] = None, - private: Optional[bool] = False, ) -> None: self.credential_type = credential_type self.location_type = location_type @@ -61,7 +59,6 @@ def __init__( self.module = module self.host = host self.port = port - self.private = private self.instantiate_service_client() def __repr__(self) -> str: @@ -85,7 +82,6 @@ def instantiate_service_client(self) -> None: if self.location_type == LocationType.CLOUD_BASED: connection_string = generate_cloud_conn_str( account=self.account_name, - private=self.private, account_key=self.credential if self.credential_type == CredentialType.ACCOUNT_KEY else None, @@ -524,7 +520,6 @@ async def generate_file_sas_url( return generate_cloud_sas_url( account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=f"{container_name}/{source}", ) if self.location_type == LocationType.EDGE_BASED: @@ -533,7 +528,6 @@ async def generate_file_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=f"{container_name}/{source}", ) if self.location_type == LocationType.LOCAL_BASED: @@ -542,7 +536,6 @@ async def generate_file_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=f"{container_name}/{source}", ) return None @@ -590,7 +583,6 @@ async def generate_container_sas_url( return generate_cloud_sas_url( account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=container_name, ) if self.location_type == LocationType.EDGE_BASED: @@ -599,7 +591,6 @@ async def generate_container_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=container_name, ) if self.location_type == LocationType.LOCAL_BASED: @@ -608,7 +599,6 @@ async def generate_container_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=container_name, ) return None diff --git a/iot-storage-client/iot/storage/client/_client.py b/iot-storage-client/iot/storage/client/_client.py index dfb5ea2..546c3ca 100644 --- a/iot-storage-client/iot/storage/client/_client.py +++ b/iot-storage-client/iot/storage/client/_client.py @@ -39,7 +39,6 @@ class IoTStorageClient: module: Optional[str] = None host: Optional[str] = None port: Optional[str] = None - private: Optional[bool] = False service_client: BlobServiceClient container_client: ContainerClient @@ -54,7 +53,6 @@ def __init__( module: Optional[str] = None, host: Optional[str] = None, port: Optional[str] = None, - private: Optional[bool] = False, ) -> None: self.credential_type = credential_type self.location_type = location_type @@ -63,7 +61,6 @@ def __init__( self.module = module self.host = host self.port = port - self.private = private self.instantiate_service_client() def __repr__(self) -> str: @@ -87,7 +84,6 @@ def instantiate_service_client(self) -> None: if self.location_type == LocationType.CLOUD_BASED: connection_string = generate_cloud_conn_str( account=self.account_name, - private=self.private, account_key=self.credential if self.credential_type == CredentialType.ACCOUNT_KEY else None, @@ -509,7 +505,6 @@ def generate_file_sas_url( return generate_cloud_sas_url( account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=f"{container_name}/{source}", ) if self.location_type == LocationType.EDGE_BASED: @@ -518,7 +513,6 @@ def generate_file_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=f"{container_name}/{source}", ) if self.location_type == LocationType.LOCAL_BASED: @@ -527,7 +521,6 @@ def generate_file_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=f"{container_name}/{source}", ) return None @@ -575,7 +568,6 @@ def generate_container_sas_url( return generate_cloud_sas_url( account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=container_name, ) if self.location_type == LocationType.EDGE_BASED: @@ -584,7 +576,6 @@ def generate_container_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=container_name, ) if self.location_type == LocationType.LOCAL_BASED: @@ -593,7 +584,6 @@ def generate_container_sas_url( port=self.port, account=self.account_name, account_sas=sas_token, - private=self.private, blob_path=container_name, ) return None diff --git a/iot-storage-client/iot/storage/client/_helpers.py b/iot-storage-client/iot/storage/client/_helpers.py index abd926a..c3ecc6b 100644 --- a/iot-storage-client/iot/storage/client/_helpers.py +++ b/iot-storage-client/iot/storage/client/_helpers.py @@ -32,27 +32,23 @@ def generate_edge_sas_url( port: str, account: str, account_sas: str, - private: bool, blob_path: Optional[str] = None, ) -> str: """ generate a SAS url for a child gateway device interacting with a parent gateway storage account """ - link = "privatelink.blob" if private else "blob" if not blob_path: - return "http://{host}:{port}/{account}.{link}.core.windows.net?{sas}".format( + return "http://{host}:{port}/{account}.blob.core.windows.net?{sas}".format( host=host, port=port, account=account, - link=link, sas=account_sas, ) - return "http://{host}:{port}/{account}.{link}.core.windows.net/{path}?{sas}".format( + return "http://{host}:{port}/{account}.blob.core.windows.net/{path}?{sas}".format( host=host, port=port, account=account, - link=link, path=blob_path, sas=account_sas, ) @@ -88,7 +84,6 @@ def generate_local_sas_url( port: str, account: str, account_sas: str, - private: bool, blob_path: Optional[str] = None, ) -> str: """ @@ -96,30 +91,24 @@ def generate_local_sas_url( interacting with a locally available storage account (AzureBlobStorageonIoTEdge) """ - link = "privatelink.blob" if private else "blob" if not blob_path: - return "http://{module}:{port}/{account}.{link}.core.windows.net?{sas}".format( + return "http://{module}:{port}/{account}.blob.core.windows.net?{sas}".format( module=module, port=port, account=account, - link=link, - sas=account_sas, - ) - return ( - "http://{module}:{port}/{account}.{link}.core.windows.net/{path}?{sas}".format( - module=module, - port=port, - account=account, - link=link, - path=blob_path, sas=account_sas, ) + return "http://{module}:{port}/{account}.blob.core.windows.net/{path}?{sas}".format( + module=module, + port=port, + account=account, + path=blob_path, + sas=account_sas, ) def generate_cloud_conn_str( account: str, - private: bool, account_key: Optional[str] = None, account_sas: Optional[str] = None, ) -> str: @@ -131,10 +120,7 @@ def generate_cloud_conn_str( return "Please provide your storage account key or SAS token" protocol = "DefaultEndpointsProtocol=https;" - if private: - endpoint = f"BlobEndpoint=https://{account}.privatelink.blob.core.windows.net;" - else: - endpoint = f"BlobEndpoint=https://{account}.blob.core.windows.net;" + endpoint = f"BlobEndpoint=https://{account}.blob.core.windows.net;" if account_key: credential = f"AccountName={account};AccountKey={account_key};" @@ -146,23 +132,19 @@ def generate_cloud_conn_str( def generate_cloud_sas_url( account: str, account_sas: str, - private: bool, blob_path: Optional[str] = None, ) -> str: """ generate a SAS url for an edge gateway device interacting with a cloud storage account """ - link = "privatelink.blob" if private else "blob" if not blob_path: - return "https://{account}.{link}.core.windows.net?{sas}".format( + return "https://{account}.blob.core.windows.net?{sas}".format( account=account, - link=link, sas=account_sas, ) - return "https://{account}.{link}.core.windows.net/{path}?{sas}".format( + return "https://{account}.blob.core.windows.net/{path}?{sas}".format( account=account, - link=link, path=blob_path, sas=account_sas, ) diff --git a/iot-storage-client/iot/storage/client/_version.py b/iot-storage-client/iot/storage/client/_version.py index 90b3199..0327641 100644 --- a/iot-storage-client/iot/storage/client/_version.py +++ b/iot-storage-client/iot/storage/client/_version.py @@ -1,3 +1,3 @@ -VERSION = "1.2.0" +VERSION = "1.2.1" __version__ = VERSION