diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index 15cd3f2ac2b6..c05851ef9b62 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`. * The `TableEntity` object now acts exclusively like a dictionary, and no longer supports key access via attributes. * Metadata of an entity is now accessed via `TableEntity.metadata` attribute rather than a method. * Removed explicit `LinearRetry` and `ExponentialRetry` in favor of keyword parameter. @@ -12,14 +13,13 @@ * `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. * Removed Batching context-manager behavior -* Changed optional `value` and `type` arguments of `EntityProperty` to required. +* `EntityProperty` is now a NampedTuple, and can be represented by a tuple of `(entity, EdmType)`. * Renamed `EntityProperty.type` to `EntityProperty.edm_type`. * `BatchErrorException` has been renamed to `TableTransactionError`. +* The `location_mode` is no longer a public attribute on the Clients. * The only supported credentials are `AzureNamedKeyCredential`, `AzureSasCredential`, or authentication by connection string -* `EntityProperty` is now a tuple. * Removed `date` and `api_version` from the `TableItem` class. - **Fixes** * Fixed issue with Cosmos merge operations. * Removed legacy Storage policies from pipeline. @@ -28,6 +28,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()`. * On `update_entity` and `delete_entity` if no `etag` is supplied via kwargs, the `etag` in the entity will be used if it is in the entity. ## 12.0.0b6 (2021-04-06) 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 c6c23470b01f..038950f0aa35 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 4e88e50a2033..18802ec9bf0e 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_models.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_models.py @@ -279,10 +279,7 @@ 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. - :keyword str location_mode: The location mode being used to list results. The available - options include "primary" and "secondary". """ def __init__(self, command, **kwargs): @@ -296,25 +293,22 @@ 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 + 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, 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 +324,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 +339,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 +355,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 be7d9a32b31b..cad884496d07 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 @@ -41,14 +42,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: Union[AzureNamedKeyCredential, AzureSasCredential] **kwargs # type: Any @@ -56,11 +59,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 @@ -75,7 +75,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 @@ -93,11 +93,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` @@ -110,10 +107,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): @@ -143,7 +140,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, @@ -154,7 +151,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( @@ -483,8 +480,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 @@ -523,8 +520,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`] @@ -547,7 +544,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( @@ -573,6 +570,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` @@ -586,14 +585,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/_table_service_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_service_client.py index 4d764473a544..def6c17ecddf 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,22 +24,34 @@ from ._table_client import TableClient from ._serialize import _parameter_filter_substitution +if TYPE_CHECKING: + from ._models import CorsRule, Metrics, TableAnalyticsLogging + 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: - :class:`~azure.core.credentials.AzureNamedKeyCredential` or - :class:`~azure.core.credentials.AzureSasCredential` - :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 credential: + The credentials with which to authenticate. This is optional if the + account URL already has a SAS token. The value can be one of AzureNamedKeyCredential + or AzureSasCredential from azure-core. + :type credential: + :class:`~azure.core.credentials.AzureNamedKeyCredential` or + :class:`~azure.core.credentials.AzureSasCredential` + :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: @@ -59,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. @@ -85,14 +95,14 @@ 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): - # 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. @@ -111,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. @@ -163,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. @@ -191,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. @@ -224,14 +226,10 @@ 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. No error will be raised - if the given tables does not exist. + if the given table is not found. :param table_name: The Table name. :type table_name: str @@ -252,18 +250,12 @@ 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. :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 @@ -283,16 +275,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, ) @@ -302,8 +290,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` @@ -317,21 +303,17 @@ 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, ) 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/_base_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py index 4f87d4ba5567..a82e774481be 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,11 @@ class AsyncTablesBaseClient(AccountHostsMixin): def __init__( self, - account_url: str, + endpoint: str, credential: Optional[Union[AzureSasCredential, AzureNamedKeyCredential]] = None, **kwargs: Any - ): - # type: (...) -> None - super(AsyncTablesBaseClient, self).__init__(account_url, credential=credential, **kwargs) + ) -> None: + 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..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,10 +23,7 @@ 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. - :keyword str location_mode: The location mode being used to list results. The available - options include "primary" and "secondary". """ def __init__(self, command, **kwargs): @@ -40,25 +37,22 @@ 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 + 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, 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 +68,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 +83,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 +99,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 98a1f59dbcef..7707b9f2ac86 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 @@ -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, AzureNamedKeyCredential]] = 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 @@ -68,7 +67,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 @@ -85,11 +84,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` @@ -102,10 +98,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( @@ -116,8 +112,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 @@ -142,7 +137,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, @@ -153,7 +148,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]: @@ -470,8 +465,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 @@ -509,8 +504,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`] @@ -533,7 +528,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( @@ -558,6 +553,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` @@ -571,14 +568,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/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 652a0da45f7b..9cecaf5f35d7 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. @@ -36,7 +40,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 +51,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: @@ -73,23 +71,17 @@ 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, # type: any - **kwargs # type: Any - ): # type: (...) -> TableServiceClient + def from_connection_string(cls, conn_str: str, **kwargs) -> '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 +95,13 @@ 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] + 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. @@ -128,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. @@ -148,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. @@ -182,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: @@ -210,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. @@ -242,14 +221,9 @@ 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 - """Deletes the table under the current account. No error will be raised if - the table name is not found. + async def delete_table(self, table_name: str, **kwargs) -> None: + """Deletes a table under the current account. No error will be raised if + the table is not found. :param str table_name: The Table name. :return: None @@ -269,15 +243,10 @@ 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 - :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` @@ -291,32 +260,21 @@ 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, ) @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. :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 @@ -335,25 +293,16 @@ 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, ) - 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/samples/async_samples/sample_authentication_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_authentication_async.py index 4146cf9186b4..9f8893e17e1a 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 """ @@ -38,13 +38,13 @@ class TableAuthSamples(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, - self.endpoint + self.endpoint_suffix ) async def authentication_by_connection_string(self): @@ -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 e29a70c8202a..596a7a51de64 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 @@ -33,13 +33,13 @@ class CreateClients(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, - 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 00780a7bac34..7d63ff943ee6 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 """ @@ -38,13 +38,13 @@ class CreateClients(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, - 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 dace703f8980..3037f4c8ee63 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 """ @@ -34,13 +34,13 @@ class CreateDeleteTable(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, - 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 01311f3d9d27..a0c62276af41 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 @@ -29,13 +29,13 @@ class InsertDeleteEntity(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, - self.endpoint + self.endpoint_suffix ) self.table_name = "InsertDeleteAsync" @@ -74,7 +74,7 @@ async def delete_entity(self): from azure.core.credentials import AzureNamedKeyCredential credential = AzureNamedKeyCredential(self.account_name, self.access_key) - table_client = TableClient(account_url=self.account_url, credential=credential, table_name=self.table_name) + table_client = TableClient(endpoint=self.endpoint, credential=credential, 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 a0ec962d5c63..31a72085c156 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 @@ -31,13 +31,13 @@ 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, - 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 7417d8b6fdea..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 @@ -30,13 +30,13 @@ 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, - 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 193bccf7c917..21b81da2129c 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,13 +31,13 @@ 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, - 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 21a245fffa43..6fa9ff18a351 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 """ @@ -37,13 +37,13 @@ class TableAuthSamples(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, - self.endpoint + self.endpoint_suffix ) def authentication_by_connection_string(self): @@ -60,8 +60,9 @@ def authentication_by_shared_key(self): # [START auth_from_shared_key] from azure.data.tables import TableServiceClient from azure.core.credentials import AzureNamedKeyCredential + credential = AzureNamedKeyCredential(self.account_name, self.access_key) - with TableServiceClient(account_url=self.account_url, credential=credential) as table_service: + with TableServiceClient(endpoint=self.endpoint, credential=credential) as table_service: properties = table_service.get_service_properties() print("Shared Key: {}".format(properties)) # [END auth_from_shared_key] @@ -84,7 +85,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 da63ba086132..1599f75ee26c 100644 --- a/sdk/tables/azure-data-tables/samples/sample_batching.py +++ b/sdk/tables/azure-data-tables/samples/sample_batching.py @@ -32,13 +32,13 @@ class CreateClients(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, - 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 486360e53bce..cfa8c52420a0 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,13 +32,13 @@ class CreateClients(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, - self.endpoint + self.endpoint_suffix ) @@ -57,7 +57,7 @@ def create_table_service_client(self): from azure.core.credentials import AzureNamedKeyCredential credential = AzureNamedKeyCredential(self.account_name, self.access_key) - with TableServiceClient(account_url=self.account_url, credential=credential) as table_service: + with TableServiceClient(endpoint=self.endpoint, credential=credential) 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 46d0de30e641..249aab5238c0 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 @@ -28,13 +28,13 @@ class CreateDeleteTable(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, - 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 33ee8e60b5e5..60c6f22d9413 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 @@ -28,13 +28,13 @@ class InsertDeleteEntity(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 = u"DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix={}".format( self.account_name, self.access_key, - self.endpoint + self.endpoint_suffix ) self.table_name = "SampleInsertDelete" @@ -72,7 +72,7 @@ def delete_entity(self): from azure.core.credentials import AzureNamedKeyCredential credential = AzureNamedKeyCredential(self.account_name, self.access_key) - with TableClient(account_url=self.account_url, credential=credential, table_name=self.table_name) as table_client: + with TableClient(endpoint=self.endpoint, credential=credential, 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..84450a05f557 100644 --- a/sdk/tables/azure-data-tables/samples/sample_query_table.py +++ b/sdk/tables/azure-data-tables/samples/sample_query_table.py @@ -30,13 +30,13 @@ 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, - 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 f741978f61da..9b73c9426cfd 100644 --- a/sdk/tables/azure-data-tables/samples/sample_query_tables.py +++ b/sdk/tables/azure-data-tables/samples/sample_query_tables.py @@ -29,13 +29,13 @@ 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, - 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 83ab9442aa7a..8506e789f6c9 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,13 +30,13 @@ 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, - self.endpoint + self.endpoint_suffix ) self.table_name = "SampleUpdateUpsertMerge" 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.py b/sdk/tables/azure-data-tables/tests/test_table.py index 94bb96714268..2d0baa8a5d8c 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 @tables_decorator 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 @tables_decorator 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() ts.delete_table(table_name) @@ -331,7 +331,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 @@ -348,7 +348,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: @@ -367,7 +367,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: @@ -389,7 +389,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) @@ -414,7 +414,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: @@ -436,7 +436,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: @@ -460,7 +460,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 @@ -524,6 +524,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.named_key.key == self.credential.named_key.key assert tsc.credential.named_key.name == self.credential.named_key.name 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 cc9f9b638df9..9e39f193645f 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 @@ -162,7 +162,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(): @@ -188,7 +188,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): @@ -221,7 +221,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 @@ -238,7 +238,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() await ts.delete_table(table_name) @@ -248,7 +248,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: @@ -265,7 +265,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: @@ -349,7 +349,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: @@ -373,7 +373,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) @@ -441,6 +441,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.named_key.key == self.credential.named_key.key assert tsc.credential.named_key.name == self.credential.named_key.name 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 8afa69f4b13a..ac0d1df0880b 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_client.py +++ b/sdk/tables/azure-data-tables/tests/test_table_client.py @@ -196,7 +196,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.credential, table_name='foo') + test_service = service_type(endpoint=123456, credential=self.credential, table_name='foo') assert str(e.value) == "You need to provide either a SAS token or an account shared key to authenticate." @@ -395,13 +395,13 @@ def test_create_service_with_custom_account_endpoint_path(self): assert service.credential.named_key.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 @@ -428,7 +428,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.credential) + service = TableClient(endpoint=table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -442,7 +442,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 ab61bdfb85b0..91360d7d67a0 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 @@ -424,13 +424,13 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): assert service.credential.named_key.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 @@ -459,7 +459,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.credential) + service = TableClient(endpoint=table_url, table_name='bar', credential=self.credential) # Assert assert service.scheme == 'https' @@ -474,7 +474,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 2cb2787da0c3..8d506d8a97cf 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 @@ -99,7 +99,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): @@ -141,7 +141,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.credential, table_name='foo') @@ -154,7 +154,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.credential, table_name="test") @@ -170,7 +170,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") @@ -187,7 +187,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.credential, table_name="foo") @@ -205,7 +205,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") @@ -228,7 +228,7 @@ def test_create_service_protocol(self): for service_type in SERVICES: # Act service = service_type( - account_url=url, + endpoint=url, credential=self.credential, table_name="foo") @@ -253,11 +253,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.credential, 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.credential, table_name="foo", connection_timeout=22) @@ -435,14 +435,14 @@ def test_create_service_with_custom_account_endpoint_path(self): assert service.credential.named_key.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 @@ -460,7 +460,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.credential, table_name="bar") @@ -474,7 +474,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.credential, table_name="bar") @@ -490,7 +490,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) @@ -513,7 +513,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.credential, table_name='table') @@ -528,7 +528,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.credential, 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 66f6b4c81723..8630f231f4d3 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 @@ -426,14 +426,14 @@ async def test_create_service_with_custom_account_endpoint_path_async(self): assert service.credential.named_key.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 @@ -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_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 c594c6602e10..666fa22aa28a 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, account_url=account_url) ts = TableServiceClient(self.account_url(tables_cosmos_account_name, "cosmos"), tables_primary_cosmos_account_key) table_name = "myasynctable" 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 c2a9241c559a..e3c1441b2bf3 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_entity.py +++ b/sdk/tables/azure-data-tables/tests/test_table_entity.py @@ -869,6 +869,27 @@ def test_get_entity(self, tables_storage_account_name, tables_primary_storage_ac finally: self._tear_down() + @tables_decorator + 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() + @tables_decorator 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 f167f27ecb64..204397b3d63e 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 @@ -600,6 +600,27 @@ async def test_get_entity(self, tables_storage_account_name, tables_primary_stor finally: await self._tear_down() + @tables_decorator_async + 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() + @tables_decorator_async 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 708e208f0cfc..4f57e354e3d9 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 @@ -828,6 +828,27 @@ def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmos_acco self._tear_down() self.sleep(SLEEP_DELAY) + @cosmos_decorator + 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) + @cosmos_decorator 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 f549366244e4..4a539e40be72 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 @@ -570,6 +570,27 @@ async def test_get_entity(self, tables_cosmos_account_name, tables_primary_cosmo finally: await self._tear_down() + @cosmos_decorator_async + 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() + @cosmos_decorator_async async def test_get_entity_with_hook(self, tables_cosmos_account_name, tables_primary_cosmos_account_key): # Arrange