Skip to content

Commit 3dc0b64

Browse files
author
SDKAuto
committed
CodeGen from PR 31923 in Azure/azure-rest-api-specs
Merge 90f16a425cfa094ff3b3de820d526993be606f8c into 12492edbcf4c2d43d153da544ffbf1ffe7cbd20b
1 parent bf50574 commit 3dc0b64

File tree

70 files changed

+4504
-4777
lines changed

Some content is hidden

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

70 files changed

+4504
-4777
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "9cfaac4539426f741f8abd6e7b90b2d9b917c8cb",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/devcenter/DevCenter",
5+
"@azure-tools/typespec-python": "0.37.2"
6+
}

sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,32 @@
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 ._client import DevCenterClient
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 DevCenterClient # type: ignore
16+
from ._client import DevBoxesClient # type: ignore
17+
from ._client import DeploymentEnvironmentsClient # type: ignore
1018
from ._version import VERSION
1119

1220
__version__ = VERSION
1321

1422
try:
1523
from ._patch import __all__ as _patch_all
16-
from ._patch import * # pylint: disable=unused-wildcard-import
24+
from ._patch import *
1725
except ImportError:
1826
_patch_all = []
1927
from ._patch import patch_sdk as _patch_sdk
2028

2129
__all__ = [
2230
"DevCenterClient",
31+
"DevBoxesClient",
32+
"DeploymentEnvironmentsClient",
2333
]
24-
__all__.extend([p for p in _patch_all if p not in __all__])
34+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2535

2636
_patch_sdk()

sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_client.py

Lines changed: 166 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,106 @@
88

99
from copy import deepcopy
1010
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
1415
from azure.core.rest import HttpRequest, HttpResponse
1516

16-
from ._configuration import DevCenterClientConfiguration
17-
from ._operations import DevCenterClientOperationsMixin
17+
from ._configuration import (
18+
DeploymentEnvironmentsClientConfiguration,
19+
DevBoxesClientConfiguration,
20+
DevCenterClientConfiguration,
21+
)
22+
from ._operations import (
23+
DeploymentEnvironmentsClientOperationsMixin,
24+
DevBoxesClientOperationsMixin,
25+
DevCenterClientOperationsMixin,
26+
)
1827
from ._serialization import Deserializer, Serializer
1928

2029
if TYPE_CHECKING:
21-
# pylint: disable=unused-import,ungrouped-imports
2230
from azure.core.credentials import TokenCredential
2331

2432

