From b3badee40ef6fc8f7d79f25d3c66761828ad5df5 Mon Sep 17 00:00:00 2001 From: antisch Date: Fri, 30 Apr 2021 11:10:16 -0700 Subject: [PATCH 1/5] Renamed account_url to endpoint --- sdk/tables/azure-data-tables/CHANGELOG.md | 2 + sdk/tables/azure-data-tables/README.md | 8 ++-- .../azure/data/tables/_base_client.py | 15 +------ .../azure/data/tables/_models.py | 16 +++----- .../azure/data/tables/_table_client.py | 34 +++++++--------- .../data/tables/_table_service_client.py | 36 ++++++++++------- .../data/tables/aio/_base_client_async.py | 4 +- .../azure/data/tables/aio/_models.py | 16 +++----- .../data/tables/aio/_table_client_async.py | 37 ++++++++--------- .../tables/aio/_table_service_client_async.py | 31 +++++--------- .../sample_authentication_async.py | 8 ++-- .../async_samples/sample_batching_async.py | 4 +- .../sample_create_client_async.py | 6 +-- .../sample_create_delete_table_async.py | 6 +-- .../sample_insert_delete_entities_async.py | 6 +-- .../async_samples/sample_query_table_async.py | 4 +- .../sample_query_tables_async.py | 4 +- ...mple_update_upsert_merge_entities_async.py | 4 +- .../samples/sample_authentication.py | 10 ++--- .../samples/sample_batching.py | 4 +- .../samples/sample_create_client.py | 8 ++-- .../samples/sample_create_delete_table.py | 4 +- .../samples/sample_insert_delete_entities.py | 6 +-- .../samples/sample_query_table.py | 4 +- .../samples/sample_query_tables.py | 4 +- .../sample_update_upsert_merge_entities.py | 4 +- .../azure-data-tables/tests/test_table.py | 40 +++++++++---------- .../tests/test_table_async.py | 28 ++++++------- .../tests/test_table_client.py | 10 ++--- .../tests/test_table_client_async.py | 8 ++-- .../tests/test_table_client_cosmos.py | 32 +++++++-------- .../tests/test_table_client_cosmos_async.py | 6 +-- .../tests/test_table_cosmos_async.py | 2 +- 33 files changed, 191 insertions(+), 220 deletions(-) diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index ab83820aad4a..0b9723b27f21 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -2,6 +2,7 @@ ## 12.0.0b7 (Unreleased) **Breaking** +* The `account_url` parameter in the client constructors has been renamed to `endpoint`. * Removed explicit `LinearRetry` and `ExponentialRetry` in favor of keyword parameter. * Renamed `filter` parameter in query APIs to `query_filter`. * The `location_mode` attribute on clients is now read-only. This has been added as a keyword parameter to the constructor. @@ -10,6 +11,7 @@ * `TableClient.send_batch` has been renamed to `TableClient.submit_transaction`. * Removed `BatchTransactionResult` object in favor of returning an iterable of batched entities with returned metadata. * `BatchErrorException` has been renamed to `TableTransactionError`. +* The `location_mode` is no longer a public attribute on the Clients. **Fixes** * Fixed issue with Cosmos merge operations. diff --git a/sdk/tables/azure-data-tables/README.md b/sdk/tables/azure-data-tables/README.md index 54835ee1b459..373d415e0ae5 100644 --- a/sdk/tables/azure-data-tables/README.md +++ b/sdk/tables/azure-data-tables/README.md @@ -29,7 +29,7 @@ pip install --pre azure-data-tables The Azure Data Tables library allows you to interact with two types of resources: * the tables in your account * the entities within those tables. -Interaction with these resources starts with an instance of a [client](#clients). To create a client object, you will need the account's table service endpoint URL and a credential that allows you to access the account. The `account_url` can be found on the page for your storage account in the [Azure Portal][azure_portal_account_url] under the "Access Keys" section or by running the following Azure CLI command: +Interaction with these resources starts with an instance of a [client](#clients). To create a client object, you will need the account's table service endpoint URL and a credential that allows you to access the account. The `endpoint` can be found on the page for your storage account in the [Azure Portal][azure_portal_account_url] under the "Access Keys" section or by running the following Azure CLI command: ```bash # Get the table service URL for the account @@ -39,7 +39,7 @@ az storage account show -n mystorageaccount -g MyResourceGroup --query "primaryE Once you have the account URL, it can be used to create the service client: ```python from azure.data.tables import TableServiceClient -service = TableServiceClient(account_url="https://.table.core.windows.net/", credential=credential) +service = TableServiceClient(endpoint="https://.table.core.windows.net/", credential=credential) ``` For more information about table service URL's and how to configure custom domain names for Azure Storage check out the [official documentation][azure_portal_account_url] @@ -60,7 +60,7 @@ az storage account keys list -g MyResourceGroup -n MyStorageAccount Use the key as the credential parameter to authenticate the client: ```python from azure.data.tables import TableServiceClient - service = TableServiceClient(account_url="https://.table.core.windows.net", credential="") + service = TableServiceClient(endpoint="https://.table.core.windows.net", credential="") ``` ##### Creating the client from a connection string @@ -93,7 +93,7 @@ To use a [shared access signature (SAS) token][azure_sas_token], provide the tok expiry=datetime.utcnow() + timedelta(hours=1) ) - table_service_client = TableServiceClient(account_url="https://.table.core.windows.net", credential=sas_token) + table_service_client = TableServiceClient(endpoint="https://.table.core.windows.net", credential=sas_token) ``` diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py index ed64fb1fe34b..79040e308208 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_base_client.py @@ -188,17 +188,6 @@ def _secondary_hostname(self): """ return self._hosts[LocationMode.SECONDARY] - @property - def location_mode(self): - """The location mode that the client is currently using. - - By default this will be "primary". Options include "primary" and "secondary". - - :type: str - """ - - return self._location_mode - @property def api_version(self): """The version of the Storage API used for requests. @@ -212,12 +201,12 @@ class TablesBaseClient(AccountHostsMixin): def __init__( self, - account_url, # type: str + endpoint, # type: str credential=None, # type: str **kwargs # type: Any ): # type: (...) -> None - super(TablesBaseClient, self).__init__(account_url, credential=credential, **kwargs) + super(TablesBaseClient, self).__init__(endpoint, credential=credential, **kwargs) self._client = AzureTable( self.url, policies=kwargs.pop('policies', self._policies), diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_models.py b/sdk/tables/azure-data-tables/azure/data/tables/_models.py index 758e3789e13f..da63f65e5db3 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_models.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_models.py @@ -281,8 +281,6 @@ class TablePropertiesPaged(PageIterator): :keyword str filter: The filter to apply to results. :keyword str select: The select filter to apply to results. :keyword str continuation_token: An opaque continuation token. - :keyword str location_mode: The location mode being used to list results. The available - options include "primary" and "secondary". """ def __init__(self, command, **kwargs): @@ -297,7 +295,7 @@ def __init__(self, command, **kwargs): self.results_per_page = kwargs.get("results_per_page") self.filter = kwargs.get("filter") self.select = kwargs.get("select") - self.location_mode = None + self._location_mode = None def _get_next_cb(self, continuation_token, **kwargs): query_options = QueryOptions( @@ -308,13 +306,13 @@ def _get_next_cb(self, continuation_token, **kwargs): query_options=query_options, next_table_name=continuation_token or None, cls=kwargs.pop("cls", None) or _return_context_and_deserialized, - use_location=self.location_mode, + use_location=self._location_mode, ) except HttpResponseError as error: _process_table_error(error) def _extract_data_cb(self, get_next_return): - self.location_mode, self._response, self._headers = get_next_return + self._location_mode, self._response, self._headers = get_next_return props_list = [ TableItem._from_generated(t, **self._headers) for t in self._response.value # pylint: disable=protected-access ] @@ -330,8 +328,6 @@ class TableEntityPropertiesPaged(PageIterator): :keyword str filter: The filter to apply to results. :keyword str select: The select filter to apply to results. :keyword str continuation_token: An opaque continuation token. - :keyword str location_mode: The location mode being used to list results. The available - options include "primary" and "secondary". """ def __init__(self, command, table, **kwargs): @@ -347,7 +343,7 @@ def __init__(self, command, table, **kwargs): self.results_per_page = kwargs.get("results_per_page") self.filter = kwargs.get("filter") self.select = kwargs.get("select") - self.location_mode = None + self._location_mode = None def _get_next_cb(self, continuation_token, **kwargs): next_partition_key, next_row_key = _extract_continuation_token( @@ -363,13 +359,13 @@ def _get_next_cb(self, continuation_token, **kwargs): next_partition_key=next_partition_key, table=self.table, cls=kwargs.pop("cls", None) or _return_context_and_deserialized, - use_location=self.location_mode, + use_location=self._location_mode, ) except HttpResponseError as error: _process_table_error(error) def _extract_data_cb(self, get_next_return): - self.location_mode, self._response, self._headers = get_next_return + self._location_mode, self._response, self._headers = get_next_return props_list = [_convert_to_entity(t) for t in self._response.value] next_entity = {} if self._headers[NEXT_PARTITION_KEY] or self._headers[NEXT_ROW_KEY]: diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py index d88ea7e2357b..e20fd434c78e 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py @@ -41,14 +41,16 @@ class TableClient(TablesBaseClient): - """ - :ivar str account_name: Name of the storage account (Cosmos or Azure) - :ivar str table_name: The name of the table + """A client to interact with a specific Table in an Azure Tables account. + + :ivar str account_name: The name of the Tables account. + :ivar str table_name: The name of the table. + :ivar str url: The full URL to the Tables account. """ def __init__( self, - account_url, # type: str + endpoint, # type: str table_name, # type: str credential=None, # type: str **kwargs # type: Any @@ -56,11 +58,8 @@ def __init__( # type: (...) -> None """Create TableClient from a Credential. - :param account_url: - A url to an Azure Storage account. - :type account_url: str - :param table_name: The table name. - :type table_name: str + :param str endpoint: A URL to an Azure Tables account. + :param str table_name: The table name. :param credential: The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared @@ -74,7 +73,7 @@ def __init__( raise ValueError("Please specify a table name.") _validate_table_name(table_name) self.table_name = table_name - super(TableClient, self).__init__(account_url, credential=credential, **kwargs) + super(TableClient, self).__init__(endpoint, credential=credential, **kwargs) def _format_url(self, hostname): """Format the endpoint URL according to the current location @@ -92,11 +91,8 @@ def from_connection_string( # type: (...) -> TableClient """Create TableClient from a Connection String. - :param conn_str: - A connection string to an Azure Storage or Cosmos account. - :type conn_str: str - :param table_name: The table name. - :type table_name: str + :param str conn_str: A connection string to an Azure Tables account. + :param str table_name: The table name. :returns: A table client. :rtype: :class:`~azure.data.tables.TableClient` @@ -109,10 +105,10 @@ def from_connection_string( :dedent: 8 :caption: Authenticating a TableServiceClient from a connection_string """ - account_url, credential = parse_connection_str( + endpoint, credential = parse_connection_str( conn_str=conn_str, credential=None, keyword_args=kwargs ) - return cls(account_url, table_name=table_name, credential=credential, **kwargs) + return cls(endpoint, table_name=table_name, credential=credential, **kwargs) @classmethod def from_table_url(cls, table_url, credential=None, **kwargs): @@ -142,7 +138,7 @@ def from_table_url(cls, table_url, credential=None, **kwargs): account_path = "" if len(table_path) > 1: account_path = "/" + "/".join(table_path[:-1]) - account_url = "{}://{}{}?{}".format( + endpoint = "{}://{}{}?{}".format( parsed_url.scheme, parsed_url.netloc.rstrip("/"), account_path, @@ -153,7 +149,7 @@ def from_table_url(cls, table_url, credential=None, **kwargs): raise ValueError( "Invalid URL. Please provide a URL with a valid table name" ) - return cls(account_url, table_name=table_name, credential=credential, **kwargs) + return cls(endpoint, table_name=table_name, credential=credential, **kwargs) @distributed_trace def get_table_access_policy( diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py index c80e1c54d238..9dfdcf3e4c34 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py @@ -26,18 +26,26 @@ class TableServiceClient(TablesBaseClient): - """Create TableServiceClient from a Credential. - - :param account_url: - A url to an Azure Storage account. - :type account_url: str - :param credential: - The credentials with which to authenticate. This is optional if the - account URL already has a SAS token, or the connection string already has shared - access key values. The value can be a SAS token string or an account shared access - key. - :type credential: str - :returns: None + """A client to interact with the Table Service at the account level. + + This client provides operations to retrieve and configure the account properties + as well as list, create and delete tables within the account. + For operations relating to a specific table, a client for this entity + can be retrieved using the :func:`~get_table_client` function. + + :ivar str account_name: The name of the Tables account. + :ivar str url: The full URL to the Tables account. + :param str endpoint: + The URL to the table service endpoint. Any other entities included + in the URL path (e.g. table) will be discarded. This URL can be optionally + authenticated with a SAS token. + :param str credential: + The credentials with which to authenticate. This is optional if the + account URL already has a SAS token. The value can be a SAS token string, an account + shared access key. + :keyword str api_version: + The Storage API version to use for requests. Default value is '2019-02-02'. + Setting to an older version may result in reduced feature compatibility. .. admonition:: Example: @@ -83,10 +91,10 @@ def from_connection_string( :dedent: 8 :caption: Authenticating a TableServiceClient from a connection_string """ - account_url, credential = parse_connection_str( + endpoint, credential = parse_connection_str( conn_str=conn_str, credential=None, keyword_args=kwargs ) - return cls(account_url, credential=credential, **kwargs) + return cls(endpoint, credential=credential, **kwargs) @distributed_trace def get_service_stats(self, **kwargs): diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py index 800d46aeba5d..d633c1b29a80 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py @@ -40,12 +40,12 @@ class AsyncTablesBaseClient(AccountHostsMixin): def __init__( self, - account_url, # type: str + endpoint, # type: str credential=None, # type: str **kwargs # type: Any ): # type: (...) -> None - super(AsyncTablesBaseClient, self).__init__(account_url, credential=credential, **kwargs) + super(AsyncTablesBaseClient, self).__init__(endpoint, credential=credential, **kwargs) self._client = AzureTable( self.url, policies=kwargs.pop('policies', self._policies), diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py index d300978542c5..bb5249c4deaf 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py @@ -25,8 +25,6 @@ class TablePropertiesPaged(AsyncPageIterator): :keyword str filter: The filter to apply to results. :keyword str select: The select filter to apply to results. :keyword str continuation_token: An opaque continuation token. - :keyword str location_mode: The location mode being used to list results. The available - options include "primary" and "secondary". """ def __init__(self, command, **kwargs): @@ -41,7 +39,7 @@ def __init__(self, command, **kwargs): self.results_per_page = kwargs.get("results_per_page") self.filter = kwargs.get("filter") self.select = kwargs.get("select") - self.location_mode = None + self._location_mode = None async def _get_next_cb(self, continuation_token, **kwargs): query_options = QueryOptions( @@ -52,13 +50,13 @@ async def _get_next_cb(self, continuation_token, **kwargs): query_options=query_options, next_table_name=continuation_token or None, cls=kwargs.pop("cls", None) or _return_context_and_deserialized, - use_location=self.location_mode, + use_location=self._location_mode, ) except HttpResponseError as error: _process_table_error(error) async def _extract_data_cb(self, get_next_return): - self.location_mode, self._response, self._headers = get_next_return + self._location_mode, self._response, self._headers = get_next_return props_list = [ TableItem._from_generated(t, **self._headers) for t in self._response.value # pylint: disable=protected-access ] @@ -74,8 +72,6 @@ class TableEntityPropertiesPaged(AsyncPageIterator): :keyword str filter: The filter to apply to results. :keyword str select: The select filter to apply to results. :keyword str continuation_token: An opaque continuation token. - :keyword str location_mode: The location mode being used to list results. The available - options include "primary" and "secondary". """ def __init__(self, command, table, **kwargs): @@ -91,7 +87,7 @@ def __init__(self, command, table, **kwargs): self.results_per_page = kwargs.get("results_per_page") self.filter = kwargs.get("filter") self.select = kwargs.get("select") - self.location_mode = None + self._location_mode = None async def _get_next_cb(self, continuation_token, **kwargs): next_partition_key, next_row_key = _extract_continuation_token( @@ -107,13 +103,13 @@ async def _get_next_cb(self, continuation_token, **kwargs): next_partition_key=next_partition_key, table=self.table, cls=kwargs.pop("cls", _return_context_and_deserialized), - use_location=self.location_mode, + use_location=self._location_mode, ) except HttpResponseError as error: _process_table_error(error) async def _extract_data_cb(self, get_next_return): - self.location_mode, self._response, self._headers = get_next_return + self._location_mode, self._response, self._headers = get_next_return props_list = [_convert_to_entity(t) for t in self._response.value] next_entity = {} if self._headers[NEXT_PARTITION_KEY] or self._headers[NEXT_ROW_KEY]: diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py index a771860a508e..9aca316f9d71 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py @@ -34,25 +34,24 @@ class TableClient(AsyncTablesBaseClient): - """ - :ivar str account_name: Name of the storage account (Cosmos or Azure) - :ivar str table_name: The name of the table + """A client to interact with a specific Table in an Azure Tables account. + + :ivar str account_name: The name of the Tables account. + :ivar str table_name: The name of the table. + :ivar str url: The full URL to the Tables account. """ def __init__( self, - account_url: str, + endpoint: str, table_name: str, credential: Optional[Union[AzureSasCredential]] = None, **kwargs ) -> None: """Create TableClient from a Credential. - :param account_url: - A url to an Azure Storage account. - :type account_url: str - :param table_name: The table name. - :type table_name: str + :param str endpoint: A URL to an Azure Tables account. + :param str table_name: The table name. :param credential: The credentials with which to authenticate. This is optional if the account URL already has a SAS token, or the connection string already has shared @@ -66,7 +65,7 @@ def __init__( raise ValueError("Please specify a table name.") _validate_table_name(table_name) self.table_name = table_name - super(TableClient, self).__init__(account_url, credential=credential, **kwargs) + super(TableClient, self).__init__(endpoint, credential=credential, **kwargs) def _format_url(self, hostname): """Format the endpoint URL according to the current location @@ -83,11 +82,8 @@ def from_connection_string( ) -> 'TableClient': """Create TableClient from a Connection string. - :param conn_str: - A connection string to an Azure Storage or Cosmos account. - :type conn_str: str - :param table_name: The table name. - :type table_name: str + :param str conn_str: A connection string to an Azure Tables account. + :param str table_name: The table name. :returns: A table client. :rtype: :class:`~azure.data.tables.TableClient` @@ -100,10 +96,10 @@ def from_connection_string( :dedent: 8 :caption: Creating the TableClient from a connection string. """ - account_url, credential = parse_connection_str( + endpoint, credential = parse_connection_str( conn_str=conn_str, credential=None, keyword_args=kwargs ) - return cls(account_url, table_name=table_name, credential=credential, **kwargs) + return cls(endpoint, table_name=table_name, credential=credential, **kwargs) @classmethod def from_table_url( @@ -114,8 +110,7 @@ def from_table_url( ) -> 'TableClient': """A client to interact with a specific Table. - :param table_url: The full URI to the table, including SAS token if used. - :type table_url: str + :param str table_url: The full URI to the table, including SAS token if used. :param credential: The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, an account @@ -138,7 +133,7 @@ def from_table_url( account_path = "" if len(table_path) > 1: account_path = "/" + "/".join(table_path[:-1]) - account_url = "{}://{}{}?{}".format( + endpoint = "{}://{}{}?{}".format( parsed_url.scheme, parsed_url.netloc.rstrip("/"), account_path, @@ -149,7 +144,7 @@ def from_table_url( raise ValueError( "Invalid URL. Please provide a URL with a valid table name" ) - return cls(account_url, table_name=table_name, credential=credential, **kwargs) + return cls(endpoint, table_name=table_name, credential=credential, **kwargs) @distributed_trace_async async def get_table_access_policy(self, **kwargs) -> Mapping[str, AccessPolicy]: diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py index ea880e900406..b29a6f11fe05 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py @@ -36,7 +36,9 @@ class TableServiceClient(AsyncTablesBaseClient): For operations relating to a specific table, a client for this entity can be retrieved using the :func:`~get_table_client` function. - :param str account_url: + :ivar str account_name: The name of the Tables account. + :ivar str url: The full URL to the Tables account. + :param str endpoint: The URL to the table service endpoint. Any other entities included in the URL path (e.g. table) will be discarded. This URL can be optionally authenticated with a SAS token. @@ -45,16 +47,8 @@ class TableServiceClient(AsyncTablesBaseClient): account URL already has a SAS token. The value can be a SAS token string, an account shared access key. :keyword str api_version: - The Storage API version to use for requests. Default value is '2019-07-07'. + The Storage API version to use for requests. Default value is '2019-02-02'. Setting to an older version may result in reduced feature compatibility. - :keyword str secondary_hostname: - The hostname of the secondary endpoint. - :param credential: - The credentials with which to authenticate. This is optional if the - account URL already has a SAS token, or the connection string already has shared - access key values. The value can be a SAS token string or an account shared access - key. - :type credential: str .. admonition:: Example: @@ -80,16 +74,11 @@ def _format_url(self, hostname): return "{}://{}{}".format(self.scheme, hostname, self._query_str) @classmethod - def from_connection_string( - cls, - conn_str, # type: any - **kwargs # type: Any - ): # type: (...) -> TableServiceClient + def from_connection_string(cls, conn_str, **kwargs): + # type: (str, Any) -> TableServiceClient """Create TableServiceClient from a Connection String. - :param conn_str: - A connection string to an Azure Storage or Cosmos account. - :type conn_str: str + :param str conn_str: A connection string to an Azure Tables account. :returns: A Table service client. :rtype: :class:`~azure.data.tables.aio.TableServiceClient` @@ -103,14 +92,14 @@ def from_connection_string( :caption: Creating the tableServiceClient from a connection string """ - account_url, credential = parse_connection_str( + endpoint, credential = parse_connection_str( conn_str=conn_str, credential=None, keyword_args=kwargs ) - return cls(account_url, credential=credential, **kwargs) + return cls(endpoint, credential=credential, **kwargs) @distributed_trace_async async def get_service_stats(self, **kwargs): - # type: (...) -> dict[str,object] + # type: (Any) -> dict[str,object] """Retrieves statistics related to replication for the Table service. It is only available on the secondary location endpoint when read-access geo-redundant replication is enabled for the account. diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py index c29e6233cdb2..7ea8394ba5a3 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py @@ -21,7 +21,7 @@ Set the environment variables with your own values before running the sample: 1) AZURE_STORAGE_CONNECTION_STRING - the connection string to your storage account - 2) AZURE_STORAGE_ACCOUNT_URL - the Table service account URL + 2) AZURE_STORAGE_ENDPOINT_SUFFIX - the Table service account URL 3) AZURE_STORAGE_ACCOUNT_NAME - the name of the storage account 4) AZURE_STORAGE_ACCESS_KEY - the storage account access key """ @@ -39,9 +39,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, @@ -82,7 +82,7 @@ async def authentication_by_shared_access_signature(self): expiry=datetime.utcnow() + timedelta(hours=1) ) - async with TableServiceClient(account_url=self.account_url, credential=sas_token) as token_auth_table_service: + async with TableServiceClient(endpoint=self.endpoint, credential=sas_token) as token_auth_table_service: properties = await token_auth_table_service.get_service_properties() print("Shared Access Signature: {}".format(properties)) # [END auth_by_sas] diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py index 3398f740c83f..fdeb4d4889af 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py @@ -34,9 +34,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py index 6ba620eca67b..45d730debd9f 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py @@ -21,7 +21,7 @@ Set the environment variables with your own values before running the sample: 1) AZURE_STORAGE_CONNECTION_STRING - the connection string to your storage account - 2) AZURE_STORAGE_ACCOUNT_URL - the Table service account URL + 2) AZURE_STORAGE_ENDPOINT_SUFFIX - the Table service account URL 3) AZURE_STORAGE_ACCOUNT_NAME - the name of the storage account 4) AZURE_STORAGE_ACCESS_KEY - the storage account access key """ @@ -39,9 +39,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py index 614c04c17e8e..acc28dde7688 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py @@ -18,7 +18,7 @@ Set the environment variables with your own values before running the sample: 1) AZURE_STORAGE_CONNECTION_STRING - the connection string to your storage account - 2) AZURE_STORAGE_ACCOUNT_URL - the Table service account URL + 2) AZURE_STORAGE_ENDPOINT_SUFFIX - the Table service account URL 3) AZURE_STORAGE_ACCOUNT_NAME - the name of the storage account 4) AZURE_STORAGE_ACCESS_KEY - the storage account access key """ @@ -35,9 +35,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py index 1fa6febf5e0f..ec3923cb523f 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py @@ -31,9 +31,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, @@ -75,7 +75,7 @@ async def delete_entity(self): from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError from azure.core import MatchConditions - table_client = TableClient(account_url=self.account_url, credential=self.access_key, table_name=self.table_name) + table_client = TableClient(endpoint=self.endpoint, credential=self.access_key, table_name=self.table_name) # [START delete_entity] async with table_client: diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py index 5bee5fb21b69..d0a9b7781e09 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py @@ -32,9 +32,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py index 7417d8b6fdea..d658fd80e9d8 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py @@ -30,9 +30,9 @@ class QueryTables(object): def __init__(self): load_dotenv(find_dotenv()) self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py index e27e87404f18..cca6b44320cf 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py @@ -31,9 +31,9 @@ class TableEntitySamples(object): def __init__(self): load_dotenv(find_dotenv()) self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/sample_authentication.py b/sdk/tables/azure-data-tables/samples/sample_authentication.py index 97e7fe161b6e..0e0207217e21 100644 --- a/sdk/tables/azure-data-tables/samples/sample_authentication.py +++ b/sdk/tables/azure-data-tables/samples/sample_authentication.py @@ -21,7 +21,7 @@ Set the environment variables with your own values before running the sample: 1) AZURE_STORAGE_CONNECTION_STRING - the connection string to your storage account - 2) AZURE_STORAGE_ACCOUNT_URL - the Table service account URL + 2) AZURE_STORAGE_ENDPOINT_SUFFIX - the Table service account URL suffix 3) AZURE_STORAGE_ACCOUNT_NAME - the name of the storage account 4) AZURE_STORAGE_ACCESS_KEY - the storage account access key """ @@ -38,9 +38,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, @@ -60,7 +60,7 @@ def authentication_by_shared_key(self): # Instantiate a TableServiceClient using a shared access key # [START auth_from_shared_key] from azure.data.tables import TableServiceClient - with TableServiceClient(account_url=self.account_url, credential=self.access_key) as table_service: + with TableServiceClient(endpoint=self.endpoint, credential=self.access_key) as table_service: properties = table_service.get_service_properties() print("Shared Key: {}".format(properties)) # [END auth_from_shared_key] @@ -82,7 +82,7 @@ def authentication_by_shared_access_signature(self): expiry=datetime.utcnow() + timedelta(hours=1) ) - with TableServiceClient(account_url=self.account_url, credential=sas_token) as token_auth_table_service: + with TableServiceClient(endpoint=self.endpoint, credential=sas_token) as token_auth_table_service: properties = token_auth_table_service.get_service_properties() print("Shared Access Signature: {}".format(properties)) # [END auth_from_sas] diff --git a/sdk/tables/azure-data-tables/samples/sample_batching.py b/sdk/tables/azure-data-tables/samples/sample_batching.py index 24fb23510e0b..53d2ede94450 100644 --- a/sdk/tables/azure-data-tables/samples/sample_batching.py +++ b/sdk/tables/azure-data-tables/samples/sample_batching.py @@ -33,9 +33,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/sample_create_client.py b/sdk/tables/azure-data-tables/samples/sample_create_client.py index a2560a2d2e3b..e25baed8edea 100644 --- a/sdk/tables/azure-data-tables/samples/sample_create_client.py +++ b/sdk/tables/azure-data-tables/samples/sample_create_client.py @@ -17,7 +17,7 @@ Set the environment variables with your own values before running the sample: 1) AZURE_STORAGE_CONNECTION_STRING - the connection string to your storage account - 2) AZURE_STORAGE_ACCOUNT_URL - the Table service account URL + 2) AZURE_STORAGE_ENDPOINT_SUFFIX - the Table service account URL suffix 3) AZURE_STORAGE_ACCOUNT_NAME - the name of the storage account 4) AZURE_STORAGE_ACCESS_KEY - the storage account access key """ @@ -32,9 +32,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, @@ -54,7 +54,7 @@ def create_table_service_client(self): # Instantiate a TableServiceClient using a shared access key # [START create_table_service_client] from azure.data.tables import TableServiceClient - with TableServiceClient(account_url=self.account_url, credential=self.access_key) as table_service: + with TableServiceClient(endpoint=self.endpoint, credential=self.access_key) as table_service: properties = table_service.get_service_properties() print("Properties: {}".format(properties)) # [END create_table_service_client] diff --git a/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py b/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py index 55d917e52887..ffcc3a42fc0d 100644 --- a/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py +++ b/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py @@ -29,9 +29,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py index e9f8bb833e04..cbf382981a4b 100644 --- a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py @@ -29,9 +29,9 @@ def __init__(self): load_dotenv(find_dotenv()) # self.connection_string = os.getenv("AZURE_TABLES_CONNECTION_STRING") self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = u"DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, @@ -72,7 +72,7 @@ def delete_entity(self): from azure.core.exceptions import ResourceNotFoundError, ResourceExistsError from azure.core import MatchConditions - with TableClient(account_url=self.account_url, credential=self.access_key, table_name=self.table_name) as table_client: + with TableClient(endpoint=self.endpoint, credential=self.access_key, table_name=self.table_name) as table_client: # Create entity to delete (to showcase etag) try: diff --git a/sdk/tables/azure-data-tables/samples/sample_query_table.py b/sdk/tables/azure-data-tables/samples/sample_query_table.py index c07cb4d9be3b..f56d24d7c056 100644 --- a/sdk/tables/azure-data-tables/samples/sample_query_table.py +++ b/sdk/tables/azure-data-tables/samples/sample_query_table.py @@ -30,9 +30,9 @@ class SampleTablesQuery(object): def __init__(self): load_dotenv(find_dotenv()) self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/sample_query_tables.py b/sdk/tables/azure-data-tables/samples/sample_query_tables.py index f741978f61da..124c23a97d28 100644 --- a/sdk/tables/azure-data-tables/samples/sample_query_tables.py +++ b/sdk/tables/azure-data-tables/samples/sample_query_tables.py @@ -29,9 +29,9 @@ class QueryTables(object): def __init__(self): load_dotenv(find_dotenv()) self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py b/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py index a8df0bf82d36..49a167e9a3c5 100644 --- a/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py @@ -30,9 +30,9 @@ class TableEntitySamples(object): def __init__(self): load_dotenv(find_dotenv()) self.access_key = os.getenv("TABLES_PRIMARY_STORAGE_ACCOUNT_KEY") - self.endpoint = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") + self.endpoint_suffix = os.getenv("TABLES_STORAGE_ENDPOINT_SUFFIX") self.account_name = os.getenv("TABLES_STORAGE_ACCOUNT_NAME") - self.account_url = "{}.table.{}".format(self.account_name, self.endpoint) + self.endpoint = "{}.table.{}".format(self.account_name, self.endpoint_suffix) self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, diff --git a/sdk/tables/azure-data-tables/tests/test_table.py b/sdk/tables/azure-data-tables/tests/test_table.py index 90cce3deb7ba..f16b310e47d3 100644 --- a/sdk/tables/azure-data-tables/tests/test_table.py +++ b/sdk/tables/azure-data-tables/tests/test_table.py @@ -87,7 +87,7 @@ def _delete_all_tables(self, ts): def test_create_properties(self, tables_storage_account_name, tables_primary_storage_account_key): # # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() # Act created = ts.create_table(table_name) @@ -110,7 +110,7 @@ def test_create_properties(self, tables_storage_account_name, tables_primary_sto def test_create_table(self, tables_storage_account_name, tables_primary_storage_account_key): # # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() @@ -125,7 +125,7 @@ def test_create_table(self, tables_storage_account_name, tables_primary_storage_ def test_create_table_fail_on_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() # Act @@ -144,7 +144,7 @@ def test_create_table_fail_on_exist(self, tables_storage_account_name, tables_pr def test_query_tables_per_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = "mytable" @@ -175,7 +175,7 @@ def test_query_tables_per_page(self, tables_storage_account_name, tables_primary @TablesPreparer() def test_create_table_if_exists(self, tables_storage_account_name, tables_primary_storage_account_key): account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() t0 = ts.create_table(table_name) @@ -189,7 +189,7 @@ def test_create_table_if_exists(self, tables_storage_account_name, tables_primar @TablesPreparer() def test_create_table_if_exists_new_table(self, tables_storage_account_name, tables_primary_storage_account_key): account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() t = ts.create_table_if_not_exists(table_name) @@ -202,7 +202,7 @@ def test_create_table_if_exists_new_table(self, tables_storage_account_name, tab def test_query_tables(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) t = self._create_table(ts) # Act @@ -224,7 +224,7 @@ def test_query_tables(self, tables_storage_account_name, tables_primary_storage_ def test_query_tables_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) t = self._create_table(ts) # Act @@ -249,7 +249,7 @@ def test_query_tables_with_num_results(self, tables_storage_account_name, tables # Arrange prefix = 'listtable' account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_list = [] for i in range(0, 4): self._create_table(ts, prefix + str(i), table_list) @@ -277,7 +277,7 @@ def test_query_tables_with_num_results(self, tables_storage_account_name, tables def test_query_tables_with_marker(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) prefix = 'listtable' table_names = [] for i in range(0, 4): @@ -307,7 +307,7 @@ def test_query_tables_with_marker(self, tables_storage_account_name, tables_prim def test_delete_table_with_existing_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = self._create_table(ts) # Act @@ -322,7 +322,7 @@ def test_delete_table_with_existing_table(self, tables_storage_account_name, tab def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() # Act @@ -334,7 +334,7 @@ def test_get_table_acl(self, tables_storage_account_name, tables_primary_storage # Arrange url = self.account_url(tables_storage_account_name, "table") account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = self._create_table(ts) try: # Act @@ -351,7 +351,7 @@ def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_accoun # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = self._create_table(ts) try: @@ -370,7 +370,7 @@ def test_set_table_acl_with_empty_signed_identifier(self, tables_storage_account # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = self._create_table(ts) try: @@ -392,7 +392,7 @@ def test_set_table_acl_with_signed_identifiers(self, tables_storage_account_name # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = self._create_table(ts) client = ts.get_table_client(table_name=table.table_name) @@ -417,7 +417,7 @@ def test_set_table_acl_too_many_ids(self, tables_storage_account_name, tables_pr # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = self._create_table(ts) try: @@ -439,7 +439,7 @@ def test_account_sas(self, tables_storage_account_name, tables_primary_storage_a # Arrange account_url = self.account_url(tables_storage_account_name, "table") - tsc = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + tsc = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = self._create_table(tsc) try: @@ -464,7 +464,7 @@ def test_account_sas(self, tables_storage_account_name, tables_primary_storage_a account_url = self.account_url(tables_storage_account_name, "table") - service = self.create_client_from_credential(TableServiceClient, token, account_url=account_url) + service = self.create_client_from_credential(TableServiceClient, token, endpoint=account_url) # Act @@ -527,6 +527,6 @@ def test_azurite_url(self): assert tsc.account_name == "my_account" assert tsc.url == "https://127.0.0.1:10002/my_account" - assert tsc.location_mode == "primary" + assert tsc._location_mode == "primary" assert tsc.credential.account_key == self.tables_primary_storage_account_key assert tsc.credential.account_name == "my_account" \ No newline at end of file diff --git a/sdk/tables/azure-data-tables/tests/test_table_async.py b/sdk/tables/azure-data-tables/tests/test_table_async.py index 8003b1b57c74..739b6fb9747c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_async.py @@ -56,7 +56,7 @@ async def _delete_table(self, ts, table): async def test_create_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() @@ -71,7 +71,7 @@ async def test_create_table(self, tables_storage_account_name, tables_primary_st async def test_create_table_fail_on_exist(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() # Act @@ -90,7 +90,7 @@ async def test_create_table_fail_on_exist(self, tables_storage_account_name, tab async def test_query_tables_per_page(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = "myasynctable" @@ -119,7 +119,7 @@ async def test_query_tables_per_page(self, tables_storage_account_name, tables_p async def test_list_tables(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = await self._create_table(ts) # Act @@ -140,7 +140,7 @@ async def test_list_tables(self, tables_storage_account_name, tables_primary_sto async def test_query_tables_with_filter(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = await self._create_table(ts) # Act @@ -163,7 +163,7 @@ async def test_list_tables_with_num_results(self, tables_storage_account_name, t # Arrange prefix = 'listtable' account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) # Delete any existing tables async for table in ts.list_tables(): @@ -189,7 +189,7 @@ async def test_list_tables_with_num_results(self, tables_storage_account_name, t async def test_list_tables_with_marker(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) prefix = 'listtable' table_names = [] for i in range(0, 4): @@ -222,7 +222,7 @@ async def test_list_tables_with_marker(self, tables_storage_account_name, tables async def test_delete_table_with_existing_table(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = await self._create_table(ts) # Act @@ -239,7 +239,7 @@ async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_ tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table_name = self._get_table_reference() # Act @@ -252,7 +252,7 @@ async def test_delete_table_with_non_existing_table_fail_not_exist(self, tables_ async def test_get_table_acl(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = await self._create_table(ts) try: @@ -269,7 +269,7 @@ async def test_get_table_acl(self, tables_storage_account_name, tables_primary_s async def test_set_table_acl_with_empty_signed_identifiers(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange account_url = self.account_url(tables_storage_account_name, "table") - ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + ts = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = await self._create_table(ts) try: @@ -353,7 +353,7 @@ async def test_account_sas(self, tables_storage_account_name, tables_primary_sto # Arrange account_url = self.account_url(tables_storage_account_name, "table") - tsc = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, account_url=account_url) + tsc = self.create_client_from_credential(TableServiceClient, tables_primary_storage_account_key, endpoint=account_url) table = await self._create_table(tsc) try: @@ -378,7 +378,7 @@ async def test_account_sas(self, tables_storage_account_name, tables_primary_sto account_url = self.account_url(tables_storage_account_name, "table") - service = self.create_client_from_credential(TableServiceClient, token, account_url=account_url) + service = self.create_client_from_credential(TableServiceClient, token, endpoint=account_url) # Act sas_table = service.get_table_client(table.table_name) @@ -445,6 +445,6 @@ def test_azurite_url(self): assert tsc.account_name == "my_account" assert tsc.url == "https://127.0.0.1:10002/my_account" - assert tsc.location_mode == "primary" + assert tsc._location_mode == "primary" assert tsc.credential.account_key == self.tables_primary_storage_account_key assert tsc.credential.account_name == "my_account" diff --git a/sdk/tables/azure-data-tables/tests/test_table_client.py b/sdk/tables/azure-data-tables/tests/test_table_client.py index af993338e060..bfaa736c31ba 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -195,7 +195,7 @@ def test_create_service_empty_key(self): # test non-string account URL with pytest.raises(ValueError): - test_service = service_type(account_url=123456, credential=self.tables_primary_storage_account_key, table_name='foo') + test_service = service_type(endpoint=123456, credential=self.tables_primary_storage_account_key, table_name='foo') assert str(e.value) == "You need to provide either a SAS token or an account shared key to authenticate." @@ -398,13 +398,13 @@ def test_create_service_with_custom_account_endpoint_path(self): assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' - service = TableServiceClient(account_url=custom_account_url) + service = TableServiceClient(endpoint=custom_account_url) assert service.account_name == "custom" assert service.credential == None assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') - service = TableClient(account_url=custom_account_url, table_name="foo") + service = TableClient(endpoint=custom_account_url, table_name="foo") assert service.account_name == "custom" assert service.table_name == "foo" assert service.credential == None @@ -431,7 +431,7 @@ def test_create_table_client_with_complete_table_url(self): def test_create_table_client_with_complete_url(self): # Arrange table_url = "https://{}.table.core.windows.net:443/foo".format(self.tables_storage_account_name) - service = TableClient(account_url=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(endpoint=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) # Assert assert service.scheme == 'https' @@ -445,7 +445,7 @@ def test_create_table_client_with_invalid_name(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") + service = TableClient(endpoint=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long." in str(excinfo) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_async.py index f989d2df8a27..fe5f26e5dee2 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_async.py @@ -427,13 +427,13 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): assert service.credential.account_key == self.tables_primary_storage_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' - service = TableServiceClient(account_url=custom_account_url) + service = TableServiceClient(endpoint=custom_account_url) assert service.account_name == "custom" assert service.credential == None assert service._primary_hostname == 'local-machine:11002/custom/account/path' assert service.url.startswith('http://local-machine:11002/custom/account/path') - service = TableClient(account_url=custom_account_url, table_name="foo") + service = TableClient(endpoint=custom_account_url, table_name="foo") assert service.account_name == "custom" assert service.table_name == "foo" assert service.credential == None @@ -462,7 +462,7 @@ async def test_create_table_client_with_complete_table_url_async(self): async def test_create_table_client_with_complete_url_async(self): # Arrange table_url = "https://{}.table.core.windows.net:443/foo".format(self.tables_storage_account_name) - service = TableClient(account_url=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) + service = TableClient(endpoint=table_url, table_name='bar', credential=self.tables_primary_storage_account_key) # Assert assert service.scheme == 'https' @@ -477,7 +477,7 @@ async def test_create_table_client_with_invalid_name_async(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") + service = TableClient(endpoint=table_url, table_name=invalid_table_name, credential="self.tables_primary_storage_account_key") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long."in str(excinfo) diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py index 8d8da85ef85c..84730d016d2c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos.py @@ -98,7 +98,7 @@ def callback(response): def test_user_agent_append(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): service = self.create_client_from_credential( TableServiceClient, - account_url=self.account_url(tables_cosmos_account_name, "cosmos"), + endpoint=self.account_url(tables_cosmos_account_name, "cosmos"), credential=tables_primary_cosmos_account_key) def callback(response): @@ -139,7 +139,7 @@ def test_create_service_with_key(self): for client, url in SERVICES.items(): # Act service = client( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.tables_primary_cosmos_account_key, table_name='foo') @@ -153,7 +153,7 @@ def test_create_service_with_connection_string(self): for client, url in SERVICES.items(): # Act service = client( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.tables_primary_cosmos_account_key, table_name="test") @@ -169,7 +169,7 @@ def test_create_service_with_sas(self): for service_type in SERVICES: # Act service = service_type( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.sas_token, table_name="foo") @@ -186,7 +186,7 @@ def test_create_service_with_token(self): for service_type in SERVICES: # Act service = service_type( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.tables_primary_cosmos_account_key, table_name="foo") @@ -204,7 +204,7 @@ def test_create_service_with_token_and_http(self): with pytest.raises(ValueError): url = self.account_url(self.tables_cosmos_account_name, "cosmos").replace('https', 'http') service = service_type( - account_url=url, + endpoint=url, credential=self.token_credential, table_name="foo") @@ -227,7 +227,7 @@ def test_create_service_protocol(self): for service_type in SERVICES: # Act service = service_type( - account_url=url, + endpoint=url, credential=self.tables_primary_cosmos_account_key, table_name="foo") @@ -252,11 +252,11 @@ def test_create_service_with_socket_timeout(self): for service_type in SERVICES.items(): # Act default_service = service_type[0]( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.tables_primary_cosmos_account_key, table_name="foo") service = service_type[0]( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.tables_primary_cosmos_account_key, table_name="foo", connection_timeout=22) @@ -438,14 +438,14 @@ def test_create_service_with_custom_account_endpoint_path(self): assert service.credential.account_key == self.tables_primary_cosmos_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' - service = TableServiceClient(account_url=custom_account_url) + service = TableServiceClient(endpoint=custom_account_url) assert service.account_name == "custom" assert service.credential == None assert service._primary_hostname == 'local-machine:11002/custom/account/path' # mine doesnt have a question mark at the end assert service.url.startswith('http://local-machine:11002/custom/account/path') - service = TableClient(account_url=custom_account_url, table_name="foo") + service = TableClient(endpoint=custom_account_url, table_name="foo") assert service.account_name == "custom" assert service.table_name == "foo" assert service.credential == None @@ -463,7 +463,7 @@ def test_create_table_client_with_complete_table_url(self): # Arrange table_url = self._account_url(self.tables_cosmos_account_name) + "/foo" service = TableClient( - account_url=table_url, + endpoint=table_url, credential=self.tables_primary_cosmos_account_key, table_name="bar") @@ -477,7 +477,7 @@ def test_create_table_client_with_complete_url(self): # Arrange table_url = "https://{}.table.cosmos.azure.com:443/foo".format(self.tables_cosmos_account_name) service = TableClient( - account_url=table_url, + endpoint=table_url, credential=self.tables_primary_cosmos_account_key, table_name="bar") @@ -493,7 +493,7 @@ def test_create_table_client_with_invalid_name(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_cosmos_account_key") + service = TableClient(endpoint=table_url, table_name=invalid_table_name, credential="self.tables_primary_cosmos_account_key") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long." in str(excinfo) @@ -516,7 +516,7 @@ def test_closing_pipeline_client(self): for client, url in SERVICES.items(): # Act service = client( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.tables_primary_cosmos_account_key, table_name='table') @@ -531,7 +531,7 @@ def test_closing_pipeline_client_simple(self): for client, url in SERVICES.items(): # Act service = client( - account_url=self._account_url(self.tables_cosmos_account_name), + endpoint=self._account_url(self.tables_cosmos_account_name), credential=self.tables_primary_cosmos_account_key, table_name='table') diff --git a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py index 8952b69490f7..abbed3d18b31 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client_cosmos_async.py @@ -429,14 +429,14 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): assert service.credential.account_key == self.tables_primary_cosmos_account_key assert service._primary_hostname == 'local-machine:11002/custom/account/path' - service = TableServiceClient(account_url=custom_account_url) + service = TableServiceClient(endpoint=custom_account_url) assert service.account_name == "custom" assert service.credential == None assert service._primary_hostname == 'local-machine:11002/custom/account/path' # mine doesnt have a question mark at the end assert service.url.startswith('http://local-machine:11002/custom/account/path') - service = TableClient(account_url=custom_account_url, table_name="foo") + service = TableClient(endpoint=custom_account_url, table_name="foo") assert service.account_name == "custom" assert service.table_name == "foo" assert service.credential == None @@ -480,7 +480,7 @@ async def test_create_table_client_with_invalid_name_async(self): # Assert with pytest.raises(ValueError) as excinfo: - service = TableClient(account_url=table_url, table_name=invalid_table_name, credential="self.tables_primary_cosmos_account_key") + service = TableClient(endpoint=table_url, table_name=invalid_table_name, credential="self.tables_primary_cosmos_account_key") assert "Table names must be alphanumeric, cannot begin with a number, and must be between 3-63 characters long.""" in str(excinfo) diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py index 72f53706d89d..2cd539aa77b3 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py @@ -99,7 +99,7 @@ async def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tabl async def test_query_tables_per_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange # account_url = self.account_url(tables_cosmos_account_name, "table") - # ts = self.create_client_from_credential(TableServiceClient, tables_primary_cosmos_account_key, account_url=account_url) + # ts = self.create_client_from_credential(TableServiceClient, tables_primary_cosmos_account_key, endpoint=account_url) ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) table_name = "myasynctable" From 7aaec0eea49b9951b2878d4154161b1fe578b3f4 Mon Sep 17 00:00:00 2001 From: antisch Date: Fri, 30 Apr 2021 11:19:36 -0700 Subject: [PATCH 2/5] Removed select from list tables --- .../azure-data-tables/azure/data/tables/_models.py | 6 +----- .../azure/data/tables/_table_service_client.py | 12 ------------ .../azure/data/tables/aio/_models.py | 6 +----- .../data/tables/aio/_table_service_client_async.py | 12 ------------ 4 files changed, 2 insertions(+), 34 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_models.py b/sdk/tables/azure-data-tables/azure/data/tables/_models.py index da63f65e5db3..06cbbcdefceb 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_models.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_models.py @@ -279,7 +279,6 @@ class TablePropertiesPaged(PageIterator): :param callable command: Function to retrieve the next page of items. :keyword int results_per_page: The maximum number of results retrieved per API call. :keyword str filter: The filter to apply to results. - :keyword str select: The select filter to apply to results. :keyword str continuation_token: An opaque continuation token. """ @@ -294,13 +293,10 @@ def __init__(self, command, **kwargs): self._response = None self.results_per_page = kwargs.get("results_per_page") self.filter = kwargs.get("filter") - self.select = kwargs.get("select") self._location_mode = None def _get_next_cb(self, continuation_token, **kwargs): - query_options = QueryOptions( - top=self.results_per_page, select=self.select, filter=self.filter - ) + query_options = QueryOptions(top=self.results_per_page, filter=self.filter) try: return self._command( query_options=query_options, diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py index 9dfdcf3e4c34..186d37999f59 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py @@ -267,8 +267,6 @@ def query_tables( :param str query_filter: Specify a filter to return certain tables. :keyword int results_per_page: Number of tables per page in return ItemPaged - :keyword select: Specify desired properties of a table to return certain tables - :paramtype select: str or List[str] :keyword Dict[str, str] parameters: Dictionary for formatting query with additional, user defined parameters :return: ItemPaged[:class:`~azure.data.tables.TableItem`] :rtype: ~azure.core.paging.ItemPaged @@ -288,16 +286,12 @@ def query_tables( parameters, query_filter ) top = kwargs.pop("results_per_page", None) - user_select = kwargs.pop("select", None) - if user_select and not isinstance(user_select, str): - user_select = ", ".join(user_select) command = functools.partial(self._client.table.query, **kwargs) return ItemPaged( command, results_per_page=top, filter=query_filter, - select=user_select, page_iterator_class=TablePropertiesPaged, ) @@ -307,8 +301,6 @@ def list_tables(self, **kwargs): """Queries tables under the given account. :keyword int results_per_page: Number of tables per page in return ItemPaged - :keyword select: Specify desired properties of a table to return certain tables - :paramtype select: str or List[str] :return: ItemPaged[:class:`~azure.data.tables.TableItem`] :rtype: ~azure.core.paging.ItemPaged :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -322,16 +314,12 @@ def list_tables(self, **kwargs): :dedent: 8 :caption: Listing all tables in a storage account """ - user_select = kwargs.pop("select", None) - if user_select and not isinstance(user_select, str): - user_select = ", ".join(user_select) top = kwargs.pop("results_per_page", None) command = functools.partial(self._client.table.query, **kwargs) return ItemPaged( command, results_per_page=top, - select=user_select, page_iterator_class=TablePropertiesPaged, ) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py index bb5249c4deaf..1a27a24ddea4 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_models.py @@ -23,7 +23,6 @@ class TablePropertiesPaged(AsyncPageIterator): :param callable command: Function to retrieve the next page of items. :keyword int results_per_page: The maximum number of results retrieved per API call. :keyword str filter: The filter to apply to results. - :keyword str select: The select filter to apply to results. :keyword str continuation_token: An opaque continuation token. """ @@ -38,13 +37,10 @@ def __init__(self, command, **kwargs): self._response = None self.results_per_page = kwargs.get("results_per_page") self.filter = kwargs.get("filter") - self.select = kwargs.get("select") self._location_mode = None async def _get_next_cb(self, continuation_token, **kwargs): - query_options = QueryOptions( - top=self.results_per_page, select=self.select, filter=self.filter - ) + query_options = QueryOptions(top=self.results_per_page, filter=self.filter) try: return await self._command( query_options=query_options, diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py index b29a6f11fe05..718e0a531cf2 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py @@ -264,8 +264,6 @@ def list_tables( """Queries tables under the given account. :keyword int results_per_page: Number of tables per page in return ItemPaged - :keyword select: Specify desired properties of a table to return certain tables - :paramtype select: str or List[str] :return: AsyncItemPaged[:class:`~azure.data.tables.TableItem`] :rtype: ~azure.core.async_paging.AsyncItemPaged :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -279,16 +277,12 @@ def list_tables( :dedent: 8 :caption: Listing all tables in an account """ - user_select = kwargs.pop("select", None) - if user_select and not isinstance(user_select, str): - user_select = ", ".join(user_select) top = kwargs.pop("results_per_page", None) command = functools.partial(self._client.table.query, **kwargs) return AsyncItemPaged( command, results_per_page=top, - select=user_select, page_iterator_class=TablePropertiesPaged, ) @@ -303,8 +297,6 @@ def query_tables( :param str query_filter: Specify a filter to return certain tables. :keyword int results_per_page: Number of tables per page in return ItemPaged - :keyword select: Specify desired properties of a table to return certain tables - :paramtype select: str or List[str] :keyword Dict[str, Any] parameters: Dictionary for formatting query with additional, user defined parameters :return: AsyncItemPaged[:class:`~azure.data.tables.TableItem`] :rtype: ~azure.core.async_paging.AsyncItemPaged @@ -323,15 +315,11 @@ def query_tables( query_filter = _parameter_filter_substitution( parameters, query_filter ) - user_select = kwargs.pop("select", None) - if user_select and not isinstance(user_select, str): - user_select = ", ".join(user_select) top = kwargs.pop("results_per_page", None) command = functools.partial(self._client.table.query, **kwargs) return AsyncItemPaged( command, results_per_page=top, - select=user_select, filter=query_filter, page_iterator_class=TablePropertiesPaged, ) From 3f41a473c2ba4eee9b112e8d8db4b905b518b2ac Mon Sep 17 00:00:00 2001 From: antisch Date: Fri, 30 Apr 2021 13:32:13 -0700 Subject: [PATCH 3/5] Added select to get_entity --- sdk/tables/azure-data-tables/CHANGELOG.md | 1 + .../azure/data/tables/_table_client.py | 18 +- .../data/tables/aio/_table_client_async.py | 19 +- ...le_entity.test_get_entity_with_select.yaml | 235 +++++++++++++++++ ...ity_async.test_get_entity_with_select.yaml | 137 +++++++--- ...ty_cosmos.test_get_entity_with_select.yaml | 243 ++++++++++++++++++ ...mos_async.test_get_entity_with_select.yaml | 165 ++++++++++++ .../tests/test_table_entity.py | 21 ++ .../tests/test_table_entity_async.py | 21 ++ .../tests/test_table_entity_cosmos.py | 21 ++ .../tests/test_table_entity_cosmos_async.py | 21 ++ 11 files changed, 855 insertions(+), 47 deletions(-) create mode 100644 sdk/tables/azure-data-tables/tests/recordings/test_table_entity.test_get_entity_with_select.yaml create mode 100644 sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos.test_get_entity_with_select.yaml create mode 100644 sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos_async.test_get_entity_with_select.yaml diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index 0b9723b27f21..17428da37fa3 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -21,6 +21,7 @@ * Added support for Azurite storage emulator * Throws a `RequestTooLargeError` on transaction requests that return a 413 error code * Added support for Int64 and Binary types in query filters +* Added support for `select` keyword parameter to `TableClient.get_entity()`. ## 12.0.0b6 (2021-04-06) * Updated deserialization of datetime fields in entities to support preservation of the service format with additional decimal place. diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py index e20fd434c78e..da5e9252e322 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py @@ -22,6 +22,7 @@ from ._generated.models import ( SignedIdentifier, TableProperties, + QueryOptions ) from ._serialize import _get_match_headers, _add_entity_properties from ._base_client import parse_connection_str, TablesBaseClient @@ -439,8 +440,8 @@ def list_entities( # type: (...) -> ItemPaged[TableEntity] """Lists entities in a table. - :keyword int results_per_page: Number of entities per page in return ItemPaged - :keyword select: Specify desired properties of an entity to return certain entities + :keyword int results_per_page: Number of entities returned per service request. + :keyword select: Specify desired properties of an entity to return. :paramtype select: str or List[str] :return: ItemPaged[:class:`~azure.data.tables.TableEntity`] :rtype: ~azure.core.paging.ItemPaged @@ -479,8 +480,8 @@ def query_entities( """Lists entities in a table. :param str query_filter: Specify a filter to return certain entities - :keyword int results_per_page: Number of entities per page in return ItemPaged - :keyword select: Specify desired properties of an entity to return certain entities + :keyword int results_per_page: Number of entities returned per service request. + :keyword select: Specify desired properties of an entity to return. :paramtype select: str or List[str] :keyword Dict[str, Any] parameters: Dictionary for formatting query with additional, user defined parameters :return: ItemPaged[:class:`~azure.data.tables.TableEntity`] @@ -503,7 +504,7 @@ def query_entities( top = kwargs.pop("results_per_page", None) user_select = kwargs.pop("select", None) if user_select and not isinstance(user_select, str): - user_select = ", ".join(user_select) + user_select = ",".join(user_select) command = functools.partial(self._client.table.query_entities, **kwargs) return ItemPaged( @@ -529,6 +530,8 @@ def get_entity( :type partition_key: str :param row_key: The row key of the entity. :type row_key: str + :keyword select: Specify desired properties of an entity to return. + :paramtype select: str or List[str] :return: Dictionary mapping operation metadata returned from the service :rtype: :class:`~azure.data.tables.TableEntity` :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -542,14 +545,17 @@ def get_entity( :dedent: 8 :caption: Get a single entity from a table """ + user_select = kwargs.pop("select", None) + if user_select and not isinstance(user_select, str): + user_select = ",".join(user_select) try: entity = self._client.table.query_entity_with_partition_and_row_key( table=self.table_name, partition_key=partition_key, row_key=row_key, + query_options=QueryOptions(select=user_select), **kwargs ) - properties = _convert_to_entity(entity) return properties except HttpResponseError as error: diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py index 9aca316f9d71..131fef5ae332 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py @@ -19,7 +19,7 @@ from .._base_client import parse_connection_str from .._entity import TableEntity -from .._generated.models import SignedIdentifier, TableProperties +from .._generated.models import SignedIdentifier, TableProperties, QueryOptions from .._models import AccessPolicy from .._serialize import serialize_iso, _parameter_filter_substitution from .._deserialize import _return_headers_and_deserialized @@ -421,8 +421,8 @@ async def update_entity( def list_entities(self, **kwargs) -> AsyncItemPaged[TableEntity]: """Lists entities in a table. - :keyword int results_per_page: Number of entities per page in return AsyncItemPaged - :keyword select: Specify desired properties of an entity to return certain entities + :keyword int results_per_page: Number of entities returned per service request. + :keyword select: Specify desired properties of an entity to return. :paramtype select: str or List[str] :return: AsyncItemPaged[:class:`~azure.data.tables.TableEntity`] :rtype: ~azure.core.async_paging.AsyncItemPaged @@ -460,8 +460,8 @@ def query_entities( """Lists entities in a table. :param str query_filter: Specify a filter to return certain entities - :keyword int results_per_page: Number of entities per page in return AsyncItemPaged - :keyword select: Specify desired properties of an entity to return certain entities + :keyword int results_per_page: Number of entities returned per service request. + :keyword select: Specify desired properties of an entity to return. :paramtype select: str or List[str] :keyword Dict[str, Any] parameters: Dictionary for formatting query with additional, user defined parameters :return: AsyncItemPaged[:class:`~azure.data.tables.TableEntity`] @@ -484,7 +484,7 @@ def query_entities( top = kwargs.pop("results_per_page", None) user_select = kwargs.pop("select", None) if user_select and not isinstance(user_select, str): - user_select = ", ".join(user_select) + user_select = ",".join(user_select) command = functools.partial(self._client.table.query_entities, **kwargs) return AsyncItemPaged( @@ -509,6 +509,8 @@ async def get_entity( :type partition_key: str :param row_key: The row key of the entity. :type row_key: str + :keyword select: Specify desired properties of an entity to return. + :paramtype select: str or List[str] :return: Dictionary mapping operation metadata returned from the service :rtype: :class:`~azure.data.tables.TableEntity` :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -522,14 +524,17 @@ async def get_entity( :dedent: 8 :caption: Getting an entity from PartitionKey and RowKey """ + user_select = kwargs.pop("select", None) + if user_select and not isinstance(user_select, str): + user_select = ",".join(user_select) try: entity = await self._client.table.query_entity_with_partition_and_row_key( table=self.table_name, partition_key=partition_key, row_key=row_key, + query_options=QueryOptions(select=user_select), **kwargs ) - properties = _convert_to_entity(entity) return properties except HttpResponseError as error: diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_entity.test_get_entity_with_select.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity.test_get_entity_with_select.yaml new file mode 100644 index 000000000000..33373c0917c0 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity.test_get_entity_with_select.yaml @@ -0,0 +1,235 @@ +interactions: +- request: + body: '{"TableName": "uttableabfa12a7"}' + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '32' + Content-Type: + - application/json;odata=nometadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:21 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:21 GMT + x-ms-version: + - '2019-02-02' + method: POST + uri: https://fake_table_account.table.core.windows.net/Tables + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables/@Element","TableName":"uttableabfa12a7"}' + headers: + cache-control: + - no-cache + content-type: + - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: + - Fri, 30 Apr 2021 20:28:21 GMT + location: + - https://fake_table_account.table.core.windows.net/Tables('uttableabfa12a7') + server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-content-type-options: + - nosniff + x-ms-version: + - '2019-02-02' + status: + code: 201 + message: Created +- request: + body: '{"PartitionKey": "pkabfa12a7", "PartitionKey@odata.type": "Edm.String", + "RowKey": "rkabfa12a7", "RowKey@odata.type": "Edm.String", "age": 39, "sex": + "male", "sex@odata.type": "Edm.String", "married": true, "deceased": false, + "ratio": 3.1, "evenratio": 3.0, "large": 933311100, "Birthday": "1973-10-04T00:00:00.000000Z", + "Birthday@odata.type": "Edm.DateTime", "birthday": "1970-10-04T00:00:00.000000Z", + "birthday@odata.type": "Edm.DateTime", "binary": "YmluYXJ5", "binary@odata.type": + "Edm.Binary", "other": 20, "clsid": "c9da6455-213d-42c9-9a79-3e9149a57833", + "clsid@odata.type": "Edm.Guid"}' + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '591' + Content-Type: + - application/json;odata=nometadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:22 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:22 GMT + x-ms-version: + - '2019-02-02' + method: POST + uri: https://fake_table_account.table.core.windows.net/uttableabfa12a7 + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttableabfa12a7/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A22.0848481Z''\"","PartitionKey":"pkabfa12a7","RowKey":"rkabfa12a7","Timestamp":"2021-04-30T20:28:22.0848481Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' + headers: + cache-control: + - no-cache + content-type: + - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: + - Fri, 30 Apr 2021 20:28:21 GMT + etag: + - W/"datetime'2021-04-30T20%3A28%3A22.0848481Z'" + location: + - https://fake_table_account.table.core.windows.net/uttableabfa12a7(PartitionKey='pkabfa12a7',RowKey='rkabfa12a7') + server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-content-type-options: + - nosniff + x-ms-version: + - '2019-02-02' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:22 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:22 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/uttableabfa12a7(PartitionKey='pkabfa12a7',RowKey='rkabfa12a7')?$select=age%2Cratio + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttableabfa12a7/@Element&$select=age,ratio","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A22.0848481Z''\"","age":39,"ratio":3.1}' + headers: + cache-control: + - no-cache + content-type: + - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: + - Fri, 30 Apr 2021 20:28:21 GMT + etag: + - W/"datetime'2021-04-30T20%3A28%3A22.0848481Z'" + server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-content-type-options: + - nosniff + x-ms-version: + - '2019-02-02' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:22 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:22 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/uttableabfa12a7(PartitionKey='pkabfa12a7',RowKey='rkabfa12a7')?$select=age%2Cratio + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttableabfa12a7/@Element&$select=age,ratio","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A22.0848481Z''\"","age":39,"ratio":3.1}' + headers: + cache-control: + - no-cache + content-type: + - application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: + - Fri, 30 Apr 2021 20:28:21 GMT + etag: + - W/"datetime'2021-04-30T20%3A28%3A22.0848481Z'" + server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + x-content-type-options: + - nosniff + x-ms-version: + - '2019-02-02' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Fri, 30 Apr 2021 20:28:22 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:22 GMT + x-ms-version: + - '2019-02-02' + method: DELETE + uri: https://fake_table_account.table.core.windows.net/Tables('uttableabfa12a7') + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 30 Apr 2021 20:28:21 GMT + server: + - Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + x-content-type-options: + - nosniff + x-ms-version: + - '2019-02-02' + status: + code: 204 + message: No Content +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_async.test_get_entity_with_select.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_async.test_get_entity_with_select.yaml index b3be2e1559d4..f70efcb16349 100644 --- a/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_async.test_get_entity_with_select.yaml +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_async.test_get_entity_with_select.yaml @@ -11,36 +11,37 @@ interactions: DataServiceVersion: - '3.0' Date: - - Fri, 24 Jul 2020 15:12:18 GMT + - Fri, 30 Apr 2021 20:28:22 GMT User-Agent: - - azsdk-python-storage-table/2019-07-07 Python/3.8.4 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 24 Jul 2020 15:12:18 GMT + - Fri, 30 Apr 2021 20:28:22 GMT x-ms-version: - - '2019-07-07' + - '2019-02-02' method: POST - uri: https://storagename.table.core.windows.net/Tables + uri: https://fake_table_account.table.core.windows.net/Tables response: body: - string: '{"odata.metadata":"https://storagename.table.core.windows.net/$metadata#Tables/@Element","TableName":"uttable25221524"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables/@Element","TableName":"uttable25221524"}' headers: cache-control: no-cache content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 - date: Fri, 24 Jul 2020 15:12:18 GMT - location: https://storagename.table.core.windows.net/Tables('uttable25221524') + date: Fri, 30 Apr 2021 20:28:21 GMT + location: https://fake_table_account.table.core.windows.net/Tables('uttable25221524') server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-content-type-options: nosniff - x-ms-version: '2019-07-07' + x-ms-version: '2019-02-02' status: code: 201 message: Created - url: https://pyacrstoragerbrqrhumwwkw.table.core.windows.net/Tables + url: https://seankaneprim.table.core.windows.net/Tables - request: - body: '{"PartitionKey": "pk25221524", "RowKey": "rk25221524", "age": "39", "age@odata.type": - "Edm.Int64", "sex": "male", "married": true, "deceased": false, "ratio": 3.1, - "evenratio": 3.0, "large": "933311100", "large@odata.type": "Edm.Int64", "Birthday": - "1973-10-04T00:00:00Z", "Birthday@odata.type": "Edm.DateTime", "birthday": "1970-10-04T00:00:00Z", + body: '{"PartitionKey": "pk25221524", "PartitionKey@odata.type": "Edm.String", + "RowKey": "rk25221524", "RowKey@odata.type": "Edm.String", "age": 39, "sex": + "male", "sex@odata.type": "Edm.String", "married": true, "deceased": false, + "ratio": 3.1, "evenratio": 3.0, "large": 933311100, "Birthday": "1973-10-04T00:00:00.000000Z", + "Birthday@odata.type": "Edm.DateTime", "birthday": "1970-10-04T00:00:00.000000Z", "birthday@odata.type": "Edm.DateTime", "binary": "YmluYXJ5", "binary@odata.type": "Edm.Binary", "other": 20, "clsid": "c9da6455-213d-42c9-9a79-3e9149a57833", "clsid@odata.type": "Edm.Guid"}' @@ -48,63 +49,131 @@ interactions: Accept: - application/json;odata=minimalmetadata Content-Length: - - '537' + - '591' Content-Type: - application/json;odata=nometadata DataServiceVersion: - '3.0' Date: - - Fri, 24 Jul 2020 15:12:18 GMT + - Fri, 30 Apr 2021 20:28:22 GMT User-Agent: - - azsdk-python-storage-table/2019-07-07 Python/3.8.4 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 24 Jul 2020 15:12:18 GMT + - Fri, 30 Apr 2021 20:28:22 GMT x-ms-version: - - '2019-07-07' + - '2019-02-02' method: POST - uri: https://storagename.table.core.windows.net/uttable25221524 + uri: https://fake_table_account.table.core.windows.net/uttable25221524 response: body: - string: '{"odata.metadata":"https://storagename.table.core.windows.net/$metadata#uttable25221524/@Element","odata.etag":"W/\"datetime''2020-07-24T15%3A12%3A19.0328764Z''\"","PartitionKey":"pk25221524","RowKey":"rk25221524","Timestamp":"2020-07-24T15:12:19.0328764Z","age@odata.type":"Edm.Int64","age":"39","sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large@odata.type":"Edm.Int64","large":"933311100","Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable25221524/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A22.2785076Z''\"","PartitionKey":"pk25221524","RowKey":"rk25221524","Timestamp":"2021-04-30T20:28:22.2785076Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}' headers: cache-control: no-cache content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 - date: Fri, 24 Jul 2020 15:12:18 GMT - etag: W/"datetime'2020-07-24T15%3A12%3A19.0328764Z'" - location: https://storagename.table.core.windows.net/uttable25221524(PartitionKey='pk25221524',RowKey='rk25221524') + date: Fri, 30 Apr 2021 20:28:21 GMT + etag: W/"datetime'2021-04-30T20%3A28%3A22.2785076Z'" + location: https://fake_table_account.table.core.windows.net/uttable25221524(PartitionKey='pk25221524',RowKey='rk25221524') server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: chunked x-content-type-options: nosniff - x-ms-version: '2019-07-07' + x-ms-version: '2019-02-02' status: code: 201 message: Created - url: https://pyacrstoragerbrqrhumwwkw.table.core.windows.net/uttable25221524 + url: https://seankaneprim.table.core.windows.net/uttable25221524 - request: body: null headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:22 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:22 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/uttable25221524(PartitionKey='pk25221524',RowKey='rk25221524')?$select=age,ratio + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable25221524/@Element&$select=age,ratio","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A22.2785076Z''\"","age":39,"ratio":3.1}' + headers: + cache-control: no-cache + content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: Fri, 30 Apr 2021 20:28:21 GMT + etag: W/"datetime'2021-04-30T20%3A28%3A22.2785076Z'" + server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-content-type-options: nosniff + x-ms-version: '2019-02-02' + status: + code: 200 + message: OK + url: https://seankaneprim.table.core.windows.net/uttable25221524(PartitionKey='pk25221524',RowKey='rk25221524')?$select=age,ratio +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:22 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:22 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_table_account.table.core.windows.net/uttable25221524(PartitionKey='pk25221524',RowKey='rk25221524')?$select=age,ratio + response: + body: + string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable25221524/@Element&$select=age,ratio","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A22.2785076Z''\"","age":39,"ratio":3.1}' + headers: + cache-control: no-cache + content-type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8 + date: Fri, 30 Apr 2021 20:28:21 GMT + etag: W/"datetime'2021-04-30T20%3A28%3A22.2785076Z'" + server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + x-content-type-options: nosniff + x-ms-version: '2019-02-02' + status: + code: 200 + message: OK + url: https://seankaneprim.table.core.windows.net/uttable25221524(PartitionKey='pk25221524',RowKey='rk25221524')?$select=age,ratio +- request: + body: null + headers: + Accept: + - application/json Date: - - Fri, 24 Jul 2020 15:12:18 GMT + - Fri, 30 Apr 2021 20:28:22 GMT User-Agent: - - azsdk-python-storage-table/2019-07-07 Python/3.8.4 (Windows-10-10.0.19041-SP0) + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) x-ms-date: - - Fri, 24 Jul 2020 15:12:18 GMT + - Fri, 30 Apr 2021 20:28:22 GMT x-ms-version: - - '2019-07-07' + - '2019-02-02' method: DELETE - uri: https://storagename.table.core.windows.net/Tables('uttable25221524') + uri: https://fake_table_account.table.core.windows.net/Tables('uttable25221524') response: body: string: '' headers: cache-control: no-cache content-length: '0' - date: Fri, 24 Jul 2020 15:12:18 GMT + date: Fri, 30 Apr 2021 20:28:21 GMT server: Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0 x-content-type-options: nosniff - x-ms-version: '2019-07-07' + x-ms-version: '2019-02-02' status: code: 204 message: No Content - url: https://pyacrstoragerbrqrhumwwkw.table.core.windows.net/Tables('uttable25221524') + url: https://seankaneprim.table.core.windows.net/Tables('uttable25221524') version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos.test_get_entity_with_select.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos.test_get_entity_with_select.yaml new file mode 100644 index 000000000000..abd497fc595c --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos.test_get_entity_with_select.yaml @@ -0,0 +1,243 @@ +interactions: +- request: + body: '{"TableName": "uttable3c13159a"}' + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '32' + Content-Type: + - application/json;odata=nometadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:22 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:22 GMT + x-ms-version: + - '2019-02-02' + method: POST + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables + response: + body: + string: '{"TableName":"uttable3c13159a","odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/$metadata#Tables/@Element"}' + headers: + content-type: + - application/json;odata=minimalmetadata + date: + - Fri, 30 Apr 2021 20:28:22 GMT + etag: + - W/"datetime'2021-04-30T20%3A28%3A22.8931592Z'" + location: + - https://fake_cosmos_account.table.cosmos.azure.com/Tables('uttable3c13159a') + server: + - Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + status: + code: 201 + message: Ok +- request: + body: '{"PartitionKey": "pk3c13159a", "PartitionKey@odata.type": "Edm.String", + "RowKey": "rk3c13159a", "RowKey@odata.type": "Edm.String", "age": 39, "sex": + "male", "sex@odata.type": "Edm.String", "married": true, "deceased": false, + "ratio": 3.1, "evenratio": 3.0, "large": 933311100, "Birthday": "1973-10-04T00:00:00.000000Z", + "Birthday@odata.type": "Edm.DateTime", "birthday": "1970-10-04T00:00:00.000000Z", + "birthday@odata.type": "Edm.DateTime", "binary": "YmluYXJ5", "binary@odata.type": + "Edm.Binary", "other": 20, "clsid": "c9da6455-213d-42c9-9a79-3e9149a57833", + "clsid@odata.type": "Edm.Guid"}' + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '591' + Content-Type: + - application/json;odata=nometadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:23 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:23 GMT + x-ms-version: + - '2019-02-02' + method: POST + uri: https://fake_cosmos_account.table.cosmos.azure.com/uttable3c13159a + response: + body: + string: '{"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/uttable3c13159a/$metadata#uttable3c13159a/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A23.3499656Z''\"","PartitionKey":"pk3c13159a","RowKey":"rk3c13159a","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00.0000000Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00.0000000Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833","Timestamp":"2021-04-30T20:28:23.3499656Z"}' + headers: + content-type: + - application/json;odata=minimalmetadata + date: + - Fri, 30 Apr 2021 20:28:22 GMT + etag: + - W/"datetime'2021-04-30T20%3A28%3A23.3499656Z'" + location: + - https://fake_cosmos_account.table.cosmos.azure.com/uttable3c13159a(PartitionKey='pk3c13159a',RowKey='rk3c13159a') + server: + - Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:23 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:23 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/uttable3c13159a(PartitionKey='pk3c13159a',RowKey='rk3c13159a')?$select=age%2Cratio + response: + body: + string: '{"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/uttable3c13159a/$metadata#uttable3c13159a/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A23.3499656Z''\"","age":39,"ratio":3.1}' + headers: + content-type: + - application/json;odata=minimalmetadata + date: + - Fri, 30 Apr 2021 20:28:22 GMT + etag: + - W/"datetime'2021-04-30T20%3A28%3A23.3499656Z'" + server: + - Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + status: + code: 200 + message: Ok +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:23 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:23 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/uttable3c13159a(PartitionKey='pk3c13159a',RowKey='rk3c13159a')?$select=age%2Cratio + response: + body: + string: '{"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/uttable3c13159a/$metadata#uttable3c13159a/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A23.3499656Z''\"","age":39,"ratio":3.1}' + headers: + content-type: + - application/json;odata=minimalmetadata + date: + - Fri, 30 Apr 2021 20:28:22 GMT + etag: + - W/"datetime'2021-04-30T20%3A28%3A23.3499656Z'" + server: + - Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + status: + code: 200 + message: Ok +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Fri, 30 Apr 2021 20:28:23 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:23 GMT + x-ms-version: + - '2019-02-02' + method: DELETE + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables('uttable3c13159a') + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Fri, 30 Apr 2021 20:28:23 GMT + server: + - Microsoft-HTTPAPI/2.0 + status: + code: 204 + message: No Content +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:23 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:23 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables + response: + body: + string: '{"value":[],"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/$metadata#Tables"}' + headers: + content-type: + - application/json;odata=minimalmetadata + date: + - Fri, 30 Apr 2021 20:28:23 GMT + server: + - Microsoft-HTTPAPI/2.0 + transfer-encoding: + - chunked + status: + code: 200 + message: Ok +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos_async.test_get_entity_with_select.yaml b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos_async.test_get_entity_with_select.yaml new file mode 100644 index 000000000000..cf7421825801 --- /dev/null +++ b/sdk/tables/azure-data-tables/tests/recordings/test_table_entity_cosmos_async.test_get_entity_with_select.yaml @@ -0,0 +1,165 @@ +interactions: +- request: + body: '{"TableName": "uttablec6de1817"}' + headers: + Accept: + - application/json;odata=minimalmetadata + Content-Length: + - '32' + Content-Type: + - application/json;odata=nometadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:53 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:53 GMT + x-ms-version: + - '2019-02-02' + method: POST + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables + response: + body: + string: '{"TableName":"uttablec6de1817","odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/$metadata#Tables/@Element"}' + headers: + content-type: application/json;odata=minimalmetadata + date: Fri, 30 Apr 2021 20:28:54 GMT + etag: W/"datetime'2021-04-30T20%3A28%3A54.1735944Z'" + location: https://fake_cosmos_account.table.cosmos.azure.com/Tables('uttablec6de1817') + server: Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + status: + code: 201 + message: Ok + url: https://seankaneprim.table.cosmos.azure.com/Tables +- request: + body: '{"PartitionKey": "pkc6de1817", "PartitionKey@odata.type": "Edm.String", + "RowKey": "rkc6de1817", "RowKey@odata.type": "Edm.String", "age": 39, "sex": + "male", "sex@odata.type": "Edm.String", "married": true, "deceased": false, + "ratio": 3.1, "evenratio": 3.0, "large": 933311100, "Birthday": "1973-10-04T00:00:00.000000Z", + "Birthday@odata.type": "Edm.DateTime", "birthday": "1970-10-04T00:00:00.000000Z", + "birthday@odata.type": "Edm.DateTime", "binary": "YmluYXJ5", "binary@odata.type": + "Edm.Binary", "other": 20, "clsid": "c9da6455-213d-42c9-9a79-3e9149a57833", + "clsid@odata.type": "Edm.Guid"}' + headers: + Accept: + - application/json;odata=minimalmetadata + Content-Length: + - '591' + Content-Type: + - application/json;odata=nometadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:54 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:54 GMT + x-ms-version: + - '2019-02-02' + method: POST + uri: https://fake_cosmos_account.table.cosmos.azure.com/uttablec6de1817 + response: + body: + string: '{"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/uttablec6de1817/$metadata#uttablec6de1817/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A54.6577416Z''\"","PartitionKey":"pkc6de1817","RowKey":"rkc6de1817","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00.0000000Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00.0000000Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833","Timestamp":"2021-04-30T20:28:54.6577416Z"}' + headers: + content-type: application/json;odata=minimalmetadata + date: Fri, 30 Apr 2021 20:28:54 GMT + etag: W/"datetime'2021-04-30T20%3A28%3A54.6577416Z'" + location: https://fake_cosmos_account.table.cosmos.azure.com/uttablec6de1817(PartitionKey='pkc6de1817',RowKey='rkc6de1817') + server: Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + status: + code: 201 + message: Created + url: https://seankaneprim.table.cosmos.azure.com/uttablec6de1817 +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:54 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:54 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/uttablec6de1817(PartitionKey='pkc6de1817',RowKey='rkc6de1817')?$select=age,ratio + response: + body: + string: '{"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/uttablec6de1817/$metadata#uttablec6de1817/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A54.6577416Z''\"","age":39,"ratio":3.1}' + headers: + content-type: application/json;odata=minimalmetadata + date: Fri, 30 Apr 2021 20:28:54 GMT + etag: W/"datetime'2021-04-30T20%3A28%3A54.6577416Z'" + server: Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + status: + code: 200 + message: Ok + url: https://seankaneprim.table.cosmos.azure.com/uttablec6de1817(PartitionKey='pkc6de1817',RowKey='rkc6de1817')?$select=age,ratio +- request: + body: null + headers: + Accept: + - application/json;odata=minimalmetadata + DataServiceVersion: + - '3.0' + Date: + - Fri, 30 Apr 2021 20:28:54 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:54 GMT + x-ms-version: + - '2019-02-02' + method: GET + uri: https://fake_cosmos_account.table.cosmos.azure.com/uttablec6de1817(PartitionKey='pkc6de1817',RowKey='rkc6de1817')?$select=age,ratio + response: + body: + string: '{"odata.metadata":"https://fake_cosmos_account.table.cosmos.azure.com/uttablec6de1817/$metadata#uttablec6de1817/@Element","odata.etag":"W/\"datetime''2021-04-30T20%3A28%3A54.6577416Z''\"","age":39,"ratio":3.1}' + headers: + content-type: application/json;odata=minimalmetadata + date: Fri, 30 Apr 2021 20:28:54 GMT + etag: W/"datetime'2021-04-30T20%3A28%3A54.6577416Z'" + server: Microsoft-HTTPAPI/2.0 + transfer-encoding: chunked + status: + code: 200 + message: Ok + url: https://seankaneprim.table.cosmos.azure.com/uttablec6de1817(PartitionKey='pkc6de1817',RowKey='rkc6de1817')?$select=age,ratio +- request: + body: null + headers: + Accept: + - application/json + Date: + - Fri, 30 Apr 2021 20:28:54 GMT + User-Agent: + - azsdk-python-data-tables/12.0.0b7 Python/3.7.4 (Windows-10-10.0.19041-SP0) + x-ms-date: + - Fri, 30 Apr 2021 20:28:54 GMT + x-ms-version: + - '2019-02-02' + method: DELETE + uri: https://fake_cosmos_account.table.cosmos.azure.com/Tables('uttablec6de1817') + response: + body: + string: '' + headers: + content-length: '0' + date: Fri, 30 Apr 2021 20:28:54 GMT + server: Microsoft-HTTPAPI/2.0 + status: + code: 204 + message: No Content + url: https://seankaneprim.table.cosmos.azure.com/Tables('uttablec6de1817') +version: 1 diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity.py b/sdk/tables/azure-data-tables/tests/test_table_entity.py index 3c1cf70af42b..3a1a505c54b2 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity.py @@ -860,6 +860,27 @@ def test_get_entity(self, tables_storage_account_name, tables_primary_storage_ac finally: self._tear_down() + @TablesPreparer() + def test_get_entity_with_select(self, tables_storage_account_name, tables_primary_storage_account_key): + # Arrange + self._set_up(tables_storage_account_name, tables_primary_storage_account_key) + try: + entity, _ = self._insert_random_entity() + + resp = self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select=['age', 'ratio']) + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + resp = self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select='age,ratio') + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + + finally: + self._tear_down() + @TablesPreparer() def test_get_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py index a95ffe8d3d40..858f2f9158ed 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_async.py @@ -591,6 +591,27 @@ async def test_get_entity(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() + @TablesPreparer() + async def test_get_entity_with_select(self, tables_storage_account_name, tables_primary_storage_account_key): + # Arrange + await self._set_up(tables_storage_account_name, tables_primary_storage_account_key) + try: + entity, _ = await self._insert_random_entity() + + resp = await self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select=['age', 'ratio']) + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + resp = await self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select='age,ratio') + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + + finally: + await self._tear_down() + @TablesPreparer() async def test_get_entity_with_hook(self, tables_storage_account_name, tables_primary_storage_account_key): # Arrange diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py index a5542c363a35..af2356743c7e 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos.py @@ -819,6 +819,27 @@ def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmos_acco self._tear_down() self.sleep(SLEEP_DELAY) + @CosmosPreparer() + def test_get_entity_with_select(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): + # Arrange + self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) + try: + entity, _ = self._insert_random_entity() + + resp = self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select=['age', 'ratio']) + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + resp = self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select='age,ratio') + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + finally: + self._tear_down() + self.sleep(SLEEP_DELAY) + @CosmosPreparer() def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange diff --git a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py index d07f496d5e6e..4c2526ed2f5a 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity_cosmos_async.py @@ -561,6 +561,27 @@ async def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmo finally: await self._tear_down() + @CosmosPreparer() + async def test_get_entity_with_select(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): + # Arrange + await self._set_up(tables_cosmos_account_name, tables_primary_cosmos_account_key) + try: + entity, _ = await self._insert_random_entity() + + resp = await self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select=['age', 'ratio']) + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + resp = await self.table.get_entity(partition_key=entity['PartitionKey'], + row_key=entity['RowKey'], + select='age,ratio') + resp.pop('_metadata', None) + assert resp == {'age': 39, 'ratio': 3.1} + + finally: + await self._tear_down() + @CosmosPreparer() async def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange From f7b68922afa3c5433b8e2cb56497ec10194e1c05 Mon Sep 17 00:00:00 2001 From: antisch Date: Fri, 30 Apr 2021 15:11:47 -0700 Subject: [PATCH 4/5] Fixed samples --- .../samples/async_samples/sample_authentication_async.py | 2 +- .../samples/async_samples/sample_batching_async.py | 2 +- .../samples/async_samples/sample_create_client_async.py | 2 +- .../samples/async_samples/sample_create_delete_table_async.py | 2 +- .../async_samples/sample_insert_delete_entities_async.py | 2 +- .../samples/async_samples/sample_query_table_async.py | 2 +- .../samples/async_samples/sample_query_tables_async.py | 2 +- .../async_samples/sample_update_upsert_merge_entities_async.py | 2 +- sdk/tables/azure-data-tables/samples/sample_authentication.py | 2 +- sdk/tables/azure-data-tables/samples/sample_batching.py | 2 +- sdk/tables/azure-data-tables/samples/sample_create_client.py | 2 +- .../azure-data-tables/samples/sample_create_delete_table.py | 2 +- .../azure-data-tables/samples/sample_insert_delete_entities.py | 2 +- sdk/tables/azure-data-tables/samples/sample_query_table.py | 2 +- sdk/tables/azure-data-tables/samples/sample_query_tables.py | 2 +- .../samples/sample_update_upsert_merge_entities.py | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py index 7ea8394ba5a3..767a85d3d85d 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py @@ -45,7 +45,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) async def authentication_by_connection_string(self): diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py index fdeb4d4889af..5d16b4b5d6aa 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py @@ -40,7 +40,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "sampleTransactionAsync" diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py index 45d730debd9f..ceeecd07d266 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_client_async.py @@ -45,7 +45,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) async def create_table_client(self): diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py index acc28dde7688..45e5b931d8cc 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py @@ -41,7 +41,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "CreateDeleteTable" diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py index ec3923cb523f..cc3ad850fc74 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py @@ -37,7 +37,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "InsertDeleteAsync" diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py index d0a9b7781e09..a909cec1d3ea 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_table_async.py @@ -38,7 +38,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "OfficeSupplies" diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py index d658fd80e9d8..492d51a3bd89 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_query_tables_async.py @@ -36,7 +36,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) async def tables_in_account(self): diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py index cca6b44320cf..af9d26461b2c 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_update_upsert_merge_entities_async.py @@ -37,7 +37,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_base = "UpdateUpsertMergeAsync" diff --git a/sdk/tables/azure-data-tables/samples/sample_authentication.py b/sdk/tables/azure-data-tables/samples/sample_authentication.py index 0e0207217e21..46c8c154a671 100644 --- a/sdk/tables/azure-data-tables/samples/sample_authentication.py +++ b/sdk/tables/azure-data-tables/samples/sample_authentication.py @@ -44,7 +44,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) def authentication_by_connection_string(self): diff --git a/sdk/tables/azure-data-tables/samples/sample_batching.py b/sdk/tables/azure-data-tables/samples/sample_batching.py index 53d2ede94450..0c92b7aa1625 100644 --- a/sdk/tables/azure-data-tables/samples/sample_batching.py +++ b/sdk/tables/azure-data-tables/samples/sample_batching.py @@ -39,7 +39,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "sampleTransaction" diff --git a/sdk/tables/azure-data-tables/samples/sample_create_client.py b/sdk/tables/azure-data-tables/samples/sample_create_client.py index e25baed8edea..e7e4155023f7 100644 --- a/sdk/tables/azure-data-tables/samples/sample_create_client.py +++ b/sdk/tables/azure-data-tables/samples/sample_create_client.py @@ -38,7 +38,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) diff --git a/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py b/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py index ffcc3a42fc0d..74bb35417686 100644 --- a/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py +++ b/sdk/tables/azure-data-tables/samples/sample_create_delete_table.py @@ -35,7 +35,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) diff --git a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py index cbf382981a4b..ee38e4adcf17 100644 --- a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py @@ -35,7 +35,7 @@ def __init__(self): self.connection_string = u"DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "SampleInsertDelete" diff --git a/sdk/tables/azure-data-tables/samples/sample_query_table.py b/sdk/tables/azure-data-tables/samples/sample_query_table.py index f56d24d7c056..84450a05f557 100644 --- a/sdk/tables/azure-data-tables/samples/sample_query_table.py +++ b/sdk/tables/azure-data-tables/samples/sample_query_table.py @@ -36,7 +36,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "SampleQueryTable" diff --git a/sdk/tables/azure-data-tables/samples/sample_query_tables.py b/sdk/tables/azure-data-tables/samples/sample_query_tables.py index 124c23a97d28..9b73c9426cfd 100644 --- a/sdk/tables/azure-data-tables/samples/sample_query_tables.py +++ b/sdk/tables/azure-data-tables/samples/sample_query_tables.py @@ -35,7 +35,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "SampleQueryTables" diff --git a/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py b/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py index 49a167e9a3c5..d7e4f42dbb44 100644 --- a/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py @@ -36,7 +36,7 @@ def __init__(self): self.connection_string = "DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "SampleUpdateUpsertMerge" From 5bb0634be1a7fa54ac738d1ee414fdddaf847233 Mon Sep 17 00:00:00 2001 From: antisch Date: Thu, 6 May 2021 10:05:01 -0700 Subject: [PATCH 5/5] Fixed service client type hints --- .../data/tables/_table_service_client.py | 53 +++++--------- .../tables/aio/_table_service_client_async.py | 70 ++++++------------- .../tests/test_table_cosmos_async.py | 2 - 3 files changed, 40 insertions(+), 85 deletions(-) diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py index 39b473dd461a..f0f32ab8872a 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py @@ -5,13 +5,13 @@ # -------------------------------------------------------------------------- import functools -from typing import Any, Union, Optional, Dict +from typing import Any, Optional, Dict, TYPE_CHECKING from azure.core.exceptions import HttpResponseError, ResourceExistsError from azure.core.paging import ItemPaged from azure.core.tracing.decorator import distributed_trace from azure.core.pipeline import Pipeline -from ._generated.models import TableProperties, TableServiceProperties +from ._generated.models import TableServiceProperties from ._models import ( TablePropertiesPaged, service_stats_deserialize, @@ -24,6 +24,9 @@ from ._table_client import TableClient from ._serialize import _parameter_filter_substitution +if TYPE_CHECKING: + from ._models import CorsRule, Metrics, TableAnalyticsLogging + class TableServiceClient(TablesBaseClient): """A client to interact with the Table Service at the account level. @@ -68,17 +71,15 @@ class TableServiceClient(TablesBaseClient): """ def _format_url(self, hostname): + # type: (str) -> str """Format the endpoint URL according to the current location mode hostname. """ return "{}://{}{}".format(self.scheme, hostname, self._query_str) @classmethod - def from_connection_string( - cls, - conn_str, # type: str - **kwargs # type: Any - ): # type: (...) -> TableServiceClient + def from_connection_string(cls, conn_str, **kwargs): + # type: (str, Any) -> TableServiceClient """Create TableServiceClient from a connection string. :param str conn_str: A connection string to an Azure Storage or Cosmos account. @@ -101,7 +102,7 @@ def from_connection_string( @distributed_trace def get_service_stats(self, **kwargs): - # type: (Dict[str, Any]) -> TableServiceStats + # type: (Any) -> Dict[str, Any] """Retrieves statistics related to replication for the Table service. It is only available on the secondary location endpoint when read-access geo-redundant replication is enabled for the account. @@ -120,7 +121,7 @@ def get_service_stats(self, **kwargs): @distributed_trace def get_service_properties(self, **kwargs): - # type: (...) -> Dict[str, Any] + # type: (Any) -> Dict[str, object] """Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -172,12 +173,8 @@ def set_service_properties( _process_table_error(error) @distributed_trace - def create_table( - self, - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> TableClient + def create_table(self, table_name, **kwargs): + # type: (str, Any) -> TableClient """Creates a new table under the current account. :param table_name: The Table name. @@ -200,12 +197,8 @@ def create_table( return table @distributed_trace - def create_table_if_not_exists( - self, - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> TableClient + def create_table_if_not_exists(self, table_name, **kwargs): + # type: (str, Any) -> TableClient """Creates a new table if it does not currently exist. If the table currently exists, the current table is returned. @@ -233,12 +226,8 @@ def create_table_if_not_exists( return table @distributed_trace - def delete_table( - self, - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def delete_table(self, table_name, **kwargs): + # type: (str, Any) -> None """Deletes the table under the current account :param table_name: The Table name. @@ -260,12 +249,8 @@ def delete_table( table.delete_table(**kwargs) @distributed_trace - def query_tables( - self, - query_filter, - **kwargs - ): - # type: (str, Dict[str, Any]) -> ItemPaged[TableItem] + def query_tables(self, query_filter, **kwargs): + # type: (str, Any) -> ItemPaged[TableItem] """Queries tables under the given account. :param str query_filter: Specify a filter to return certain tables. @@ -327,7 +312,7 @@ def list_tables(self, **kwargs): ) def get_table_client(self, table_name, **kwargs): - # type: (Union[TableProperties, str], Optional[Any]) -> TableClient + # type: (str, Any) -> TableClient """Get a client to interact with the specified table. The table need not already exist. diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py index 718e0a531cf2..3fc6f94d7295 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_service_client_async.py @@ -5,9 +5,10 @@ # -------------------------------------------------------------------------- import functools from typing import ( - Union, Optional, + Dict, Any, + TYPE_CHECKING ) from azure.core.async_paging import AsyncItemPaged @@ -27,6 +28,9 @@ from ._base_client_async import AsyncTablesBaseClient, AsyncTransportWrapper from ._models import TablePropertiesPaged +if TYPE_CHECKING: + from .._models import CorsRule, Metrics, TableAnalyticsLogging + class TableServiceClient(AsyncTablesBaseClient): """A client to interact with the Table Service at the account level. @@ -67,15 +71,14 @@ class TableServiceClient(AsyncTablesBaseClient): :caption: Creating the tableServiceClient with Shared Access Signature. """ - def _format_url(self, hostname): + def _format_url(self, hostname: str) -> str: """Format the endpoint URL according to the current location mode hostname. """ return "{}://{}{}".format(self.scheme, hostname, self._query_str) @classmethod - def from_connection_string(cls, conn_str, **kwargs): - # type: (str, Any) -> TableServiceClient + def from_connection_string(cls, conn_str: str, **kwargs) -> 'TableServiceClient': """Create TableServiceClient from a Connection String. :param str conn_str: A connection string to an Azure Tables account. @@ -98,8 +101,7 @@ def from_connection_string(cls, conn_str, **kwargs): return cls(endpoint, credential=credential, **kwargs) @distributed_trace_async - async def get_service_stats(self, **kwargs): - # type: (Any) -> dict[str,object] + async def get_service_stats(self, **kwargs) -> Dict[str, Any]: """Retrieves statistics related to replication for the Table service. It is only available on the secondary location endpoint when read-access geo-redundant replication is enabled for the account. @@ -117,8 +119,7 @@ async def get_service_stats(self, **kwargs): _process_table_error(error) @distributed_trace_async - async def get_service_properties(self, **kwargs): - # type: (...) -> dict[str,Any] + async def get_service_properties(self, **kwargs) -> Dict[str, object]: """Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -137,13 +138,12 @@ async def get_service_properties(self, **kwargs): @distributed_trace_async async def set_service_properties( self, - analytics_logging=None, # type: Optional[TableAnalyticsLogging] - hour_metrics=None, # type: Optional[Metrics] - minute_metrics=None, # type: Optional[Metrics] - cors=None, # type: Optional[CorsRule] - **kwargs # type: Any - ): - # type: (...) -> None + analytics_logging: Optional['TableAnalyticsLogging'] = None, + hour_metrics: Optional['Metrics'] = None, + minute_metrics: Optional['Metrics'] = None, + cors: Optional['CorsRule'] = None, + **kwargs + ) -> None: """Sets properties for an account's Table service endpoint, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -171,12 +171,7 @@ async def set_service_properties( _process_table_error(error) @distributed_trace_async - async def create_table( - self, - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> TableClient + async def create_table(self, table_name: str, **kwargs) -> TableClient: """Creates a new table under the given account. :param headers: @@ -199,12 +194,7 @@ async def create_table( return table @distributed_trace_async - async def create_table_if_not_exists( - self, - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> TableClient + async def create_table_if_not_exists(self, table_name: str, **kwargs) -> TableClient: """Creates a new table if it does not currently exist. If the table currently exists, the current table is returned. @@ -231,12 +221,7 @@ async def create_table_if_not_exists( return table @distributed_trace_async - async def delete_table( - self, - table_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + async def delete_table(self, table_name: str, **kwargs) -> None: """Deletes the table under the current account :param str table_name: The Table name. @@ -257,10 +242,7 @@ async def delete_table( await table.delete_table(**kwargs) @distributed_trace - def list_tables( - self, **kwargs # type: Any - ): - # type: (...) -> AsyncItemPaged[TableItem] + def list_tables(self, **kwargs) -> AsyncItemPaged[TableItem]: """Queries tables under the given account. :keyword int results_per_page: Number of tables per page in return ItemPaged @@ -287,12 +269,7 @@ def list_tables( ) @distributed_trace - def query_tables( - self, - query_filter, - **kwargs - ): - # type: (str, Dict[str, Any]) -> AsyncItemPaged[TableItem] + def query_tables(self, query_filter: str, **kwargs) -> AsyncItemPaged[TableItem]: """Queries tables under the given account. :param str query_filter: Specify a filter to return certain tables. @@ -324,12 +301,7 @@ def query_tables( page_iterator_class=TablePropertiesPaged, ) - def get_table_client( - self, - table_name, # type: str - **kwargs # type: Optional[Any] - ): - # type: (...) -> TableClient + def get_table_client(self, table_name: str, **kwargs) -> TableClient: """Get a client to interact with the specified table. The table need not already exist. diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py index 3f244d5cefc1..9e6503dd7455 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos_async.py @@ -98,8 +98,6 @@ async def test_create_table_fail_on_exist(self, tables_cosmos_account_name, tabl @cosmos_decorator_async async def test_query_tables_per_page(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange - # account_url = self.account_url(tables_cosmos_account_name, "table") - # ts = self.create_client_from_credential(TableServiceClient, tables_primary_cosmos_account_key, endpoint=account_url) ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) table_name = "myasynctable"