Skip to content

Commit 9a674e9

Browse files
author
SDKAuto
committed
CodeGen from PR 30924 in Azure/azure-rest-api-specs
Merge 113d3161e8a225aac25af3705971a5b45e3b775a into 63c41aa20e38fe6d2ddd1a367b4fe57e8b601c34
1 parent c065216 commit 9a674e9

File tree

96 files changed

+17625
-10135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+17625
-10135
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"commit": "37acfe2967e5e1be1169146ac461eb1875c9476e",
2+
"commit": "aea97f6dcb7b5c3039a82b7e54c49e35fe1106ac",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"typespec_src": "specification/ai/Face",
5-
"@azure-tools/typespec-python": "0.23.8",
6-
"@autorest/python": "6.13.15"
5+
"@azure-tools/typespec-python": "0.35.1"
76
}

sdk/face/azure-ai-vision-face/azure/ai/vision/face/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._patch import FaceClient
10-
from ._patch import FaceSessionClient
9+
from ._client import FaceAdministrationClient
10+
from ._client import FaceClient
11+
from ._client import FaceSessionClient
1112
from ._version import VERSION
1213

1314
__version__ = VERSION
1415

15-
16+
try:
17+
from ._patch import __all__ as _patch_all
18+
from ._patch import * # pylint: disable=unused-wildcard-import
19+
except ImportError:
20+
_patch_all = []
1621
from ._patch import patch_sdk as _patch_sdk
1722

1823
__all__ = [
24+
"FaceAdministrationClient",
1925
"FaceClient",
2026
"FaceSessionClient",
2127
]
22-
28+
__all__.extend([p for p in _patch_all if p not in __all__])
2329

2430
_patch_sdk()

sdk/face/azure-ai-vision-face/azure/ai/vision/face/_client.py

Lines changed: 109 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,120 @@
88

99
from copy import deepcopy
1010
from typing import Any, TYPE_CHECKING, Union
11+
from typing_extensions import Self
1112

1213
from azure.core import PipelineClient
1314
from azure.core.credentials import AzureKeyCredential
1415
from azure.core.pipeline import policies
1516
from azure.core.rest import HttpRequest, HttpResponse
1617

17-
from ._configuration import FaceClientConfiguration, FaceSessionClientConfiguration
18-
from ._operations import FaceClientOperationsMixin, FaceSessionClientOperationsMixin
18+
from ._configuration import (
19+
FaceAdministrationClientConfiguration,
20+
FaceClientConfiguration,
21+
FaceSessionClientConfiguration,
22+
)
1923
from ._serialization import Deserializer, Serializer
24+
from .operations import (
25+
FaceClientOperationsMixin,
26+
FaceSessionClientOperationsMixin,
27+
LargeFaceListOperations,
28+
LargePersonGroupOperations,
29+
)
2030

2131
if TYPE_CHECKING:
22-
# pylint: disable=unused-import,ungrouped-imports
2332
from azure.core.credentials import TokenCredential
2433

2534

