|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 | +# Code generated by Microsoft (R) Python Code Generator. |
| 6 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 7 | +# -------------------------------------------------------------------------- |
| 8 | + |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, TYPE_CHECKING |
| 11 | +from typing_extensions import Self |
| 12 | + |
| 13 | +from azure.core import PipelineClient |
| 14 | +from azure.core.pipeline import policies |
| 15 | +from azure.core.rest import HttpRequest, HttpResponse |
| 16 | + |
| 17 | +from ._configuration import DeidentificationClientConfiguration |
| 18 | +from ._operations import DeidentificationClientOperationsMixin |
| 19 | +from ._serialization import Deserializer, Serializer |
| 20 | + |
| 21 | +if TYPE_CHECKING: |
| 22 | + # pylint: disable=unused-import,ungrouped-imports |
| 23 | + from azure.core.credentials import TokenCredential |
| 24 | + |
| 25 | + |
| 26 | +class DeidentificationClient( |
| 27 | + DeidentificationClientOperationsMixin |
| 28 | +): # pylint: disable=client-accepts-api-version-keyword |
| 29 | + """DeidentificationClient. |
| 30 | +
|
| 31 | + :param endpoint: Url of your De-identification Service. Required. |
| 32 | + :type endpoint: str |
| 33 | + :param credential: Credential used to authenticate requests to the service. Required. |
| 34 | + :type credential: ~azure.core.credentials.TokenCredential |
| 35 | + :keyword api_version: The API version to use for this operation. Default value is |
| 36 | + "2024-07-12-preview". Note that overriding this default value may result in unsupported |
| 37 | + behavior. |
| 38 | + :paramtype api_version: str |
| 39 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 40 | + Retry-After header is present. |
| 41 | + """ |
| 42 | + |
| 43 | + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: |
| 44 | + _endpoint = "https://{endpoint}" |
| 45 | + self._config = DeidentificationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) |
| 46 | + _policies = kwargs.pop("policies", None) |
| 47 | + if _policies is None: |
| 48 | + _policies = [ |
| 49 | + policies.RequestIdPolicy(**kwargs), |
| 50 | + self._config.headers_policy, |
| 51 | + self._config.user_agent_policy, |
| 52 | + self._config.proxy_policy, |
| 53 | + policies.ContentDecodePolicy(**kwargs), |
| 54 | + self._config.redirect_policy, |
| 55 | + self._config.retry_policy, |
| 56 | + self._config.authentication_policy, |
| 57 | + self._config.custom_hook_policy, |
| 58 | + self._config.logging_policy, |
| 59 | + policies.DistributedTracingPolicy(**kwargs), |
| 60 | + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, |
| 61 | + self._config.http_logging_policy, |
| 62 | + ] |
| 63 | + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) |
| 64 | + |
| 65 | + self._serialize = Serializer() |
| 66 | + self._deserialize = Deserializer() |
| 67 | + self._serialize.client_side_validation = False |
| 68 | + |
| 69 | + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: |
| 70 | + """Runs the network request through the client's chained policies. |
| 71 | +
|
| 72 | + >>> from azure.core.rest import HttpRequest |
| 73 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 74 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 75 | + >>> response = client.send_request(request) |
| 76 | + <HttpResponse: 200 OK> |
| 77 | +
|
| 78 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 79 | +
|
| 80 | + :param request: The network request you want to make. Required. |
| 81 | + :type request: ~azure.core.rest.HttpRequest |
| 82 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 83 | + :return: The response of your network call. Does not do error handling on your response. |
| 84 | + :rtype: ~azure.core.rest.HttpResponse |
| 85 | + """ |
| 86 | + |
| 87 | + request_copy = deepcopy(request) |
| 88 | + path_format_arguments = { |
| 89 | + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"), |
| 90 | + } |
| 91 | + |
| 92 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 93 | + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore |
| 94 | + |
| 95 | + def close(self) -> None: |
| 96 | + self._client.close() |
| 97 | + |
| 98 | + def __enter__(self) -> Self: |
| 99 | + self._client.__enter__() |
| 100 | + return self |
| 101 | + |
| 102 | + def __exit__(self, *exc_details: Any) -> None: |
| 103 | + self._client.__exit__(*exc_details) |
0 commit comments