25-
class DevCenterClient(DevCenterClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
33+
class DevCenterClient(DevCenterClientOperationsMixin):
2634
"""DevCenterClient.
2735
36+
:param endpoint: The DevCenter-specific URI to operate on. Required.
37+
:type endpoint: str
38+
:param credential: Credential used to authenticate requests to the service. Required.
39+
:type credential: ~azure.core.credentials.TokenCredential
40+
:keyword api_version: The API version to use for this operation. Default value is "2023-04-01".
41+
Note that overriding this default value may result in unsupported behavior.
42+
:paramtype api_version: str
43+
"""
44+
45+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
46+
_endpoint = "{endpoint}"
47+
self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
48+
_policies = kwargs.pop("policies", None)
49+
if _policies is None:
50+
_policies = [
51+
policies.RequestIdPolicy(**kwargs),
52+
self._config.headers_policy,
53+
self._config.user_agent_policy,
54+
self._config.proxy_policy,
55+
policies.ContentDecodePolicy(**kwargs),
56+
self._config.redirect_policy,
57+
self._config.retry_policy,
58+
self._config.authentication_policy,
59+
self._config.custom_hook_policy,
60+
self._config.logging_policy,
61+
policies.DistributedTracingPolicy(**kwargs),
62+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
63+
self._config.http_logging_policy,
64+
]
65+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
66+
67+
self._serialize = Serializer()
68+
self._deserialize = Deserializer()
69+
self._serialize.client_side_validation = False
70+
71+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
72+
"""Runs the network request through the client's chained policies.
73+
74+
>>> from azure.core.rest import HttpRequest
75+
>>> request = HttpRequest("GET", "https://www.example.org/")
76+
<HttpRequest [GET], url: 'https://www.example.org/'>
77+
>>> response = client.send_request(request)
78+
<HttpResponse: 200 OK>
79+
80+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
81+
82+
:param request: The network request you want to make. Required.
83+
:type request: ~azure.core.rest.HttpRequest
84+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
85+
:return: The response of your network call. Does not do error handling on your response.
86+
:rtype: ~azure.core.rest.HttpResponse
87+
"""
88+
89+
request_copy = deepcopy(request)
90+
path_format_arguments = {
91+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
92+
}
93+
94+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
95+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
96+
97+
def close(self) -> None:
98+
self._client.close()
99+
100+
def __enter__(self) -> Self:
101+
self._client.__enter__()
102+
return self
103+
104+
def __exit__(self, *exc_details: Any) -> None:
105+
self._client.__exit__(*exc_details)
106+
107+
108+
class DevBoxesClient(DevBoxesClientOperationsMixin):
109+
"""DevBoxesClient.
110+
28111
:param endpoint: The DevCenter-specific URI to operate on. Required.
29112
:type endpoint: str
30113
:param credential: Credential used to authenticate requests to the service. Required.
@@ -38,7 +121,84 @@ class DevCenterClient(DevCenterClientOperationsMixin): # pylint: disable=client
38121

39122
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
40123
_endpoint = "{endpoint}"
41-
self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
124+
self._config = DevBoxesClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
125+
_policies = kwargs.pop("policies", None)
126+
if _policies is None:
127+
_policies = [
128+
policies.RequestIdPolicy(**kwargs),
129+
self._config.headers_policy,
130+
self._config.user_agent_policy,
131+
self._config.proxy_policy,
132+
policies.ContentDecodePolicy(**kwargs),
133+
self._config.redirect_policy,
134+
self._config.retry_policy,
135+
self._config.authentication_policy,
136+
self._config.custom_hook_policy,
137+
self._config.logging_policy,
138+
policies.DistributedTracingPolicy(**kwargs),
139+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
140+
self._config.http_logging_policy,
141+
]
142+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
143+
144+
self._serialize = Serializer()
145+
self._deserialize = Deserializer()
146+
self._serialize.client_side_validation = False
147+
148+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
149+
"""Runs the network request through the client's chained policies.
150+
151+
>>> from azure.core.rest import HttpRequest
152+
>>> request = HttpRequest("GET", "https://www.example.org/")
153+
<HttpRequest [GET], url: 'https://www.example.org/'>
154+
>>> response = client.send_request(request)
155+
<HttpResponse: 200 OK>
156+
157+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
158+
159+
:param request: The network request you want to make. Required.
160+
:type request: ~azure.core.rest.HttpRequest
161+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
162+
:return: The response of your network call. Does not do error handling on your response.
163+
:rtype: ~azure.core.rest.HttpResponse
164+
"""
165+
166+
request_copy = deepcopy(request)
167+
path_format_arguments = {
168+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
169+
}
170+
171+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
172+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
173+
174+
def close(self) -> None:
175+
self._client.close()
176+
177+
def __enter__(self) -> Self:
178+
self._client.__enter__()
179+
return self
180+
181+
def __exit__(self, *exc_details: Any) -> None:
182+
self._client.__exit__(*exc_details)
183+
184+
185+
class DeploymentEnvironmentsClient(DeploymentEnvironmentsClientOperationsMixin):
186+
"""DeploymentEnvironmentsClient.
187+
188+
:param endpoint: The DevCenter-specific URI to operate on. Required.
189+
:type endpoint: str
190+
:param credential: Credential used to authenticate requests to the service. Required.
191+
:type credential: ~azure.core.credentials.TokenCredential
192+
:keyword api_version: The API version to use for this operation. Default value is "2023-04-01".
193+
Note that overriding this default value may result in unsupported behavior.
194+
:paramtype api_version: str
195+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
196+
Retry-After header is present.
197+
"""
198+
199+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
200+
_endpoint = "{endpoint}"
201+
self._config = DeploymentEnvironmentsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
42202
_policies = kwargs.pop("policies", None)
43203
if _policies is None:
44204
_policies = [
@@ -91,7 +251,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
91251
def close(self) -> None:
92252
self._client.close()
93253

94-
def __enter__(self) -> "DevCenterClient":
254+
def __enter__(self) -> Self:
95255
self._client.__enter__()
96256
return self
97257

sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_configuration.py

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
from ._version import VERSION
1414

1515
if TYPE_CHECKING:
16-
# pylint: disable=unused-import,ungrouped-imports
1716
from azure.core.credentials import TokenCredential
1817

1918

20-
class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
19+
class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attributes
2120
"""Configuration for DevCenterClient.
2221
2322
Note that all parameters used to create this instance are saved as instance
@@ -62,3 +61,97 @@ def _configure(self, **kwargs: Any) -> None:
6261
self.authentication_policy = policies.BearerTokenCredentialPolicy(
6362
self.credential, *self.credential_scopes, **kwargs
6463
)
64+
65+
66+
class DevBoxesClientConfiguration: # pylint: disable=too-many-instance-attributes
67+
"""Configuration for DevBoxesClient.
68+
69+
Note that all parameters used to create this instance are saved as instance
70+
attributes.
71+
72+
:param endpoint: The DevCenter-specific URI to operate on. Required.
73+
:type endpoint: str
74+
:param credential: Credential used to authenticate requests to the service. Required.
75+
:type credential: ~azure.core.credentials.TokenCredential
76+
:keyword api_version: The API version to use for this operation. Default value is "2023-04-01".
77+
Note that overriding this default value may result in unsupported behavior.
78+
:paramtype api_version: str
79+
"""
80+
81+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
82+
api_version: str = kwargs.pop("api_version", "2023-04-01")
83+
84+
if endpoint is None:
85+
raise ValueError("Parameter 'endpoint' must not be None.")
86+
if credential is None:
87+
raise ValueError("Parameter 'credential' must not be None.")
88+
89+
self.endpoint = endpoint
90+
self.credential = credential
91+
self.api_version = api_version
92+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"])
93+
kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION))
94+
self.polling_interval = kwargs.get("polling_interval", 30)
95+
self._configure(**kwargs)
96+
97+
def _configure(self, **kwargs: Any) -> None:
98+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
99+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
100+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
101+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
102+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
103+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
104+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
105+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
106+
self.authentication_policy = kwargs.get("authentication_policy")
107+
if self.credential and not self.authentication_policy:
108+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
109+
self.credential, *self.credential_scopes, **kwargs
110+
)
111+
112+
113+
class DeploymentEnvironmentsClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
114+
"""Configuration for DeploymentEnvironmentsClient.
115+
116+
Note that all parameters used to create this instance are saved as instance
117+
attributes.
118+
119+
:param endpoint: The DevCenter-specific URI to operate on. Required.
120+
:type endpoint: str
121+
:param credential: Credential used to authenticate requests to the service. Required.
122+
:type credential: ~azure.core.credentials.TokenCredential
123+
:keyword api_version: The API version to use for this operation. Default value is "2023-04-01".
124+
Note that overriding this default value may result in unsupported behavior.
125+
:paramtype api_version: str
126+
"""
127+
128+
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
129+
api_version: str = kwargs.pop("api_version", "2023-04-01")
130+
131+
if endpoint is None:
132+
raise ValueError("Parameter 'endpoint' must not be None.")
133+
if credential is None:
134+
raise ValueError("Parameter 'credential' must not be None.")
135+
136+
self.endpoint = endpoint
137+
self.credential = credential
138+
self.api_version = api_version
139+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"])
140+
kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION))
141+
self.polling_interval = kwargs.get("polling_interval", 30)
142+
self._configure(**kwargs)
143+
144+
def _configure(self, **kwargs: Any) -> None:
145+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
146+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
147+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
148+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
149+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
150+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
151+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
152+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
153+
self.authentication_policy = kwargs.get("authentication_policy")
154+
if self.credential and not self.authentication_policy:
155+
self.authentication_policy = policies.BearerTokenCredentialPolicy(
156+
self.credential, *self.credential_scopes, **kwargs
157+
)

0 commit comments

Comments
 (0)