Skip to content

Commit 7a93a56

Browse files
author
SDKAuto
committed
CodeGen from PR 31952 in Azure/azure-rest-api-specs
Merge bb4cbda86c234e2d0b985089df92a4a049f3e0ea into dfd52d5cdd667697e29289183e70655bc3a0d390
1 parent 8bff427 commit 7a93a56

File tree

80 files changed

+4476
-14292
lines changed

Some content is hidden

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

80 files changed

+4476
-14292
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "512df453da24a2293976afa64f1f1d2dbe6cee9d",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/communication/Communication.JobRouter",
5+
"@azure-tools/typespec-python": "0.37.2"
6+
}

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._patch import JobRouterAdministrationClient
10-
from ._patch import JobRouterClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import JobRouterAdministrationClient # type: ignore
16+
from ._client import JobRouterClient # type: ignore
1117
from ._version import VERSION
1218

1319
__version__ = VERSION
1420

1521
try:
1622
from ._patch import __all__ as _patch_all
17-
from ._patch import * # pylint: disable=unused-wildcard-import
23+
from ._patch import *
1824
except ImportError:
1925
_patch_all = []
2026
from ._patch import patch_sdk as _patch_sdk
@@ -23,6 +29,6 @@
2329
"JobRouterAdministrationClient",
2430
"JobRouterClient",
2531
]
26-
__all__.extend([p for p in _patch_all if p not in __all__])
32+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2733

2834
_patch_sdk()

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_api_versions.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_client.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# --------------------------------------------------------------------------
88

99
from copy import deepcopy
10-
from typing import Any
10+
from typing import Any, TYPE_CHECKING
11+
from typing_extensions import Self
1112

1213
from azure.core import PipelineClient
1314
from azure.core.pipeline import policies
@@ -17,25 +18,26 @@
1718
from ._operations import JobRouterAdministrationClientOperationsMixin, JobRouterClientOperationsMixin
1819
from ._serialization import Deserializer, Serializer
1920

21+
if TYPE_CHECKING:
22+
from azure.core.credentials import TokenCredential
2023

21-
class JobRouterAdministrationClient(
22-
JobRouterAdministrationClientOperationsMixin
23-
): # pylint: disable=client-accepts-api-version-keyword
24+
25+
class JobRouterAdministrationClient(JobRouterAdministrationClientOperationsMixin):
2426
"""JobRouterAdministrationClient.
2527
2628
:param endpoint: Uri of your Communication resource. Required.
2729
:type endpoint: str
30+
:param credential: Credential used to authenticate requests to the service. Required.
31+
:type credential: ~azure.core.credentials.TokenCredential
2832
:keyword api_version: The API version to use for this operation. Default value is
2933
"2024-01-18-preview". Note that overriding this default value may result in unsupported
3034
behavior.
3135
:paramtype api_version: str
3236
"""
3337

