Skip to content

Commit 713444e

Browse files
author
SDKAuto
committed
CodeGen from PR 3559 in test-repo-billy/azure-rest-api-specs
Merge 060e30d7a05928d0442267354fe4ccf0740e37ef into a1ece0d8092cbabd104c6a090519eb102db0c350
1 parent b2b0c35 commit 713444e

38 files changed

+3091
-4663
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "9458b84485608b75bb0aa3057a951e41102c6f40",
3+
"repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs",
4+
"typespec_src": "specification/devcenter/DevCenter",
5+
"@azure-tools/typespec-python": "0.31.1"
6+
}

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

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

99
from ._client import DevCenterClient
10+
from ._client import DevBoxesClient
11+
from ._client import DeploymentEnvironmentsClient
1012
from ._version import VERSION
1113

1214
__version__ = VERSION
@@ -20,6 +22,8 @@
2022

2123
__all__ = [
2224
"DevCenterClient",
25+
"DevBoxesClient",
26+
"DeploymentEnvironmentsClient",
2327
]
2428
__all__.extend([p for p in _patch_all if p not in __all__])
2529

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

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

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

94-
def __enter__(self) -> "DevCenterClient":
257+
def __enter__(self) -> Self:
95258
self._client.__enter__()
96259
return self
97260

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

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

0 commit comments

Comments
 (0)