26-
class FaceClient(FaceClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
35+
class FaceAdministrationClient:
36+
"""FaceAdministrationClient.
37+
38+
:ivar large_face_list: LargeFaceListOperations operations
39+
:vartype large_face_list: azure.ai.vision.face.operations.LargeFaceListOperations
40+
:ivar large_person_group: LargePersonGroupOperations operations
41+
:vartype large_person_group: azure.ai.vision.face.operations.LargePersonGroupOperations
42+
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
43+
https://{resource-name}.cognitiveservices.azure.com). Required.
44+
:type endpoint: str
45+
:param credential: Credential used to authenticate requests to the service. Is either a
46+
AzureKeyCredential type or a TokenCredential type. Required.
47+
:type credential: ~azure.core.credentials.AzureKeyCredential or
48+
~azure.core.credentials.TokenCredential
49+
:keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is
50+
"v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
51+
:paramtype api_version: str or ~azure.ai.vision.face.models.Versions
52+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
53+
Retry-After header is present.
54+
"""
55+
56+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
57+
_endpoint = "{endpoint}/face/{apiVersion}"
58+
self._config = FaceAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
59+
_policies = kwargs.pop("policies", None)
60+
if _policies is None:
61+
_policies = [
62+
policies.RequestIdPolicy(**kwargs),
63+
self._config.headers_policy,
64+
self._config.user_agent_policy,
65+
self._config.proxy_policy,
66+
policies.ContentDecodePolicy(**kwargs),
67+
self._config.redirect_policy,
68+
self._config.retry_policy,
69+
self._config.authentication_policy,
70+
self._config.custom_hook_policy,
71+
self._config.logging_policy,
72+
policies.DistributedTracingPolicy(**kwargs),
73+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
74+
self._config.http_logging_policy,
75+
]
76+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
77+
78+
self._serialize = Serializer()
79+
self._deserialize = Deserializer()
80+
self._serialize.client_side_validation = False
81+
self.large_face_list = LargeFaceListOperations(self._client, self._config, self._serialize, self._deserialize)
82+
self.large_person_group = LargePersonGroupOperations(
83+
self._client, self._config, self._serialize, self._deserialize
84+
)
85+
86+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
87+
"""Runs the network request through the client's chained policies.
88+
89+
>>> from azure.core.rest import HttpRequest
90+
>>> request = HttpRequest("GET", "https://www.example.org/")
91+
<HttpRequest [GET], url: 'https://www.example.org/'>
92+
>>> response = client.send_request(request)
93+
<HttpResponse: 200 OK>
94+
95+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
96+
97+
:param request: The network request you want to make. Required.
98+
:type request: ~azure.core.rest.HttpRequest
99+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
100+
:return: The response of your network call. Does not do error handling on your response.
101+
:rtype: ~azure.core.rest.HttpResponse
102+
"""
103+
104+
request_copy = deepcopy(request)
105+
path_format_arguments = {
106+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
107+
"apiVersion": self._serialize.url("self._config.api_version", self._config.api_version, "str"),
108+
}
109+
110+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
111+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
112+
113+
def close(self) -> None:
114+
self._client.close()
115+
116+
def __enter__(self) -> Self:
117+
self._client.__enter__()
118+
return self
119+
120+
def __exit__(self, *exc_details: Any) -> None:
121+
self._client.__exit__(*exc_details)
122+
123+
124+
class FaceClient(FaceClientOperationsMixin):
27125
"""FaceClient.
28126
29127
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
@@ -33,8 +131,8 @@ class FaceClient(FaceClientOperationsMixin): # pylint: disable=client-accepts-a
33131
AzureKeyCredential type or a TokenCredential type. Required.
34132
:type credential: ~azure.core.credentials.AzureKeyCredential or
35133
~azure.core.credentials.TokenCredential
36-
:keyword api_version: API Version. Default value is "v1.1-preview.1". Note that overriding this
37-
default value may result in unsupported behavior.
134+
:keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is
135+
"v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
38136
:paramtype api_version: str or ~azure.ai.vision.face.models.Versions
39137
"""
40138

@@ -94,15 +192,15 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
94192
def close(self) -> None:
95193
self._client.close()
96194

97-
def __enter__(self) -> "FaceClient":
195+
def __enter__(self) -> Self:
98196
self._client.__enter__()
99197
return self
100198

101199
def __exit__(self, *exc_details: Any) -> None:
102200
self._client.__exit__(*exc_details)
103201

104202

105-
class FaceSessionClient(FaceSessionClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
203+
class FaceSessionClient(FaceSessionClientOperationsMixin):
106204
"""FaceSessionClient.
107205
108206
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
@@ -112,8 +210,8 @@ class FaceSessionClient(FaceSessionClientOperationsMixin): # pylint: disable=cl
112210
AzureKeyCredential type or a TokenCredential type. Required.
113211
:type credential: ~azure.core.credentials.AzureKeyCredential or
114212
~azure.core.credentials.TokenCredential
115-
:keyword api_version: API Version. Default value is "v1.1-preview.1". Note that overriding this
116-
default value may result in unsupported behavior.
213+
:keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is
214+
"v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
117215
:paramtype api_version: str or ~azure.ai.vision.face.models.Versions
118216
"""
119217

@@ -173,7 +271,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
173271
def close(self) -> None:
174272
self._client.close()
175273

176-
def __enter__(self) -> "FaceSessionClient":
274+
def __enter__(self) -> Self:
177275
self._client.__enter__()
178276
return self
179277

sdk/face/azure-ai-vision-face/azure/ai/vision/face/_configuration.py

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,64 @@
1414
from ._version import VERSION
1515

1616
if TYPE_CHECKING:
17-
# pylint: disable=unused-import,ungrouped-imports
1817
from azure.core.credentials import TokenCredential
1918

2019

20+
class FaceAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes
21+
"""Configuration for FaceAdministrationClient.
22+
23+
Note that all parameters used to create this instance are saved as instance
24+
attributes.
25+
26+
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
27+
https://{resource-name}.cognitiveservices.azure.com). Required.
28+
:type endpoint: str
29+
:param credential: Credential used to authenticate requests to the service. Is either a
30+
AzureKeyCredential type or a TokenCredential type. Required.
31+
:type credential: ~azure.core.credentials.AzureKeyCredential or
32+
~azure.core.credentials.TokenCredential
33+
:keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is
34+
"v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
35+
:paramtype api_version: str or ~azure.ai.vision.face.models.Versions
36+
"""
37+
38+
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
39+
api_version: str = kwargs.pop("api_version", "v1.2-preview.1")
40+
41+
if endpoint is None:
42+
raise ValueError("Parameter 'endpoint' must not be None.")
43+
if credential is None:
44+
raise ValueError("Parameter 'credential' must not be None.")
45+
46+
self.endpoint = endpoint
47+
self.credential = credential
48+
self.api_version = api_version
49+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://cognitiveservices.azure.com/.default"])
50+
kwargs.setdefault("sdk_moniker", "ai-vision-face/{}".format(VERSION))
51+
self.polling_interval = kwargs.get("polling_interval", 30)
52+
self._configure(**kwargs)
53+
54+
def _infer_policy(self, **kwargs):
55+
if isinstance(self.credential, AzureKeyCredential):
56+
return policies.AzureKeyCredentialPolicy(self.credential, "Ocp-Apim-Subscription-Key", **kwargs)
57+
if hasattr(self.credential, "get_token"):
58+
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
59+
raise TypeError(f"Unsupported credential: {self.credential}")
60+
61+
def _configure(self, **kwargs: Any) -> None:
62+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
63+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
64+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
65+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
66+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
67+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
68+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
69+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
70+
self.authentication_policy = kwargs.get("authentication_policy")
71+
if self.credential and not self.authentication_policy:
72+
self.authentication_policy = self._infer_policy(**kwargs)
73+
74+
2175
class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes
2276
"""Configuration for FaceClient.
2377
@@ -31,13 +85,13 @@ class FaceClientConfiguration: # pylint: disable=too-many-instance-attributes
3185
AzureKeyCredential type or a TokenCredential type. Required.
3286
:type credential: ~azure.core.credentials.AzureKeyCredential or
3387
~azure.core.credentials.TokenCredential
34-
:keyword api_version: API Version. Default value is "v1.1-preview.1". Note that overriding this
35-
default value may result in unsupported behavior.
88+
:keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is
89+
"v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
3690
:paramtype api_version: str or ~azure.ai.vision.face.models.Versions
3791
"""
3892

3993
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
40-
api_version: str = kwargs.pop("api_version", "v1.1-preview.1")
94+
api_version: str = kwargs.pop("api_version", "v1.2-preview.1")
4195

4296
if endpoint is None:
4397
raise ValueError("Parameter 'endpoint' must not be None.")
@@ -73,7 +127,7 @@ def _configure(self, **kwargs: Any) -> None:
73127
self.authentication_policy = self._infer_policy(**kwargs)
74128

75129

76-
class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
130+
class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attributes
77131
"""Configuration for FaceSessionClient.
78132
79133
Note that all parameters used to create this instance are saved as instance
@@ -86,13 +140,13 @@ class FaceSessionClientConfiguration: # pylint: disable=too-many-instance-attri
86140
AzureKeyCredential type or a TokenCredential type. Required.
87141
:type credential: ~azure.core.credentials.AzureKeyCredential or
88142
~azure.core.credentials.TokenCredential
89-
:keyword api_version: API Version. Default value is "v1.1-preview.1". Note that overriding this
90-
default value may result in unsupported behavior.
143+
:keyword api_version: API Version. Known values are "v1.2-preview.1" and None. Default value is
144+
"v1.2-preview.1". Note that overriding this default value may result in unsupported behavior.
91145
:paramtype api_version: str or ~azure.ai.vision.face.models.Versions
92146
"""
93147

94148
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
95-
api_version: str = kwargs.pop("api_version", "v1.1-preview.1")
149+
api_version: str = kwargs.pop("api_version", "v1.2-preview.1")
96150

97151
if endpoint is None:
98152
raise ValueError("Parameter 'endpoint' must not be None.")

0 commit comments

Comments
 (0)