34-
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
35-
self, endpoint: str, **kwargs: Any
36-
) -> None:
38+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
3739
_endpoint = "{endpoint}"
38-
self._config = JobRouterAdministrationClientConfiguration(endpoint=endpoint, **kwargs)
40+
self._config = JobRouterAdministrationClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
3941
_policies = kwargs.pop("policies", None)
4042
if _policies is None:
4143
_policies = [
@@ -79,7 +81,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
7981

8082
request_copy = deepcopy(request)
8183
path_format_arguments = {
82-
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
84+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
8385
}
8486

8587
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
@@ -88,30 +90,30 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
8890
def close(self) -> None:
8991
self._client.close()
9092

91-
def __enter__(self) -> "JobRouterAdministrationClient":
93+
def __enter__(self) -> Self:
9294
self._client.__enter__()
9395
return self
9496

9597
def __exit__(self, *exc_details: Any) -> None:
9698
self._client.__exit__(*exc_details)
9799

98100

99-
class JobRouterClient(JobRouterClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
101+
class JobRouterClient(JobRouterClientOperationsMixin):
100102
"""JobRouterClient.
101103
102104
:param endpoint: Uri of your Communication resource. Required.
103105
:type endpoint: str
106+
:param credential: Credential used to authenticate requests to the service. Required.
107+
:type credential: ~azure.core.credentials.TokenCredential
104108
:keyword api_version: The API version to use for this operation. Default value is
105109
"2024-01-18-preview". Note that overriding this default value may result in unsupported
106110
behavior.
107111
:paramtype api_version: str
108112
"""
109113

110-
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
111-
self, endpoint: str, **kwargs: Any
112-
) -> None:
114+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
113115
_endpoint = "{endpoint}"
114-
self._config = JobRouterClientConfiguration(endpoint=endpoint, **kwargs)
116+
self._config = JobRouterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
115117
_policies = kwargs.pop("policies", None)
116118
if _policies is None:
117119
_policies = [
@@ -155,7 +157,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
155157

156158
request_copy = deepcopy(request)
157159
path_format_arguments = {
158-
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
160+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"),
159161
}
160162

161163
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
@@ -164,7 +166,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
164166
def close(self) -> None:
165167
self._client.close()
166168

167-
def __enter__(self) -> "JobRouterClient":
169+
def __enter__(self) -> Self:
168170
self._client.__enter__()
169171
return self
170172

sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_configuration.py

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

9-
from typing import Any
9+
from typing import Any, TYPE_CHECKING
1010

1111
from azure.core.pipeline import policies
1212

1313
from ._version import VERSION
1414

15+
if TYPE_CHECKING:
16+
from azure.core.credentials import TokenCredential
17+
1518

1619
class JobRouterAdministrationClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
1720
"""Configuration for JobRouterAdministrationClient.
@@ -21,20 +24,26 @@ class JobRouterAdministrationClientConfiguration: # pylint: disable=too-many-in
2124
2225
:param endpoint: Uri of your Communication resource. Required.
2326
:type endpoint: str
27+
:param credential: Credential used to authenticate requests to the service. Required.
28+
:type credential: ~azure.core.credentials.TokenCredential
2429
:keyword api_version: The API version to use for this operation. Default value is
2530
"2024-01-18-preview". Note that overriding this default value may result in unsupported
2631
behavior.
2732
:paramtype api_version: str
2833
"""
2934

30-
def __init__(self, endpoint: str, **kwargs: Any) -> None:
35+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
3136
api_version: str = kwargs.pop("api_version", "2024-01-18-preview")
3237

3338
if endpoint is None:
3439
raise ValueError("Parameter 'endpoint' must not be None.")
40+
if credential is None:
41+
raise ValueError("Parameter 'credential' must not be None.")
3542

3643
self.endpoint = endpoint
44+
self.credential = credential
3745
self.api_version = api_version
46+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://communication.azure.com/.default"])
3847
kwargs.setdefault("sdk_moniker", "communication-jobrouter/{}".format(VERSION))
3948
self.polling_interval = kwargs.get("polling_interval", 30)
4049
self._configure(**kwargs)
@@ -49,30 +58,40 @@ def _configure(self, **kwargs: Any) -> None:
4958
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
5059
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5160
self.authentication_policy = kwargs.get("authentication_policy")
61+
if self.credential and not self.authentication_policy:
62+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
63+
self.credential, *self.credential_scopes, **kwargs
64+
)
5265

5366

54-
class JobRouterClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
67+
class JobRouterClientConfiguration: # pylint: disable=too-many-instance-attributes
5568
"""Configuration for JobRouterClient.
5669
5770
Note that all parameters used to create this instance are saved as instance
5871
attributes.
5972
6073
:param endpoint: Uri of your Communication resource. Required.
6174
:type endpoint: str
75+
:param credential: Credential used to authenticate requests to the service. Required.
76+
:type credential: ~azure.core.credentials.TokenCredential
6277
:keyword api_version: The API version to use for this operation. Default value is
6378
"2024-01-18-preview". Note that overriding this default value may result in unsupported
6479
behavior.
6580
:paramtype api_version: str
6681
"""
6782

68-
def __init__(self, endpoint: str, **kwargs: Any) -> None:
83+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
6984
api_version: str = kwargs.pop("api_version", "2024-01-18-preview")
7085

7186
if endpoint is None:
7287
raise ValueError("Parameter 'endpoint' must not be None.")
88+
if credential is None:
89+
raise ValueError("Parameter 'credential' must not be None.")
7390

7491
self.endpoint = endpoint
92+
self.credential = credential
7593
self.api_version = api_version
94+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://communication.azure.com/.default"])
7695
kwargs.setdefault("sdk_moniker", "communication-jobrouter/{}".format(VERSION))
7796
self.polling_interval = kwargs.get("polling_interval", 30)
7897
self._configure(**kwargs)
@@ -87,3 +106,7 @@ def _configure(self, **kwargs: Any) -> None:
87106
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
88107
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
89108
self.authentication_policy = kwargs.get("authentication_policy")
109+
if self.credential and not self.authentication_policy:
110+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
111+
self.credential, *self.credential_scopes, **kwargs
112+
)

0 commit comments

Comments
 (0)