77# --------------------------------------------------------------------------
88
99from copy import deepcopy
10- from typing import Any
10+ from typing import Any , TYPE_CHECKING , Union
1111
1212from azure .core import PipelineClient
1313from azure .core .credentials import AzureKeyCredential
1414from azure .core .pipeline import policies
1515from azure .core .rest import HttpRequest , HttpResponse
1616
17- from ._configuration import ContentSafetyClientConfiguration
18- from ._operations import ContentSafetyClientOperationsMixin
17+ from ._configuration import BlocklistClientConfiguration , ContentSafetyClientConfiguration
18+ from ._operations import BlocklistClientOperationsMixin , ContentSafetyClientOperationsMixin
1919from ._serialization import Deserializer , Serializer
2020
21+ if TYPE_CHECKING :
22+ # pylint: disable=unused-import,ungrouped-imports
23+ from azure .core .credentials import TokenCredential
24+
2125
2226class ContentSafetyClient (ContentSafetyClientOperationsMixin ): # pylint: disable=client-accepts-api-version-keyword
23- """Analyze harmful content .
27+ """ContentSafetyClient .
2428
2529 :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
2630 https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
2731 :type endpoint: str
28- :param credential: Credential needed for the client to connect to Azure. Required.
29- :type credential: ~azure.core.credentials.AzureKeyCredential
30- :keyword api_version: The API version to use for this operation. Default value is
31- "2023-04-30-preview". Note that overriding this default value may result in unsupported
32- behavior.
32+ :param credential: Credential needed for the client to connect to Azure. Is either a
33+ AzureKeyCredential type or a TokenCredential type. Required.
34+ :type credential: ~azure.core.credentials.AzureKeyCredential or
35+ ~azure.core.credentials.TokenCredential
36+ :keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
37+ Note that overriding this default value may result in unsupported behavior.
3338 :paramtype api_version: str
3439 """
3540
36- def __init__ (self , endpoint : str , credential : AzureKeyCredential , ** kwargs : Any ) -> None :
41+ def __init__ (self , endpoint : str , credential : Union [ AzureKeyCredential , "TokenCredential" ] , ** kwargs : Any ) -> None :
3742 _endpoint = "{endpoint}/contentsafety"
3843 self ._config = ContentSafetyClientConfiguration (endpoint = endpoint , credential = credential , ** kwargs )
3944 _policies = kwargs .pop ("policies" , None )
@@ -59,7 +64,7 @@ def __init__(self, endpoint: str, credential: AzureKeyCredential, **kwargs: Any)
5964 self ._deserialize = Deserializer ()
6065 self ._serialize .client_side_validation = False
6166
62- def send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
67+ def send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
6368 """Runs the network request through the client's chained policies.
6469
6570 >>> from azure.core.rest import HttpRequest
@@ -83,7 +88,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
8388 }
8489
8590 request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
86- return self ._client .send_request (request_copy , ** kwargs ) # type: ignore
91+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
8792
8893 def close (self ) -> None :
8994 self ._client .close ()
@@ -94,3 +99,81 @@ def __enter__(self) -> "ContentSafetyClient":
9499
95100 def __exit__ (self , * exc_details : Any ) -> None :
96101 self ._client .__exit__ (* exc_details )
102+
103+
104+ class BlocklistClient (BlocklistClientOperationsMixin ): # pylint: disable=client-accepts-api-version-keyword
105+ """BlocklistClient.
106+
107+ :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
108+ https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
109+ :type endpoint: str
110+ :param credential: Credential needed for the client to connect to Azure. Is either a
111+ AzureKeyCredential type or a TokenCredential type. Required.
112+ :type credential: ~azure.core.credentials.AzureKeyCredential or
113+ ~azure.core.credentials.TokenCredential
114+ :keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
115+ Note that overriding this default value may result in unsupported behavior.
116+ :paramtype api_version: str
117+ """
118+
119+ def __init__ (self , endpoint : str , credential : Union [AzureKeyCredential , "TokenCredential" ], ** kwargs : Any ) -> None :
120+ _endpoint = "{endpoint}/contentsafety"
121+ self ._config = BlocklistClientConfiguration (endpoint = endpoint , credential = credential , ** kwargs )
122+ _policies = kwargs .pop ("policies" , None )
123+ if _policies is None :
124+ _policies = [
125+ policies .RequestIdPolicy (** kwargs ),
126+ self ._config .headers_policy ,
127+ self ._config .user_agent_policy ,
128+ self ._config .proxy_policy ,
129+ policies .ContentDecodePolicy (** kwargs ),
130+ self ._config .redirect_policy ,
131+ self ._config .retry_policy ,
132+ self ._config .authentication_policy ,
133+ self ._config .custom_hook_policy ,
134+ self ._config .logging_policy ,
135+ policies .DistributedTracingPolicy (** kwargs ),
136+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
137+ self ._config .http_logging_policy ,
138+ ]
139+ self ._client : PipelineClient = PipelineClient (base_url = _endpoint , policies = _policies , ** kwargs )
140+
141+ self ._serialize = Serializer ()
142+ self ._deserialize = Deserializer ()
143+ self ._serialize .client_side_validation = False
144+
145+ def send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
146+ """Runs the network request through the client's chained policies.
147+
148+ >>> from azure.core.rest import HttpRequest
149+ >>> request = HttpRequest("GET", "https://www.example.org/")
150+ <HttpRequest [GET], url: 'https://www.example.org/'>
151+ >>> response = client.send_request(request)
152+ <HttpResponse: 200 OK>
153+
154+ For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
155+
156+ :param request: The network request you want to make. Required.
157+ :type request: ~azure.core.rest.HttpRequest
158+ :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
159+ :return: The response of your network call. Does not do error handling on your response.
160+ :rtype: ~azure.core.rest.HttpResponse
161+ """
162+
163+ request_copy = deepcopy (request )
164+ path_format_arguments = {
165+ "endpoint" : self ._serialize .url ("self._config.endpoint" , self ._config .endpoint , "str" , skip_quote = True ),
166+ }
167+
168+ request_copy .url = self ._client .format_url (request_copy .url , ** path_format_arguments )
169+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
170+
171+ def close (self ) -> None :
172+ self ._client .close ()
173+
174+ def __enter__ (self ) -> "BlocklistClient" :
175+ self ._client .__enter__ ()
176+ return self
177+
178+ def __exit__ (self , * exc_details : Any ) -> None :
179+ self ._client .__exit__ (* exc_details )
0 commit comments