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 6cfe9e8a25d3..0e51a1108751 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 @@ -30,7 +30,6 @@ from azure.core.exceptions import ClientAuthenticationError, ResourceNotFoundError from azure.core.pipeline import Pipeline from azure.core.pipeline.transport import ( - RequestsTransport, HttpTransport, HttpRequest, ) @@ -66,7 +65,6 @@ from ._models import BatchErrorException from ._sdk_moniker import SDK_MONIKER - _LOGGER = logging.getLogger(__name__) _SERVICE_PARAMS = { "blob": {"primary": "BlobEndpoint", "secondary": "BlobSecondaryEndpoint"}, @@ -124,9 +122,27 @@ def __init__( self.require_encryption = kwargs.get("require_encryption", False) self.key_encryption_key = kwargs.get("key_encryption_key") self.key_resolver_function = kwargs.get("key_resolver_function") - self._config, self._pipeline = self._create_pipeline( - self.credential, storage_sdk=service, **kwargs - ) + + self._configure_credential(self.credential) + kwargs.setdefault("connection_timeout", CONNECTION_TIMEOUT) + kwargs.setdefault("read_timeout", READ_TIMEOUT) + + self._policies = [ + StorageHeadersPolicy(**kwargs), + ProxyPolicy(**kwargs), + UserAgentPolicy(sdk_moniker=SDK_MONIKER, **kwargs), + StorageContentValidation(), + StorageRequestHook(**kwargs), + self._credential_policy, + ContentDecodePolicy(response_encoding="utf-8"), + RedirectPolicy(**kwargs), + StorageHosts(hosts=self._hosts, **kwargs), + kwargs.get("retry_policy") or TablesRetryPolicy(**kwargs), + StorageLoggingPolicy(**kwargs), + StorageResponseHook(**kwargs), + DistributedTracingPolicy(**kwargs), + HttpLoggingPolicy(**kwargs), + ] def __enter__(self): self._client.__enter__() @@ -233,7 +249,7 @@ def _format_query_string( credential = None return query_str.rstrip("?&"), credential - def _create_pipeline(self, credential, **kwargs): + def _configure_credential(self, credential): # type: (Any, **Any) -> Tuple[Configuration, Pipeline] self._credential_policy = None if hasattr(credential, "get_token"): @@ -245,32 +261,6 @@ def _create_pipeline(self, credential, **kwargs): elif credential is not None: raise TypeError("Unsupported credential: {}".format(credential)) - config = kwargs.get("_configuration") or create_configuration(**kwargs) - if kwargs.get("_pipeline"): - return config, kwargs["_pipeline"] - config.transport = kwargs.get("transport") # type: ignore - kwargs.setdefault("connection_timeout", CONNECTION_TIMEOUT) - kwargs.setdefault("read_timeout", READ_TIMEOUT) - if not config.transport: - config.transport = RequestsTransport(**kwargs) - policies = [ - config.headers_policy, - config.proxy_policy, - config.user_agent_policy, - StorageContentValidation(), - StorageRequestHook(**kwargs), - self._credential_policy, - ContentDecodePolicy(response_encoding="utf-8"), - RedirectPolicy(**kwargs), - StorageHosts(hosts=self._hosts, **kwargs), - config.retry_policy, - config.logging_policy, - StorageResponseHook(**kwargs), - DistributedTracingPolicy(**kwargs), - HttpLoggingPolicy(**kwargs), - ] - return config, Pipeline(config.transport, policies=policies) - def _batch_send( # pylint: disable=inconsistent-return-statements self, entities, # type: List[TableEntity] @@ -302,7 +292,7 @@ def _batch_send( # pylint: disable=inconsistent-return-statements boundary="batch_{}".format(uuid4()), ) - pipeline_response = self._pipeline.run(request, **kwargs) + pipeline_response = self._client._client._pipeline.run(request, **kwargs) # pylint:disable=protected-access response = pipeline_response.http_response if response.status_code == 403: @@ -461,39 +451,6 @@ def parse_connection_str(conn_str, credential, service, keyword_args): return primary, credential -def create_configuration(**kwargs): - # type: (**Any) -> Configuration - config = Configuration(**kwargs) - config.headers_policy = StorageHeadersPolicy(**kwargs) - config.user_agent_policy = UserAgentPolicy(sdk_moniker=SDK_MONIKER, **kwargs) - # sdk_moniker="storage-{}/{}".format(kwargs.pop('storage_sdk'), VERSION), **kwargs) - config.retry_policy = kwargs.get("retry_policy") or TablesRetryPolicy(**kwargs) - config.logging_policy = StorageLoggingPolicy(**kwargs) - config.proxy_policy = ProxyPolicy(**kwargs) - - # Storage settings - config.max_single_put_size = kwargs.get("max_single_put_size", 64 * 1024 * 1024) - config.copy_polling_interval = 15 - - # Block blob uploads - config.max_block_size = kwargs.get("max_block_size", 4 * 1024 * 1024) - config.min_large_block_upload_threshold = kwargs.get( - "min_large_block_upload_threshold", 4 * 1024 * 1024 + 1 - ) - config.use_byte_buffer = kwargs.get("use_byte_buffer", False) - - # Page blob uploads - config.max_page_size = kwargs.get("max_page_size", 4 * 1024 * 1024) - - # Blob downloads - config.max_single_get_size = kwargs.get("max_single_get_size", 32 * 1024 * 1024) - config.max_chunk_get_size = kwargs.get("max_chunk_get_size", 4 * 1024 * 1024) - - # File uploads - config.max_range_size = kwargs.get("max_range_size", 4 * 1024 * 1024) - return config - - def parse_query(query_str): sas_values = QueryStringConstants.to_list() parsed_query = {k: v[0] for k, v in parse_qs(query_str).items()} diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_generated/_azure_table.py b/sdk/tables/azure-data-tables/azure/data/tables/_generated/_azure_table.py index 7d6f16f78721..49348713afc2 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_generated/_azure_table.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_generated/_azure_table.py @@ -44,6 +44,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.table = TableOperations( diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/_azure_table.py b/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/_azure_table.py index c2f6e6333d44..09806d68b257 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/_azure_table.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/_azure_table.py @@ -39,6 +39,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.table = TableOperations( diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_service_operations.py b/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_service_operations.py index 4ef1391d9b92..14715416451e 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_service_operations.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_service_operations.py @@ -12,7 +12,7 @@ from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -31,7 +31,7 @@ class ServiceOperations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -41,7 +41,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def set_properties( self, - table_service_properties: "models.TableServiceProperties", + table_service_properties: "_models.TableServiceProperties", timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, **kwargs @@ -102,7 +102,7 @@ async def set_properties( if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -120,7 +120,7 @@ async def get_properties( timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, **kwargs - ) -> "models.TableServiceProperties": + ) -> "_models.TableServiceProperties": """Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -134,7 +134,7 @@ async def get_properties( :rtype: ~azure.data.tables.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableServiceProperties"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -170,7 +170,7 @@ async def get_properties( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -190,7 +190,7 @@ async def get_statistics( timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, **kwargs - ) -> "models.TableServiceStats": + ) -> "_models.TableServiceStats": """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. @@ -205,7 +205,7 @@ async def get_statistics( :rtype: ~azure.data.tables.models.TableServiceStats :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableServiceStats"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceStats"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -241,7 +241,7 @@ async def get_statistics( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_table_operations.py b/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_table_operations.py index 8a2951127b6f..e591ae3b76f4 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_table_operations.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_generated/aio/operations/_table_operations.py @@ -12,7 +12,7 @@ from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from ... import models +from ... import models as _models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -31,7 +31,7 @@ class TableOperations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -43,9 +43,9 @@ async def query( self, request_id_parameter: Optional[str] = None, next_table_name: Optional[str] = None, - query_options: Optional["models.QueryOptions"] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs - ) -> "models.TableQueryResponse": + ) -> "_models.TableQueryResponse": """Queries tables under the given account. :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character @@ -60,12 +60,12 @@ async def query( :rtype: ~azure.data.tables.models.TableQueryResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableQueryResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableQueryResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None _top = None _select = None @@ -112,7 +112,7 @@ async def query( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -131,12 +131,12 @@ async def query( async def create( self, - table_properties: "models.TableProperties", + table_properties: "_models.TableProperties", request_id_parameter: Optional[str] = None, - response_preference: Optional[Union[str, "models.ResponseFormat"]] = None, - query_options: Optional["models.QueryOptions"] = None, + response_preference: Optional[Union[str, "_models.ResponseFormat"]] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs - ) -> Optional["models.TableResponse"]: + ) -> Optional["_models.TableResponse"]: """Creates a new table under the given account. :param table_properties: The Table properties. @@ -154,12 +154,12 @@ async def create( :rtype: ~azure.data.tables.models.TableResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.TableResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.TableResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -199,7 +199,7 @@ async def create( if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -274,7 +274,7 @@ async def delete( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -295,9 +295,9 @@ async def query_entities( request_id_parameter: Optional[str] = None, next_partition_key: Optional[str] = None, next_row_key: Optional[str] = None, - query_options: Optional["models.QueryOptions"] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs - ) -> "models.TableEntityQueryResponse": + ) -> "_models.TableEntityQueryResponse": """Queries entities in a table. :param table: The name of the table. @@ -318,12 +318,12 @@ async def query_entities( :rtype: ~azure.data.tables.models.TableEntityQueryResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableEntityQueryResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableEntityQueryResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None _top = None _select = None @@ -375,7 +375,7 @@ async def query_entities( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -400,7 +400,7 @@ async def query_entities_with_partition_and_row_key( row_key: str, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, - query_options: Optional["models.QueryOptions"] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs ) -> Dict[str, object]: """Queries entities in a table. @@ -428,7 +428,7 @@ async def query_entities_with_partition_and_row_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None _select = None _filter = None @@ -474,7 +474,7 @@ async def query_entities_with_partition_and_row_key( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -502,7 +502,7 @@ async def update_entity( request_id_parameter: Optional[str] = None, if_match: Optional[str] = None, table_entity_properties: Optional[Dict[str, object]] = None, - query_options: Optional["models.QueryOptions"] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs ) -> None: """Update entity in a table. @@ -537,7 +537,7 @@ async def update_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -585,7 +585,7 @@ async def update_entity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -609,7 +609,7 @@ async def merge_entity( request_id_parameter: Optional[str] = None, if_match: Optional[str] = None, table_entity_properties: Optional[Dict[str, object]] = None, - query_options: Optional["models.QueryOptions"] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs ) -> None: """Merge entity in a table. @@ -644,7 +644,7 @@ async def merge_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -692,7 +692,7 @@ async def merge_entity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -715,7 +715,7 @@ async def delete_entity( if_match: str, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, - query_options: Optional["models.QueryOptions"] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs ) -> None: """Deletes the specified entity in a table. @@ -747,7 +747,7 @@ async def delete_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -786,7 +786,7 @@ async def delete_entity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -805,9 +805,9 @@ async def insert_entity( table: str, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, - response_preference: Optional[Union[str, "models.ResponseFormat"]] = None, + response_preference: Optional[Union[str, "_models.ResponseFormat"]] = None, table_entity_properties: Optional[Dict[str, object]] = None, - query_options: Optional["models.QueryOptions"] = None, + query_options: Optional["_models.QueryOptions"] = None, **kwargs ) -> Optional[Dict[str, object]]: """Insert entity in a table. @@ -836,7 +836,7 @@ async def insert_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -882,7 +882,7 @@ async def insert_entity( if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -918,7 +918,7 @@ async def get_access_policy( timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, **kwargs - ) -> List["models.SignedIdentifier"]: + ) -> List["_models.SignedIdentifier"]: """Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures. @@ -934,7 +934,7 @@ async def get_access_policy( :rtype: list[~azure.data.tables.models.SignedIdentifier] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["models.SignedIdentifier"]] + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.SignedIdentifier"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -969,7 +969,7 @@ async def get_access_policy( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -990,7 +990,7 @@ async def set_access_policy( table: str, timeout: Optional[int] = None, request_id_parameter: Optional[str] = None, - table_acl: Optional[List["models.SignedIdentifier"]] = None, + table_acl: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ) -> None: """Sets stored access policies for the table that may be used with Shared Access Signatures. @@ -1053,7 +1053,7 @@ async def set_access_policy( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_service_operations.py b/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_service_operations.py index 923d52a0ac40..a55e05345e87 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_service_operations.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_service_operations.py @@ -12,7 +12,7 @@ from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -35,7 +35,7 @@ class ServiceOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -45,7 +45,7 @@ def __init__(self, client, config, serializer, deserializer): def set_properties( self, - table_service_properties, # type: "models.TableServiceProperties" + table_service_properties, # type: "_models.TableServiceProperties" timeout=None, # type: Optional[int] request_id_parameter=None, # type: Optional[str] **kwargs # type: Any @@ -107,7 +107,7 @@ def set_properties( if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -126,7 +126,7 @@ def get_properties( request_id_parameter=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> "models.TableServiceProperties" + # type: (...) -> "_models.TableServiceProperties" """Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -140,7 +140,7 @@ def get_properties( :rtype: ~azure.data.tables.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableServiceProperties"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -176,7 +176,7 @@ def get_properties( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -197,7 +197,7 @@ def get_statistics( request_id_parameter=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> "models.TableServiceStats" + # type: (...) -> "_models.TableServiceStats" """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. @@ -212,7 +212,7 @@ def get_statistics( :rtype: ~azure.data.tables.models.TableServiceStats :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableServiceStats"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceStats"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -248,7 +248,7 @@ def get_statistics( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_table_operations.py b/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_table_operations.py index 1f6797da2b00..6d2c5e11ec60 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_table_operations.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_generated/operations/_table_operations.py @@ -12,7 +12,7 @@ from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse -from .. import models +from .. import models as _models if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -35,7 +35,7 @@ class TableOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -47,10 +47,10 @@ def query( self, request_id_parameter=None, # type: Optional[str] next_table_name=None, # type: Optional[str] - query_options=None, # type: Optional["models.QueryOptions"] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): - # type: (...) -> "models.TableQueryResponse" + # type: (...) -> "_models.TableQueryResponse" """Queries tables under the given account. :param request_id_parameter: Provides a client-generated, opaque value with a 1 KB character @@ -65,12 +65,12 @@ def query( :rtype: ~azure.data.tables.models.TableQueryResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableQueryResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableQueryResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None _top = None _select = None @@ -117,7 +117,7 @@ def query( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -136,13 +136,13 @@ def query( def create( self, - table_properties, # type: "models.TableProperties" + table_properties, # type: "_models.TableProperties" request_id_parameter=None, # type: Optional[str] - response_preference=None, # type: Optional[Union[str, "models.ResponseFormat"]] - query_options=None, # type: Optional["models.QueryOptions"] + response_preference=None, # type: Optional[Union[str, "_models.ResponseFormat"]] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): - # type: (...) -> Optional["models.TableResponse"] + # type: (...) -> Optional["_models.TableResponse"] """Creates a new table under the given account. :param table_properties: The Table properties. @@ -160,12 +160,12 @@ def create( :rtype: ~azure.data.tables.models.TableResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.TableResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.TableResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -205,7 +205,7 @@ def create( if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -281,7 +281,7 @@ def delete( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -302,10 +302,10 @@ def query_entities( request_id_parameter=None, # type: Optional[str] next_partition_key=None, # type: Optional[str] next_row_key=None, # type: Optional[str] - query_options=None, # type: Optional["models.QueryOptions"] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): - # type: (...) -> "models.TableEntityQueryResponse" + # type: (...) -> "_models.TableEntityQueryResponse" """Queries entities in a table. :param table: The name of the table. @@ -326,12 +326,12 @@ def query_entities( :rtype: ~azure.data.tables.models.TableEntityQueryResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.TableEntityQueryResponse"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TableEntityQueryResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None _top = None _select = None @@ -383,7 +383,7 @@ def query_entities( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -408,7 +408,7 @@ def query_entities_with_partition_and_row_key( row_key, # type: str timeout=None, # type: Optional[int] request_id_parameter=None, # type: Optional[str] - query_options=None, # type: Optional["models.QueryOptions"] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): # type: (...) -> Dict[str, object] @@ -437,7 +437,7 @@ def query_entities_with_partition_and_row_key( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None _select = None _filter = None @@ -483,7 +483,7 @@ def query_entities_with_partition_and_row_key( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -511,7 +511,7 @@ def update_entity( request_id_parameter=None, # type: Optional[str] if_match=None, # type: Optional[str] table_entity_properties=None, # type: Optional[Dict[str, object]] - query_options=None, # type: Optional["models.QueryOptions"] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): # type: (...) -> None @@ -547,7 +547,7 @@ def update_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -595,7 +595,7 @@ def update_entity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -619,7 +619,7 @@ def merge_entity( request_id_parameter=None, # type: Optional[str] if_match=None, # type: Optional[str] table_entity_properties=None, # type: Optional[Dict[str, object]] - query_options=None, # type: Optional["models.QueryOptions"] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): # type: (...) -> None @@ -655,7 +655,7 @@ def merge_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -703,7 +703,7 @@ def merge_entity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -726,7 +726,7 @@ def delete_entity( if_match, # type: str timeout=None, # type: Optional[int] request_id_parameter=None, # type: Optional[str] - query_options=None, # type: Optional["models.QueryOptions"] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): # type: (...) -> None @@ -759,7 +759,7 @@ def delete_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -798,7 +798,7 @@ def delete_entity( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -817,9 +817,9 @@ def insert_entity( table, # type: str timeout=None, # type: Optional[int] request_id_parameter=None, # type: Optional[str] - response_preference=None, # type: Optional[Union[str, "models.ResponseFormat"]] + response_preference=None, # type: Optional[Union[str, "_models.ResponseFormat"]] table_entity_properties=None, # type: Optional[Dict[str, object]] - query_options=None, # type: Optional["models.QueryOptions"] + query_options=None, # type: Optional["_models.QueryOptions"] **kwargs # type: Any ): # type: (...) -> Optional[Dict[str, object]] @@ -849,7 +849,7 @@ def insert_entity( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - + _format = None if query_options is not None: _format = query_options.format @@ -895,7 +895,7 @@ def insert_entity( if response.status_code not in [201, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -932,7 +932,7 @@ def get_access_policy( request_id_parameter=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> List["models.SignedIdentifier"] + # type: (...) -> List["_models.SignedIdentifier"] """Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures. @@ -948,7 +948,7 @@ def get_access_policy( :rtype: list[~azure.data.tables.models.SignedIdentifier] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["models.SignedIdentifier"]] + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.SignedIdentifier"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -983,7 +983,7 @@ def get_access_policy( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} @@ -1004,7 +1004,7 @@ def set_access_policy( table, # type: str timeout=None, # type: Optional[int] request_id_parameter=None, # type: Optional[str] - table_acl=None, # type: Optional[List["models.SignedIdentifier"]] + table_acl=None, # type: Optional[List["_models.SignedIdentifier"]] **kwargs # type: Any ): # type: (...) -> None @@ -1068,7 +1068,7 @@ def set_access_policy( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.TableServiceError, response) + error = self._deserialize(_models.TableServiceError, response) raise HttpResponseError(response=response, model=error) response_headers = {} 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 6e5668c83411..ff5e3c80de36 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 @@ -17,12 +17,12 @@ from azure.core.paging import ItemPaged from azure.core.tracing.decorator import distributed_trace +from ._constants import CONNECTION_TIMEOUT from ._deserialize import _convert_to_entity, _trim_service_metadata from ._entity import TableEntity from ._error import _process_table_error from ._generated import AzureTable from ._generated.models import ( - # AccessPolicy, SignedIdentifier, TableProperties, ) @@ -31,7 +31,6 @@ from ._table_client_base import TableClientBase from ._serialize import serialize_iso from ._deserialize import _return_headers_and_deserialized - from ._table_batch import TableBatchOperations from ._models import TableEntityPropertiesPaged, UpdateMode, AccessPolicy @@ -66,7 +65,12 @@ def __init__( super(TableClient, self).__init__( account_url, table_name, credential=credential, **kwargs ) - self._client = AzureTable(self.url, pipeline=self._pipeline) + kwargs['connection_timeout'] = kwargs.get('connection_timeout') or CONNECTION_TIMEOUT + self._client = AzureTable( + self.url, + policies=kwargs.pop('policies', self._policies), + **kwargs + ) @classmethod def from_connection_string( 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 f3d58d520e3d..8726111cdce9 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 @@ -10,16 +10,17 @@ from azure.core.paging import ItemPaged from azure.core.tracing.decorator import distributed_trace from azure.core.pipeline import Pipeline -from ._models import TableItem +from ._constants import CONNECTION_TIMEOUT from ._generated import AzureTable from ._generated.models import TableProperties, TableServiceProperties from ._models import ( TablePropertiesPaged, service_stats_deserialize, service_properties_deserialize, + TableItem ) -from ._base_client import parse_connection_str, TransportWrapper +from ._base_client import parse_connection_str from ._models import LocationMode from ._error import _process_table_error from ._table_client import TableClient @@ -65,11 +66,15 @@ def __init__( :dedent: 8 :caption: Authenticating a TableServiceClient from a Shared Account Key """ - super(TableServiceClient, self).__init__( account_url, service="table", credential=credential, **kwargs ) - self._client = AzureTable(self.url, pipeline=self._pipeline) + kwargs['connection_timeout'] = kwargs.get('connection_timeout') or CONNECTION_TIMEOUT + self._client = AzureTable( + self.url, + policies=kwargs.pop('policies', self._policies), + **kwargs + ) @classmethod def from_connection_string( @@ -357,10 +362,8 @@ def get_table_client(self, table_name, **kwargs): """ _pipeline = Pipeline( - transport=TransportWrapper( - self._pipeline._transport # pylint: disable=protected-access - ), - policies=self._pipeline._impl_policies, # pylint: disable=protected-access + transport=self._client._client._pipeline._transport, # pylint: disable=protected-access + policies=self._policies, # pylint: disable=protected-access ) return TableClient( @@ -371,8 +374,9 @@ def get_table_client(self, table_name, **kwargs): require_encryption=self.require_encryption, key_encryption_key=self.key_encryption_key, api_version=self.api_version, - _pipeline=_pipeline, - _configuration=self._config, + transport=self._client._client._pipeline._transport, # pylint: disable=protected-access + policies=self._policies, + _configuration=self._client._config, # pylint: disable=protected-access _location_mode=self._location_mode, _hosts=self._hosts, **kwargs diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_base_client_async.py index 8431cb8ae3f1..14e7955916ca 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 @@ -18,7 +18,6 @@ import logging from uuid import uuid4 -from azure.core.pipeline import AsyncPipeline from azure.core.exceptions import ResourceNotFoundError, ClientAuthenticationError from azure.core.pipeline.policies import ( ContentDecodePolicy, @@ -26,24 +25,35 @@ AsyncRedirectPolicy, DistributedTracingPolicy, HttpLoggingPolicy, + UserAgentPolicy, + ProxyPolicy, +) +from azure.core.pipeline.transport import ( + AsyncHttpTransport, + HttpRequest, ) -from azure.core.pipeline.transport import AsyncHttpTransport, HttpRequest -from .._constants import STORAGE_OAUTH_SCOPE, CONNECTION_TIMEOUT, READ_TIMEOUT from .._authentication import SharedKeyCredentialPolicy -from .._base_client import create_configuration +from .._constants import STORAGE_OAUTH_SCOPE, CONNECTION_TIMEOUT, READ_TIMEOUT +from .._generated.aio._configuration import AzureTableConfiguration +from .._models import BatchErrorException, BatchTransactionResult from .._policies import ( StorageContentValidation, StorageRequestHook, StorageHosts, StorageHeadersPolicy, + StorageLoggingPolicy, +) +from .._sdk_moniker import SDK_MONIKER +from ._policies_async import ( + AsyncStorageResponseHook, + AsyncTablesRetryPolicy ) -from ._policies_async import AsyncStorageResponseHook -from .._models import BatchErrorException, BatchTransactionResult if TYPE_CHECKING: from azure.core.pipeline import Pipeline from azure.core.configuration import Configuration + _LOGGER = logging.getLogger(__name__) @@ -67,8 +77,8 @@ async def close(self): """ await self._client.close() - def _create_pipeline(self, credential, **kwargs): - # type: (Any, **Any) -> Tuple[Configuration, Pipeline] + def _configure_credential(self, credential): + # type: (Any) -> None self._credential_policy = None if hasattr(credential, "get_token"): self._credential_policy = AsyncBearerTokenCredentialPolicy( @@ -78,37 +88,37 @@ def _create_pipeline(self, credential, **kwargs): self._credential_policy = credential elif credential is not None: raise TypeError("Unsupported credential: {}".format(credential)) - config = kwargs.get("_configuration") or create_configuration(**kwargs) - if kwargs.get("_pipeline"): - return config, kwargs["_pipeline"] - config.transport = kwargs.get("transport") # type: ignore + + def _configure_policies(self, **kwargs): + # type: (**Any) -> None + try: + from azure.core.pipeline.transport import AioHttpTransport + if not kwargs.get("transport"): + kwargs.setdefault("transport", AioHttpTransport(**kwargs)) + except ImportError: + raise ImportError( + "Unable to create async transport. Please check aiohttp is installed." + ) + kwargs.setdefault("connection_timeout", CONNECTION_TIMEOUT) kwargs.setdefault("read_timeout", READ_TIMEOUT) - if not config.transport: - try: - from azure.core.pipeline.transport import AioHttpTransport - except ImportError: - raise ImportError( - "Unable to create async transport. Please check aiohttp is installed." - ) - config.transport = AioHttpTransport(**kwargs) - policies = [ - config.headers_policy, - config.proxy_policy, - config.user_agent_policy, + + self._policies = [ + StorageHeadersPolicy(**kwargs), + ProxyPolicy(**kwargs), + UserAgentPolicy(sdk_moniker=SDK_MONIKER, **kwargs), StorageContentValidation(), StorageRequestHook(**kwargs), self._credential_policy, ContentDecodePolicy(response_encoding="utf-8"), AsyncRedirectPolicy(**kwargs), - StorageHosts(hosts=self._hosts, **kwargs), # type: ignore - config.retry_policy, - config.logging_policy, + StorageHosts(hosts=self._hosts, **kwargs), + AsyncTablesRetryPolicy(**kwargs), + StorageLoggingPolicy(**kwargs), AsyncStorageResponseHook(**kwargs), DistributedTracingPolicy(**kwargs), HttpLoggingPolicy(**kwargs), ] - return config, AsyncPipeline(config.transport, policies=policies) async def _batch_send( self, @@ -140,7 +150,7 @@ async def _batch_send( boundary="batch_{}".format(uuid4()), ) - pipeline_response = await self._pipeline.run(request, **kwargs) + pipeline_response = await self._client._client._pipeline.run(request, **kwargs) # pylint:disable=protected-access response = pipeline_response.http_response if response.status_code == 403: 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 af9f83d54d05..f404fff21e0e 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 @@ -22,6 +22,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from .._base_client import parse_connection_str +from .._constants import CONNECTION_TIMEOUT from .._entity import TableEntity from .._generated.aio import AzureTable from .._generated.models import SignedIdentifier, TableProperties @@ -77,7 +78,14 @@ def __init__( loop=loop, **kwargs ) - self._client = AzureTable(self.url, pipeline=self._pipeline, loop=loop) + kwargs['connection_timeout'] = kwargs.get('connection_timeout') or CONNECTION_TIMEOUT + self._configure_policies(**kwargs) + self._client = AzureTable( + self.url, + policies=kwargs.pop('policies', self._policies), + loop=loop, + **kwargs + ) self._loop = loop @classmethod 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 ea331df349af..0505bb6d9255 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 @@ -17,6 +17,7 @@ from azure.core.tracing.decorator_async import distributed_trace_async from .. import LocationMode +from .._constants import CONNECTION_TIMEOUT from .._base_client import parse_connection_str from .._generated.aio._azure_table import AzureTable from .._generated.models import TableServiceProperties, TableProperties @@ -26,7 +27,7 @@ from .._models import TableItem from ._policies_async import ExponentialRetry from ._table_client_async import TableClient -from ._base_client_async import AsyncStorageAccountHostsMixin, AsyncTransportWrapper +from ._base_client_async import AsyncStorageAccountHostsMixin from ._models import TablePropertiesPaged @@ -89,7 +90,13 @@ def __init__( super(TableServiceClient, self).__init__( # type: ignore account_url, service="table", credential=credential, loop=loop, **kwargs ) - self._client = AzureTable(url=self.url, pipeline=self._pipeline, loop=loop) # type: ignore + kwargs['connection_timeout'] = kwargs.get('connection_timeout') or CONNECTION_TIMEOUT + self._configure_policies(**kwargs) + self._client = AzureTable( + self.url, + policies=kwargs.pop('policies', self._policies), + **kwargs + ) self._loop = loop @classmethod @@ -384,12 +391,9 @@ def get_table_client( :rtype: ~azure.data.tables.TableClient """ - _pipeline = AsyncPipeline( - transport=AsyncTransportWrapper( - self._pipeline._transport # pylint: disable = protected-access - ), - policies=self._pipeline._impl_policies, # pylint: disable = protected-access + transport=self._client._client._pipeline._transport, # pylint: disable=protected-access + policies=self._policies, # pylint: disable = protected-access ) return TableClient( @@ -400,8 +404,9 @@ def get_table_client( require_encryption=self.require_encryption, key_encryption_key=self.key_encryption_key, api_version=self.api_version, - _pipeline=self._pipeline, - _configuration=self._config, + transport=self._client._client._pipeline._transport, # pylint: disable=protected-access + policies=self._policies, + _configuration=self._client._config, # pylint: disable=protected-access _location_mode=self._location_mode, _hosts=self._hosts, **kwargs diff --git a/sdk/tables/azure-data-tables/tests/test_table.py b/sdk/tables/azure-data-tables/tests/test_table.py index 37c0c4bec7f6..6cfee9a948fa 100644 --- a/sdk/tables/azure-data-tables/tests/test_table.py +++ b/sdk/tables/azure-data-tables/tests/test_table.py @@ -32,7 +32,6 @@ HeadersPolicy, ContentDecodePolicy, ) -from azure.core.pipeline.transport import RequestsTransport from azure.core.exceptions import ( HttpResponseError, ResourceNotFoundError, 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 22bc3335a179..efe6f5a91cab 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 @@ -250,7 +250,6 @@ async def test_create_service_with_connection_string_endpoint_protocol_async(sel assert service.account_name == tables_cosmos_account_name assert service.credential.account_name == tables_cosmos_account_name assert service.credential.account_key == tables_primary_cosmos_account_key - print(service._primary_endpoint) assert service._primary_endpoint.startswith('http://{}.{}.core.chinacloudapi.cn'.format(tables_cosmos_account_name, "table")) assert service.scheme == 'http' diff --git a/sdk/tables/azure-data-tables/tests/test_table_cosmos.py b/sdk/tables/azure-data-tables/tests/test_table_cosmos.py index ab4c401abea1..6867b6216b42 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_cosmos.py +++ b/sdk/tables/azure-data-tables/tests/test_table_cosmos.py @@ -15,7 +15,6 @@ timedelta, ) -from azure.core.pipeline.transport import RequestsTransport from azure.core.exceptions import ( HttpResponseError, ResourceNotFoundError,