diff --git a/sdk/devcenter/azure-developer-devcenter/_meta.json b/sdk/devcenter/azure-developer-devcenter/_meta.json new file mode 100644 index 000000000000..4ea96cca6a53 --- /dev/null +++ b/sdk/devcenter/azure-developer-devcenter/_meta.json @@ -0,0 +1,6 @@ +{ + "commit": "e8136c11848f05e79597bab310539c506b4af9df", + "repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs", + "typespec_src": "specification/devcenter/DevCenter", + "@azure-tools/typespec-python": "0.29.0" +} \ No newline at end of file diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/__init__.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/__init__.py index 7590310c9bda..127a6278a2e3 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/__init__.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/__init__.py @@ -7,6 +7,8 @@ # -------------------------------------------------------------------------- from ._client import DevCenterClient +from ._client import DevBoxesClient +from ._client import DeploymentEnvironmentsClient from ._version import VERSION __version__ = VERSION @@ -20,6 +22,8 @@ __all__ = [ "DevCenterClient", + "DevBoxesClient", + "DeploymentEnvironmentsClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_client.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_client.py index df902c7477b9..4395600b1bf5 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_client.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_client.py @@ -8,13 +8,22 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core import PipelineClient from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse -from ._configuration import DevCenterClientConfiguration -from ._operations import DevCenterClientOperationsMixin +from ._configuration import ( + DeploymentEnvironmentsClientConfiguration, + DevBoxesClientConfiguration, + DevCenterClientConfiguration, +) +from ._operations import ( + DeploymentEnvironmentsClientOperationsMixin, + DevBoxesClientOperationsMixin, + DevCenterClientOperationsMixin, +) from ._serialization import Deserializer, Serializer if TYPE_CHECKING: @@ -25,6 +34,81 @@ class DevCenterClient(DevCenterClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """DevCenterClient. + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + _endpoint = "{endpoint}" + self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) + + +class DevBoxesClient(DevBoxesClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """DevBoxesClient. + :param endpoint: The DevCenter-specific URI to operate on. Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. @@ -38,7 +122,86 @@ class DevCenterClient(DevCenterClientOperationsMixin): # pylint: disable=client def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: _endpoint = "{endpoint}" - self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = DevBoxesClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) + + +class DeploymentEnvironmentsClient( + DeploymentEnvironmentsClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword + """DeploymentEnvironmentsClient. + + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + _endpoint = "{endpoint}" + self._config = DeploymentEnvironmentsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -91,7 +254,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "DevCenterClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_configuration.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_configuration.py index e37ae956cc25..94962f39d27d 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_configuration.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_configuration.py @@ -62,3 +62,97 @@ def _configure(self, **kwargs: Any) -> None: self.authentication_policy = policies.BearerTokenCredentialPolicy( self.credential, *self.credential_scopes, **kwargs ) + + +class DevBoxesClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for DevBoxesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-04-01") + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.endpoint = endpoint + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) + + +class DeploymentEnvironmentsClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for DeploymentEnvironmentsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-04-01") + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.endpoint = endpoint + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_model_base.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_model_base.py index 4b0f59f73e4c..c4b1008c1e85 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_model_base.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_model_base.py @@ -6,6 +6,7 @@ # -------------------------------------------------------------------------- # pylint: disable=protected-access, arguments-differ, signature-differs, broad-except +import copy import calendar import decimal import functools @@ -475,6 +476,9 @@ def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typin class Model(_MyMutableMapping): _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: class_name = self.__class__.__name__ @@ -507,24 +511,27 @@ def copy(self) -> "Model": return Model(self.__dict__) def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument - # we know the last three classes in mro are going to be 'Model', 'dict', and 'object' - mros = cls.__mro__[:-3][::-1] # ignore model, dict, and object parents, and reverse the mro order - attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property - k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") - } - annotations = { - k: v - for mro_class in mros - if hasattr(mro_class, "__annotations__") # pylint: disable=no-member - for k, v in mro_class.__annotations__.items() # pylint: disable=no-member - } - for attr, rf in attr_to_rest_field.items(): - rf._module = cls.__module__ - if not rf._type: - rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) - if not rf._rest_name_input: - rf._rest_name_input = attr - cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") # pylint: disable=no-member + for k, v in mro_class.__annotations__.items() # pylint: disable=no-member + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") return super().__new__(cls) # pylint: disable=no-value-for-parameter @@ -562,6 +569,7 @@ def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing. """ result = {} + readonly_props = [] if exclude_readonly: readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] for k, v in self.items(): @@ -639,6 +647,13 @@ def _deserialize_sequence( return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912 annotation: typing.Any, module: typing.Optional[str], @@ -680,21 +695,25 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, # is it optional? try: if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore - if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore - ) - - return functools.partial(_deserialize_with_optional, if_obj_deserializer) + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) except AttributeError: pass + # is it union? if getattr(annotation, "__origin__", None) is typing.Union: # initial ordering is we make `string` the last deserialization option, because it is often them most generic deserializers = [ _get_deserialize_callable_from_annotation(arg, module, rf) - for arg in sorted( - annotation.__args__, key=lambda x: hasattr(x, "__name__") and x.__name__ == "str" # pyright: ignore - ) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore ] return functools.partial(_deserialize_with_union, deserializers) @@ -871,5 +890,6 @@ def rest_discriminator( *, name: typing.Optional[str] = None, type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, ) -> typing.Any: - return _RestField(name=name, type=type, is_discriminator=True) + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility) diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/__init__.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/__init__.py index 32322330a2b5..34a148666638 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/__init__.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/__init__.py @@ -7,6 +7,8 @@ # -------------------------------------------------------------------------- from ._operations import DevCenterClientOperationsMixin +from ._operations import DevBoxesClientOperationsMixin +from ._operations import DeploymentEnvironmentsClientOperationsMixin from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -14,6 +16,8 @@ __all__ = [ "DevCenterClientOperationsMixin", + "DevBoxesClientOperationsMixin", + "DeploymentEnvironmentsClientOperationsMixin", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/_operations.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/_operations.py index 825ae666ecff..c32182364630 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/_operations.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_operations/_operations.py @@ -10,7 +10,7 @@ from io import IOBase import json import sys -from typing import Any, Callable, Dict, IO, Iterable, List, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -19,6 +19,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged @@ -32,15 +34,15 @@ from .. import models as _models from .._model_base import SdkJSONEncoder, _deserialize from .._serialization import Serializer -from .._vendor import DevCenterClientMixinABC +from .._vendor import DeploymentEnvironmentsClientMixinABC, DevBoxesClientMixinABC, DevCenterClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False @@ -89,7 +91,7 @@ def build_dev_center_get_project_request(project_name: str, **kwargs: Any) -> Ht return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_pools_request(project_name: str, **kwargs: Any) -> HttpRequest: +def build_dev_boxes_list_pools_request(project_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -113,7 +115,7 @@ def build_dev_center_list_pools_request(project_name: str, **kwargs: Any) -> Htt return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_pool_request(project_name: str, pool_name: str, **kwargs: Any) -> HttpRequest: +def build_dev_boxes_get_pool_request(project_name: str, pool_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -138,7 +140,7 @@ def build_dev_center_get_pool_request(project_name: str, pool_name: str, **kwarg return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_schedules_request(project_name: str, pool_name: str, **kwargs: Any) -> HttpRequest: +def build_dev_boxes_list_schedules_request(project_name: str, pool_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -163,7 +165,7 @@ def build_dev_center_list_schedules_request(project_name: str, pool_name: str, * return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_schedule_request( +def build_dev_boxes_get_schedule_request( project_name: str, pool_name: str, schedule_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -191,7 +193,7 @@ def build_dev_center_get_schedule_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_all_dev_boxes_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_dev_boxes_list_all_dev_boxes_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -210,7 +212,7 @@ def build_dev_center_list_all_dev_boxes_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_all_dev_boxes_by_user_request( # pylint: disable=name-too-long +def build_dev_boxes_list_all_dev_boxes_by_user_request( # pylint: disable=name-too-long user_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -236,7 +238,7 @@ def build_dev_center_list_all_dev_boxes_by_user_request( # pylint: disable=name return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_dev_boxes_request(project_name: str, user_id: str, **kwargs: Any) -> HttpRequest: +def build_dev_boxes_list_dev_boxes_request(project_name: str, user_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -261,7 +263,7 @@ def build_dev_center_list_dev_boxes_request(project_name: str, user_id: str, **k return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_dev_box_request( +def build_dev_boxes_get_dev_box_request( project_name: str, user_id: str, dev_box_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -289,7 +291,7 @@ def build_dev_center_get_dev_box_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_create_dev_box_request( +def build_dev_boxes_create_dev_box_request( project_name: str, user_id: str, dev_box_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -320,7 +322,7 @@ def build_dev_center_create_dev_box_request( return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_delete_dev_box_request( +def build_dev_boxes_delete_dev_box_request( project_name: str, user_id: str, dev_box_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -348,7 +350,7 @@ def build_dev_center_delete_dev_box_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_start_dev_box_request( +def build_dev_boxes_start_dev_box_request( project_name: str, user_id: str, dev_box_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -376,7 +378,7 @@ def build_dev_center_start_dev_box_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_stop_dev_box_request( +def build_dev_boxes_stop_dev_box_request( project_name: str, user_id: str, dev_box_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -406,7 +408,7 @@ def build_dev_center_stop_dev_box_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_restart_dev_box_request( +def build_dev_boxes_restart_dev_box_request( project_name: str, user_id: str, dev_box_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -434,7 +436,7 @@ def build_dev_center_restart_dev_box_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_remote_connection_request( # pylint: disable=name-too-long +def build_dev_boxes_get_remote_connection_request( # pylint: disable=name-too-long project_name: str, user_id: str, dev_box_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -462,7 +464,7 @@ def build_dev_center_get_remote_connection_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_dev_box_actions_request( # pylint: disable=name-too-long +def build_dev_boxes_list_dev_box_actions_request( # pylint: disable=name-too-long project_name: str, user_id: str, dev_box_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -490,7 +492,7 @@ def build_dev_center_list_dev_box_actions_request( # pylint: disable=name-too-l return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_dev_box_action_request( # pylint: disable=name-too-long +def build_dev_boxes_get_dev_box_action_request( # pylint: disable=name-too-long project_name: str, user_id: str, dev_box_name: str, action_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -519,7 +521,7 @@ def build_dev_center_get_dev_box_action_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_skip_dev_box_action_request( # pylint: disable=name-too-long +def build_dev_boxes_skip_action_request( project_name: str, user_id: str, dev_box_name: str, action_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -548,7 +550,7 @@ def build_dev_center_skip_dev_box_action_request( # pylint: disable=name-too-lo return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_delay_dev_box_action_request( # pylint: disable=name-too-long +def build_dev_boxes_delay_action_request( project_name: str, user_id: str, dev_box_name: str, @@ -584,7 +586,7 @@ def build_dev_center_delay_dev_box_action_request( # pylint: disable=name-too-l return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_delay_all_dev_box_actions_request( # pylint: disable=name-too-long +def build_dev_boxes_delay_all_actions_request( # pylint: disable=name-too-long project_name: str, user_id: str, dev_box_name: str, *, delay_until: datetime.datetime, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -613,7 +615,7 @@ def build_dev_center_delay_all_dev_box_actions_request( # pylint: disable=name- return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_all_environments_request( # pylint: disable=name-too-long +def build_deployment_environments_list_all_environments_request( # pylint: disable=name-too-long project_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -639,7 +641,7 @@ def build_dev_center_list_all_environments_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_environments_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environments_request( # pylint: disable=name-too-long project_name: str, user_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -666,7 +668,7 @@ def build_dev_center_list_environments_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_environment_request( +def build_deployment_environments_get_environment_request( # pylint: disable=name-too-long project_name: str, user_id: str, environment_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -694,7 +696,7 @@ def build_dev_center_get_environment_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_create_or_update_environment_request( # pylint: disable=name-too-long +def build_deployment_environments_create_or_update_environment_request( # pylint: disable=name-too-long project_name: str, user_id: str, environment_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -725,7 +727,7 @@ def build_dev_center_create_or_update_environment_request( # pylint: disable=na return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_delete_environment_request( # pylint: disable=name-too-long +def build_deployment_environments_delete_environment_request( # pylint: disable=name-too-long project_name: str, user_id: str, environment_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -753,7 +755,9 @@ def build_dev_center_delete_environment_request( # pylint: disable=name-too-lon return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_catalogs_request(project_name: str, **kwargs: Any) -> HttpRequest: +def build_deployment_environments_list_catalogs_request( # pylint: disable=name-too-long + project_name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -777,7 +781,9 @@ def build_dev_center_list_catalogs_request(project_name: str, **kwargs: Any) -> return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_catalog_request(project_name: str, catalog_name: str, **kwargs: Any) -> HttpRequest: +def build_deployment_environments_get_catalog_request( # pylint: disable=name-too-long + project_name: str, catalog_name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -802,7 +808,7 @@ def build_dev_center_get_catalog_request(project_name: str, catalog_name: str, * return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_environment_definitions_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environment_definitions_request( # pylint: disable=name-too-long project_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -828,7 +834,7 @@ def build_dev_center_list_environment_definitions_request( # pylint: disable=na return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_environment_definitions_by_catalog_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environment_definitions_by_catalog_request( # pylint: disable=name-too-long project_name: str, catalog_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -855,7 +861,7 @@ def build_dev_center_list_environment_definitions_by_catalog_request( # pylint: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_get_environment_definition_request( # pylint: disable=name-too-long +def build_deployment_environments_get_environment_definition_request( # pylint: disable=name-too-long project_name: str, catalog_name: str, definition_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -883,7 +889,7 @@ def build_dev_center_get_environment_definition_request( # pylint: disable=name return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_center_list_environment_types_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environment_types_request( # pylint: disable=name-too-long project_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -909,27 +915,15 @@ def build_dev_center_list_environment_types_request( # pylint: disable=name-too return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class DevCenterClientOperationsMixin(DevCenterClientMixinABC): # pylint: disable=too-many-public-methods +class DevCenterClientOperationsMixin(DevCenterClientMixinABC): @distributed_trace def list_projects(self, **kwargs: Any) -> Iterable["_models.Project"]: - # pylint: disable=line-too-long """Lists all projects. :return: An iterator like instance of Project :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.Project] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Name of the project. Required. - "description": "str", # Optional. Description of the project. - "maxDevBoxesPerUser": 0 # Optional. When specified, indicates the maximum - number of Dev Boxes a single user can create across all pools in the project. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -998,8 +992,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1009,7 +1001,6 @@ def get_next(next_link=None): @distributed_trace def get_project(self, project_name: str, **kwargs: Any) -> _models.Project: - # pylint: disable=line-too-long """Gets a project. :param project_name: Name of the project. Required. @@ -1017,17 +1008,6 @@ def get_project(self, project_name: str, **kwargs: Any) -> _models.Project: :return: Project. The Project is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Project :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Name of the project. Required. - "description": "str", # Optional. Description of the project. - "maxDevBoxesPerUser": 0 # Optional. When specified, indicates the maximum - number of Dev Boxes a single user can create across all pools in the project. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -1062,7 +1042,10 @@ def get_project(self, project_name: str, **kwargs: Any) -> _models.Project: if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1076,9 +1059,11 @@ def get_project(self, project_name: str, **kwargs: Any) -> _models.Project: return deserialized # type: ignore + +class DevBoxesClientOperationsMixin(DevBoxesClientMixinABC): # pylint: disable=too-many-public-methods + @distributed_trace def list_pools(self, project_name: str, **kwargs: Any) -> Iterable["_models.Pool"]: - # pylint: disable=line-too-long """Lists available pools. :param project_name: Name of the project. Required. @@ -1086,68 +1071,6 @@ def list_pools(self, project_name: str, **kwargs: Any) -> Iterable["_models.Pool :return: An iterator like instance of Pool :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.Pool] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "healthStatus": "str", # Overall health status of the Pool. Indicates - whether or not the Pool is available to create Dev Boxes. Required. Known values - are: "Unknown", "Pending", "Healthy", "Warning", and "Unhealthy". - "location": "str", # Azure region where Dev Boxes in the pool are located. - Required. - "name": "str", # Pool name. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether owners of Dev - Boxes in this pool are local administrators on the Dev Boxes. Known values are: - "Enabled" and "Disabled". - "osType": "str", # Optional. The operating system type of Dev Boxes in this - pool. "Windows" - "stopOnDisconnect": { - "status": "str", # Indicates whether the feature to stop the devbox - on disconnect once the grace period has lapsed is enabled. Required. Known - values are: "Enabled" and "Disabled". - "gracePeriodMinutes": 0 # Optional. The specified time in minutes to - wait before stopping a Dev Box once disconnect is detected. - }, - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1165,7 +1088,7 @@ def list_pools(self, project_name: str, **kwargs: Any) -> Iterable["_models.Pool def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_pools_request( + _request = build_dev_boxes_list_pools_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -1217,8 +1140,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1228,7 +1149,6 @@ def get_next(next_link=None): @distributed_trace def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _models.Pool: - # pylint: disable=line-too-long """Gets a pool. :param project_name: Name of the project. Required. @@ -1238,68 +1158,6 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _models. :return: Pool. The Pool is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Pool :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "healthStatus": "str", # Overall health status of the Pool. Indicates - whether or not the Pool is available to create Dev Boxes. Required. Known values - are: "Unknown", "Pending", "Healthy", "Warning", and "Unhealthy". - "location": "str", # Azure region where Dev Boxes in the pool are located. - Required. - "name": "str", # Pool name. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether owners of Dev - Boxes in this pool are local administrators on the Dev Boxes. Known values are: - "Enabled" and "Disabled". - "osType": "str", # Optional. The operating system type of Dev Boxes in this - pool. "Windows" - "stopOnDisconnect": { - "status": "str", # Indicates whether the feature to stop the devbox - on disconnect once the grace period has lapsed is enabled. Required. Known - values are: "Enabled" and "Disabled". - "gracePeriodMinutes": 0 # Optional. The specified time in minutes to - wait before stopping a Dev Box once disconnect is detected. - }, - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - } - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -1314,7 +1172,7 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _models. cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - _request = build_dev_center_get_pool_request( + _request = build_dev_boxes_get_pool_request( project_name=project_name, pool_name=pool_name, api_version=self._config.api_version, @@ -1335,7 +1193,10 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _models. if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1360,22 +1221,6 @@ def list_schedules(self, project_name: str, pool_name: str, **kwargs: Any) -> It :return: An iterator like instance of Schedule :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "frequency": "str", # The frequency of this scheduled task. Required. - "Daily" - "name": "str", # Display name for the Schedule. Required. - "time": "str", # The target time to trigger the action. The format is HH:MM. - Required. - "timeZone": "str", # The IANA timezone id at which the schedule should - execute. Required. - "type": "str" # Supported type this scheduled task represents. Required. - "StopDevBox" - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1393,7 +1238,7 @@ def list_schedules(self, project_name: str, pool_name: str, **kwargs: Any) -> It def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_schedules_request( + _request = build_dev_boxes_list_schedules_request( project_name=project_name, pool_name=pool_name, api_version=self._config.api_version, @@ -1446,8 +1291,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1468,22 +1311,6 @@ def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, ** :return: Schedule. The Schedule is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "frequency": "str", # The frequency of this scheduled task. Required. - "Daily" - "name": "str", # Display name for the Schedule. Required. - "time": "str", # The target time to trigger the action. The format is HH:MM. - Required. - "timeZone": "str", # The IANA timezone id at which the schedule should - execute. Required. - "type": "str" # Supported type this scheduled task represents. Required. - "StopDevBox" - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -1498,7 +1325,7 @@ def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, ** cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) - _request = build_dev_center_get_schedule_request( + _request = build_dev_boxes_get_schedule_request( project_name=project_name, pool_name=pool_name, schedule_name=schedule_name, @@ -1520,7 +1347,10 @@ def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, ** if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1536,97 +1366,11 @@ def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, ** @distributed_trace def list_all_dev_boxes(self, **kwargs: Any) -> Iterable["_models.DevBox"]: - # pylint: disable=line-too-long """Lists Dev Boxes that the caller has access to in the DevCenter. :return: An iterator like instance of DevBox :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.DevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1644,7 +1388,7 @@ def list_all_dev_boxes(self, **kwargs: Any) -> Iterable["_models.DevBox"]: def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_all_dev_boxes_request( + _request = build_dev_boxes_list_all_dev_boxes_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -1695,8 +1439,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1706,7 +1448,6 @@ def get_next(next_link=None): @distributed_trace def list_all_dev_boxes_by_user(self, user_id: str, **kwargs: Any) -> Iterable["_models.DevBox"]: - # pylint: disable=line-too-long """Lists Dev Boxes in the Dev Center for a particular user. :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the @@ -1715,91 +1456,6 @@ def list_all_dev_boxes_by_user(self, user_id: str, **kwargs: Any) -> Iterable["_ :return: An iterator like instance of DevBox :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.DevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1817,7 +1473,7 @@ def list_all_dev_boxes_by_user(self, user_id: str, **kwargs: Any) -> Iterable["_ def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_all_dev_boxes_by_user_request( + _request = build_dev_boxes_list_all_dev_boxes_by_user_request( user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -1869,8 +1525,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1880,7 +1534,6 @@ def get_next(next_link=None): @distributed_trace def list_dev_boxes(self, project_name: str, user_id: str, **kwargs: Any) -> Iterable["_models.DevBox"]: - # pylint: disable=line-too-long """Lists Dev Boxes in the project for a particular user. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -1891,91 +1544,6 @@ def list_dev_boxes(self, project_name: str, user_id: str, **kwargs: Any) -> Iter :return: An iterator like instance of DevBox :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.DevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1993,7 +1561,7 @@ def list_dev_boxes(self, project_name: str, user_id: str, **kwargs: Any) -> Iter def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_dev_boxes_request( + _request = build_dev_boxes_list_dev_boxes_request( project_name=project_name, user_id=user_id, api_version=self._config.api_version, @@ -2046,8 +1614,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2057,7 +1623,6 @@ def get_next(next_link=None): @distributed_trace def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any) -> _models.DevBox: - # pylint: disable=line-too-long """Gets a Dev Box. :param project_name: Name of the project. Required. @@ -2070,91 +1635,6 @@ def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, **kwar :return: DevBox. The DevBox is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.DevBox :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -2169,7 +1649,7 @@ def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, **kwar cls: ClsType[_models.DevBox] = kwargs.pop("cls", None) - _request = build_dev_center_get_dev_box_request( + _request = build_dev_boxes_get_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2191,7 +1671,10 @@ def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, **kwar if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2212,7 +1695,7 @@ def _create_dev_box_initial( dev_box_name: str, body: Union[_models.DevBox, JSON, IO[bytes]], **kwargs: Any - ) -> JSON: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2225,7 +1708,7 @@ def _create_dev_box_initial( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -2234,7 +1717,7 @@ def _create_dev_box_initial( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_dev_center_create_dev_box_request( + _request = build_dev_boxes_create_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2249,7 +1732,7 @@ def _create_dev_box_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2257,22 +1740,21 @@ def _create_dev_box_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: - deserialized = _deserialize(JSON, response.json()) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Operation-Location"] = self._deserialize( "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2289,8 +1771,7 @@ def begin_create_dev_box( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -2306,177 +1787,10 @@ def begin_create_dev_box( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of LROPoller that returns ErrorResponseDevBox. The ErrorResponseDevBox is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ @overload @@ -2489,8 +1803,7 @@ def begin_create_dev_box( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -2506,95 +1819,10 @@ def begin_create_dev_box( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of LROPoller that returns ErrorResponseDevBox. The ErrorResponseDevBox is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ @overload @@ -2607,8 +1835,7 @@ def begin_create_dev_box( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -2624,95 +1851,10 @@ def begin_create_dev_box( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of LROPoller that returns ErrorResponseDevBox. The ErrorResponseDevBox is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ @distributed_trace @@ -2723,8 +1865,7 @@ def begin_create_dev_box( dev_box_name: str, body: Union[_models.DevBox, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -2738,183 +1879,16 @@ def begin_create_dev_box( Optionally set the owner of the Dev Box as local administrator. Is one of the following types: DevBox, JSON, IO[bytes] Required. :type body: ~azure.developer.devcenter.models.DevBox or JSON or IO[bytes] - :return: An instance of LROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of LROPoller that returns ErrorResponseDevBox. The ErrorResponseDevBox is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevBox] = kwargs.pop("cls", None) + cls: ClsType[_models.ErrorResponseDevBox] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -2930,11 +1904,12 @@ def begin_create_dev_box( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.DevBox, response.json()) + deserialized = _deserialize(_models.ErrorResponseDevBox, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2952,19 +1927,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.DevBox].from_continuation_token( + return LROPoller[_models.ErrorResponseDevBox].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.DevBox]( + return LROPoller[_models.ErrorResponseDevBox]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) def _delete_dev_box_initial( self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> Optional[JSON]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2976,9 +1951,9 @@ def _delete_dev_box_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_delete_dev_box_request( + _request = build_dev_boxes_delete_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2991,7 +1966,7 @@ def _delete_dev_box_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2999,12 +1974,13 @@ def _delete_dev_box_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -3012,7 +1988,7 @@ def _delete_dev_box_initial( "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3022,8 +1998,7 @@ def _delete_dev_box_initial( @distributed_trace def begin_delete_dev_box( self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> LROPoller[None]: """Deletes a Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -3033,49 +2008,14 @@ def begin_delete_dev_box( :type user_id: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :return: An instance of LROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -3089,20 +2029,12 @@ def begin_delete_dev_box( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -3117,17 +2049,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.OperationDetails].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any) -> JSON: + def _start_dev_box_initial( + self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3139,9 +2071,9 @@ def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_start_dev_box_request( + _request = build_dev_boxes_start_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3154,7 +2086,7 @@ def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3162,15 +2094,17 @@ def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3178,10 +2112,7 @@ def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: return deserialized # type: ignore @distributed_trace - def begin_start_dev_box( - self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + def begin_start_dev_box(self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any) -> LROPoller[None]: """Starts a Dev Box. :param project_name: Name of the project. Required. @@ -3191,49 +2122,14 @@ def begin_start_dev_box( :type user_id: str :param dev_box_name: Display name for the Dev Box. Required. :type dev_box_name: str - :return: An instance of LROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -3247,19 +2143,12 @@ def begin_start_dev_box( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -3274,19 +2163,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.OperationDetails].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _stop_dev_box_initial( self, project_name: str, user_id: str, dev_box_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any - ) -> JSON: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3298,9 +2185,9 @@ def _stop_dev_box_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_stop_dev_box_request( + _request = build_dev_boxes_stop_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3314,7 +2201,7 @@ def _stop_dev_box_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3322,15 +2209,17 @@ def _stop_dev_box_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3340,8 +2229,7 @@ def _stop_dev_box_initial( @distributed_trace def begin_stop_dev_box( self, project_name: str, user_id: str, dev_box_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any - ) -> LROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> LROPoller[None]: """Stops a Dev Box. :param project_name: Name of the project. Required. @@ -3353,49 +2241,14 @@ def begin_stop_dev_box( :type dev_box_name: str :keyword hibernate: Optional parameter to hibernate the dev box. Default value is None. :paramtype hibernate: bool - :return: An instance of LROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -3410,19 +2263,12 @@ def begin_stop_dev_box( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -3437,17 +2283,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.OperationDetails].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any) -> JSON: + def _restart_dev_box_initial( + self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3459,9 +2305,9 @@ def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_box_name _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_restart_dev_box_request( + _request = build_dev_boxes_restart_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3474,7 +2320,7 @@ def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_box_name } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3482,15 +2328,17 @@ def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_box_name response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3500,8 +2348,7 @@ def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_box_name @distributed_trace def begin_restart_dev_box( self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> LROPoller[None]: """Restarts a Dev Box. :param project_name: Name of the project. Required. @@ -3511,49 +2358,14 @@ def begin_restart_dev_box( :type user_id: str :param dev_box_name: Display name for the Dev Box. Required. :type dev_box_name: str - :return: An instance of LROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -3567,19 +2379,12 @@ def begin_restart_dev_box( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -3594,15 +2399,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.OperationDetails].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get_remote_connection( @@ -3620,16 +2423,6 @@ def get_remote_connection( :return: RemoteConnection. The RemoteConnection is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.RemoteConnection :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "rdpConnectionUrl": "str", # Optional. Link to open a Remote Desktop - session. - "webUrl": "str" # Optional. URL to open a browser based RDP session. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -3644,7 +2437,7 @@ def get_remote_connection( cls: ClsType[_models.RemoteConnection] = kwargs.pop("cls", None) - _request = build_dev_center_get_remote_connection_request( + _request = build_dev_boxes_get_remote_connection_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3666,7 +2459,10 @@ def get_remote_connection( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3696,23 +2492,6 @@ def list_dev_box_actions( :return: An iterator like instance of DevBoxAction :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.DevBoxAction] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "actionType": "str", # The action that will be taken. Required. "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this action. - Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -3730,7 +2509,7 @@ def list_dev_box_actions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_dev_box_actions_request( + _request = build_dev_boxes_list_dev_box_actions_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3784,8 +2563,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3811,23 +2588,6 @@ def get_dev_box_action( :return: DevBoxAction. The DevBoxAction is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.DevBoxAction :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "actionType": "str", # The action that will be taken. Required. "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this action. - Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -3842,7 +2602,7 @@ def get_dev_box_action( cls: ClsType[_models.DevBoxAction] = kwargs.pop("cls", None) - _request = build_dev_center_get_dev_box_action_request( + _request = build_dev_boxes_get_dev_box_action_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3865,7 +2625,10 @@ def get_dev_box_action( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3880,7 +2643,7 @@ def get_dev_box_action( return deserialized # type: ignore @distributed_trace - def skip_dev_box_action( # pylint: disable=inconsistent-return-statements + def skip_action( # pylint: disable=inconsistent-return-statements self, project_name: str, user_id: str, dev_box_name: str, action_name: str, **kwargs: Any ) -> None: """Skips an occurrence of an action. @@ -3911,7 +2674,7 @@ def skip_dev_box_action( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_dev_center_skip_dev_box_action_request( + _request = build_dev_boxes_skip_action_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3933,8 +2696,6 @@ def skip_dev_box_action( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3942,7 +2703,7 @@ def skip_dev_box_action( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def delay_dev_box_action( + def delay_action( self, project_name: str, user_id: str, @@ -3968,23 +2729,6 @@ def delay_dev_box_action( :return: DevBoxAction. The DevBoxAction is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.DevBoxAction :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "actionType": "str", # The action that will be taken. Required. "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this action. - Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -3999,7 +2743,7 @@ def delay_dev_box_action( cls: ClsType[_models.DevBoxAction] = kwargs.pop("cls", None) - _request = build_dev_center_delay_dev_box_action_request( + _request = build_dev_boxes_delay_action_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -4023,7 +2767,10 @@ def delay_dev_box_action( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4038,10 +2785,9 @@ def delay_dev_box_action( return deserialized # type: ignore @distributed_trace - def delay_all_dev_box_actions( + def delay_all_actions( self, project_name: str, user_id: str, dev_box_name: str, *, delay_until: datetime.datetime, **kwargs: Any ) -> Iterable["_models.DevBoxActionDelayResult"]: - # pylint: disable=line-too-long """Delays all actions. :param project_name: Name of the project. Required. @@ -4056,44 +2802,6 @@ def delay_all_dev_box_actions( :return: An iterator like instance of DevBoxActionDelayResult :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.DevBoxActionDelayResult] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # The name of the action. Required. - "result": "str", # The result of the delay operation on this action. - Required. Known values are: "Succeeded" and "Failed". - "action": { - "actionType": "str", # The action that will be taken. Required. - "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this - action. Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action - will be triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest - time that the action could occur (UTC). - }, - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -4111,7 +2819,7 @@ def delay_all_dev_box_actions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_delay_all_dev_box_actions_request( + _request = build_dev_boxes_delay_all_actions_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -4166,8 +2874,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4175,9 +2881,13 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + +class DeploymentEnvironmentsClientOperationsMixin( # pylint: disable=name-too-long + DeploymentEnvironmentsClientMixinABC +): + @distributed_trace def list_all_environments(self, project_name: str, **kwargs: Any) -> Iterable["_models.Environment"]: - # pylint: disable=line-too-long """Lists the environments for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4185,44 +2895,6 @@ def list_all_environments(self, project_name: str, **kwargs: Any) -> Iterable["_ :return: An iterator like instance of Environment :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.Environment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -4240,7 +2912,7 @@ def list_all_environments(self, project_name: str, **kwargs: Any) -> Iterable["_ def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_all_environments_request( + _request = build_deployment_environments_list_all_environments_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -4292,8 +2964,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4303,7 +2973,6 @@ def get_next(next_link=None): @distributed_trace def list_environments(self, project_name: str, user_id: str, **kwargs: Any) -> Iterable["_models.Environment"]: - # pylint: disable=line-too-long """Lists the environments for a project and user. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4314,44 +2983,6 @@ def list_environments(self, project_name: str, user_id: str, **kwargs: Any) -> I :return: An iterator like instance of Environment :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.Environment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -4369,7 +3000,7 @@ def list_environments(self, project_name: str, user_id: str, **kwargs: Any) -> I def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environments_request( + _request = build_deployment_environments_list_environments_request( project_name=project_name, user_id=user_id, api_version=self._config.api_version, @@ -4422,8 +3053,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4435,7 +3064,6 @@ def get_next(next_link=None): def get_environment( self, project_name: str, user_id: str, environment_name: str, **kwargs: Any ) -> _models.Environment: - # pylint: disable=line-too-long """Gets an environment. :param project_name: Name of the project. Required. @@ -4448,44 +3076,6 @@ def get_environment( :return: Environment. The Environment is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -4500,7 +3090,7 @@ def get_environment( cls: ClsType[_models.Environment] = kwargs.pop("cls", None) - _request = build_dev_center_get_environment_request( + _request = build_deployment_environments_get_environment_request( project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -4522,7 +3112,10 @@ def get_environment( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4543,7 +3136,7 @@ def _create_or_update_environment_initial( environment_name: str, body: Union[_models.Environment, JSON, IO[bytes]], **kwargs: Any - ) -> JSON: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4556,7 +3149,7 @@ def _create_or_update_environment_initial( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -4565,7 +3158,7 @@ def _create_or_update_environment_initial( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_dev_center_create_or_update_environment_request( + _request = build_deployment_environments_create_or_update_environment_request( project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -4580,7 +3173,7 @@ def _create_or_update_environment_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4588,15 +3181,17 @@ def _create_or_update_environment_initial( response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -4613,8 +3208,7 @@ def begin_create_or_update_environment( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4629,83 +3223,11 @@ def begin_create_or_update_environment( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns Environment. The Environment is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of LROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ @overload @@ -4718,8 +3240,7 @@ def begin_create_or_update_environment( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4734,48 +3255,11 @@ def begin_create_or_update_environment( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns Environment. The Environment is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of LROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ @overload @@ -4788,8 +3272,7 @@ def begin_create_or_update_environment( *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4804,48 +3287,11 @@ def begin_create_or_update_environment( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of LROPoller that returns Environment. The Environment is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of LROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ @distributed_trace @@ -4856,8 +3302,7 @@ def begin_create_or_update_environment( environment_name: str, body: Union[_models.Environment, JSON, IO[bytes]], **kwargs: Any - ) -> LROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> LROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4870,89 +3315,17 @@ def begin_create_or_update_environment( :param body: Represents an environment. Is one of the following types: Environment, JSON, IO[bytes] Required. :type body: ~azure.developer.devcenter.models.Environment or JSON or IO[bytes] - :return: An instance of LROPoller that returns Environment. The Environment is compatible with - MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of LROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Environment] = kwargs.pop("cls", None) + cls: ClsType[_models.ErrorResponseEnvironment] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -4968,6 +3341,7 @@ def begin_create_or_update_environment( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -4977,7 +3351,7 @@ def get_long_running_output(pipeline_response): "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(_models.Environment, response.json()) + deserialized = _deserialize(_models.ErrorResponseEnvironment, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -4995,19 +3369,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.Environment].from_continuation_token( + return LROPoller[_models.ErrorResponseEnvironment].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.Environment]( + return LROPoller[_models.ErrorResponseEnvironment]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) def _delete_environment_initial( self, project_name: str, user_id: str, environment_name: str, **kwargs: Any - ) -> Optional[JSON]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5019,9 +3393,9 @@ def _delete_environment_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_delete_environment_request( + _request = build_deployment_environments_delete_environment_request( project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -5034,7 +3408,7 @@ def _delete_environment_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -5042,12 +3416,13 @@ def _delete_environment_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: + try: response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -5055,7 +3430,7 @@ def _delete_environment_initial( "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -5065,8 +3440,7 @@ def _delete_environment_initial( @distributed_trace def begin_delete_environment( self, project_name: str, user_id: str, environment_name: str, **kwargs: Any - ) -> LROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> LROPoller[None]: """Deletes an environment and all its associated resources. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -5076,49 +3450,14 @@ def begin_delete_environment( :type user_id: str :param environment_name: The name of the environment. Required. :type environment_name: str - :return: An instance of LROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -5132,20 +3471,12 @@ def begin_delete_environment( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -5160,15 +3491,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[_models.OperationDetails].from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_catalogs(self, project_name: str, **kwargs: Any) -> Iterable["_models.Catalog"]: @@ -5179,14 +3508,6 @@ def list_catalogs(self, project_name: str, **kwargs: Any) -> Iterable["_models.C :return: An iterator like instance of Catalog :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.Catalog] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str" # Name of the catalog. Required. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -5204,7 +3525,7 @@ def list_catalogs(self, project_name: str, **kwargs: Any) -> Iterable["_models.C def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_catalogs_request( + _request = build_deployment_environments_list_catalogs_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -5256,8 +3577,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -5276,14 +3595,6 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> _m :return: Catalog. The Catalog is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Catalog :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str" # Name of the catalog. Required. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -5298,7 +3609,7 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> _m cls: ClsType[_models.Catalog] = kwargs.pop("cls", None) - _request = build_dev_center_get_catalog_request( + _request = build_deployment_environments_get_catalog_request( project_name=project_name, catalog_name=catalog_name, api_version=self._config.api_version, @@ -5319,7 +3630,10 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> _m if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -5337,7 +3651,6 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> _m def list_environment_definitions( self, project_name: str, **kwargs: Any ) -> Iterable["_models.EnvironmentDefinition"]: - # pylint: disable=line-too-long """Lists all environment definitions available for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -5345,42 +3658,6 @@ def list_environment_definitions( :return: An iterator like instance of EnvironmentDefinition :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.EnvironmentDefinition] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "id": "str", # The ID of the environment definition. Required. - "name": "str", # Name of the environment definition. Required. - "description": "str", # Optional. A short description of the environment - definition. - "parameters": [ - { - "id": "str", # Unique ID of the parameter. Required. - "required": bool, # Whether or not this parameter is - required. Required. - "type": "str", # A string of one of the basic JSON types - (number, integer, array, object, boolean, string). Required. Known values - are: "array", "boolean", "integer", "number", "object", and "string". - "allowed": [ - "str" # Optional. An array of allowed values. - ], - "default": "str", # Optional. Default value of the - parameter. - "description": "str", # Optional. Description of the - parameter. - "name": "str", # Optional. Display name of the parameter. - "readOnly": bool # Optional. Whether or not this parameter - is read-only. If true, default should have a value. - } - ], - "parametersSchema": "str", # Optional. JSON schema defining the parameters - object passed to an environment. - "templatePath": "str" # Optional. Path to the Environment Definition - entrypoint file. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -5398,7 +3675,7 @@ def list_environment_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environment_definitions_request( + _request = build_deployment_environments_list_environment_definitions_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -5450,8 +3727,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -5463,7 +3738,6 @@ def get_next(next_link=None): def list_environment_definitions_by_catalog( self, project_name: str, catalog_name: str, **kwargs: Any ) -> Iterable["_models.EnvironmentDefinition"]: - # pylint: disable=line-too-long """Lists all environment definitions available within a catalog. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -5473,42 +3747,6 @@ def list_environment_definitions_by_catalog( :return: An iterator like instance of EnvironmentDefinition :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.EnvironmentDefinition] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "id": "str", # The ID of the environment definition. Required. - "name": "str", # Name of the environment definition. Required. - "description": "str", # Optional. A short description of the environment - definition. - "parameters": [ - { - "id": "str", # Unique ID of the parameter. Required. - "required": bool, # Whether or not this parameter is - required. Required. - "type": "str", # A string of one of the basic JSON types - (number, integer, array, object, boolean, string). Required. Known values - are: "array", "boolean", "integer", "number", "object", and "string". - "allowed": [ - "str" # Optional. An array of allowed values. - ], - "default": "str", # Optional. Default value of the - parameter. - "description": "str", # Optional. Description of the - parameter. - "name": "str", # Optional. Display name of the parameter. - "readOnly": bool # Optional. Whether or not this parameter - is read-only. If true, default should have a value. - } - ], - "parametersSchema": "str", # Optional. JSON schema defining the parameters - object passed to an environment. - "templatePath": "str" # Optional. Path to the Environment Definition - entrypoint file. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -5526,7 +3764,7 @@ def list_environment_definitions_by_catalog( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environment_definitions_by_catalog_request( + _request = build_deployment_environments_list_environment_definitions_by_catalog_request( project_name=project_name, catalog_name=catalog_name, api_version=self._config.api_version, @@ -5579,8 +3817,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -5592,7 +3828,6 @@ def get_next(next_link=None): def get_environment_definition( self, project_name: str, catalog_name: str, definition_name: str, **kwargs: Any ) -> _models.EnvironmentDefinition: - # pylint: disable=line-too-long """Get an environment definition from a catalog. :param project_name: Name of the project. Required. @@ -5604,42 +3839,6 @@ def get_environment_definition( :return: EnvironmentDefinition. The EnvironmentDefinition is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.EnvironmentDefinition :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "id": "str", # The ID of the environment definition. Required. - "name": "str", # Name of the environment definition. Required. - "description": "str", # Optional. A short description of the environment - definition. - "parameters": [ - { - "id": "str", # Unique ID of the parameter. Required. - "required": bool, # Whether or not this parameter is - required. Required. - "type": "str", # A string of one of the basic JSON types - (number, integer, array, object, boolean, string). Required. Known values - are: "array", "boolean", "integer", "number", "object", and "string". - "allowed": [ - "str" # Optional. An array of allowed values. - ], - "default": "str", # Optional. Default value of the - parameter. - "description": "str", # Optional. Description of the - parameter. - "name": "str", # Optional. Display name of the parameter. - "readOnly": bool # Optional. Whether or not this parameter - is read-only. If true, default should have a value. - } - ], - "parametersSchema": "str", # Optional. JSON schema defining the parameters - object passed to an environment. - "templatePath": "str" # Optional. Path to the Environment Definition - entrypoint file. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -5654,7 +3853,7 @@ def get_environment_definition( cls: ClsType[_models.EnvironmentDefinition] = kwargs.pop("cls", None) - _request = build_dev_center_get_environment_definition_request( + _request = build_deployment_environments_get_environment_definition_request( project_name=project_name, catalog_name=catalog_name, definition_name=definition_name, @@ -5676,7 +3875,10 @@ def get_environment_definition( if response.status_code not in [200]: if _stream: - response.read() # Load the body in memory and close the socket + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -5692,27 +3894,13 @@ def get_environment_definition( @distributed_trace def list_environment_types(self, project_name: str, **kwargs: Any) -> Iterable["_models.EnvironmentType"]: - # pylint: disable=line-too-long """Lists all environment types configured for a project. - :param project_name: The DevCenter Project upon which to execute operations. Required. + :param project_name: Name of the project. Required. :type project_name: str :return: An iterator like instance of EnvironmentType :rtype: ~azure.core.paging.ItemPaged[~azure.developer.devcenter.models.EnvironmentType] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deploymentTargetId": "str", # Id of a subscription or management group that - the environment type will be mapped to. The environment's resources will be - deployed into this subscription or management group. Required. - "name": "str", # Name of the environment type. Required. - "status": "str" # Indicates whether this environment type is enabled for use - in this project. Required. Known values are: "Enabled" and "Disabled". - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -5730,7 +3918,7 @@ def list_environment_types(self, project_name: str, **kwargs: Any) -> Iterable[" def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environment_types_request( + _request = build_deployment_environments_list_environment_types_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -5782,8 +3970,6 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_serialization.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_serialization.py index 2f781d740827..8139854b97bb 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_serialization.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_serialization.py @@ -144,6 +144,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -1441,7 +1443,7 @@ def _deserialize(self, target_obj, data): elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_vendor.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_vendor.py index f8a0e715e8f5..209b046fd16a 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_vendor.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_vendor.py @@ -8,7 +8,11 @@ from abc import ABC from typing import TYPE_CHECKING -from ._configuration import DevCenterClientConfiguration +from ._configuration import ( + DeploymentEnvironmentsClientConfiguration, + DevBoxesClientConfiguration, + DevCenterClientConfiguration, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -24,3 +28,21 @@ class DevCenterClientMixinABC(ABC): _config: DevCenterClientConfiguration _serialize: "Serializer" _deserialize: "Deserializer" + + +class DevBoxesClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: DevBoxesClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" + + +class DeploymentEnvironmentsClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: DeploymentEnvironmentsClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_version.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_version.py index 83602e6274bc..0ec13ea52bbf 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_version.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.1" +VERSION = "1.0.0" diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/__init__.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/__init__.py index dc5f6ca493ef..d7bc6930c911 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/__init__.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/__init__.py @@ -7,6 +7,8 @@ # -------------------------------------------------------------------------- from ._client import DevCenterClient +from ._client import DevBoxesClient +from ._client import DeploymentEnvironmentsClient try: from ._patch import __all__ as _patch_all @@ -17,6 +19,8 @@ __all__ = [ "DevCenterClient", + "DevBoxesClient", + "DeploymentEnvironmentsClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_client.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_client.py index e94fae1092d9..0b70a1a6f1ea 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_client.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_client.py @@ -8,14 +8,23 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core import AsyncPipelineClient from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from .._serialization import Deserializer, Serializer -from ._configuration import DevCenterClientConfiguration -from ._operations import DevCenterClientOperationsMixin +from ._configuration import ( + DeploymentEnvironmentsClientConfiguration, + DevBoxesClientConfiguration, + DevCenterClientConfiguration, +) +from ._operations import ( + DeploymentEnvironmentsClientOperationsMixin, + DevBoxesClientOperationsMixin, + DevCenterClientOperationsMixin, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -25,6 +34,83 @@ class DevCenterClient(DevCenterClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """DevCenterClient. + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + _endpoint = "{endpoint}" + self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) + + +class DevBoxesClient(DevBoxesClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """DevBoxesClient. + :param endpoint: The DevCenter-specific URI to operate on. Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. @@ -38,7 +124,88 @@ class DevCenterClient(DevCenterClientOperationsMixin): # pylint: disable=client def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: _endpoint = "{endpoint}" - self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = DevBoxesClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) + + +class DeploymentEnvironmentsClient( + DeploymentEnvironmentsClientOperationsMixin +): # pylint: disable=client-accepts-api-version-keyword + """DeploymentEnvironmentsClient. + + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + _endpoint = "{endpoint}" + self._config = DeploymentEnvironmentsClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -93,7 +260,7 @@ def send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "DevCenterClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_configuration.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_configuration.py index 7f1449d13d56..af277ba06a4f 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_configuration.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_configuration.py @@ -62,3 +62,97 @@ def _configure(self, **kwargs: Any) -> None: self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( self.credential, *self.credential_scopes, **kwargs ) + + +class DevBoxesClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for DevBoxesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-04-01") + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.endpoint = endpoint + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) + + +class DeploymentEnvironmentsClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for DeploymentEnvironmentsClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The DevCenter-specific URI to operate on. Required. + :type endpoint: str + :param credential: Credential used to authenticate requests to the service. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: The API version to use for this operation. Default value is "2023-04-01". + Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2023-04-01") + + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.endpoint = endpoint + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/__init__.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/__init__.py index 32322330a2b5..34a148666638 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/__init__.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/__init__.py @@ -7,6 +7,8 @@ # -------------------------------------------------------------------------- from ._operations import DevCenterClientOperationsMixin +from ._operations import DevBoxesClientOperationsMixin +from ._operations import DeploymentEnvironmentsClientOperationsMixin from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -14,6 +16,8 @@ __all__ = [ "DevCenterClientOperationsMixin", + "DevBoxesClientOperationsMixin", + "DeploymentEnvironmentsClientOperationsMixin", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/_operations.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/_operations.py index d265d51dfc79..e2df9bf9be85 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/_operations.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_operations/_operations.py @@ -10,7 +10,21 @@ from io import IOBase import json import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, Type, TypeVar, Union, cast, overload +from typing import ( + Any, + AsyncIterable, + AsyncIterator, + Callable, + Dict, + IO, + List, + Optional, + Type, + TypeVar, + Union, + cast, + overload, +) import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -20,6 +34,8 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse @@ -33,71 +49,59 @@ from ... import models as _models from ..._model_base import SdkJSONEncoder, _deserialize from ..._operations._operations import ( - build_dev_center_create_dev_box_request, - build_dev_center_create_or_update_environment_request, - build_dev_center_delay_all_dev_box_actions_request, - build_dev_center_delay_dev_box_action_request, - build_dev_center_delete_dev_box_request, - build_dev_center_delete_environment_request, - build_dev_center_get_catalog_request, - build_dev_center_get_dev_box_action_request, - build_dev_center_get_dev_box_request, - build_dev_center_get_environment_definition_request, - build_dev_center_get_environment_request, - build_dev_center_get_pool_request, + build_deployment_environments_create_or_update_environment_request, + build_deployment_environments_delete_environment_request, + build_deployment_environments_get_catalog_request, + build_deployment_environments_get_environment_definition_request, + build_deployment_environments_get_environment_request, + build_deployment_environments_list_all_environments_request, + build_deployment_environments_list_catalogs_request, + build_deployment_environments_list_environment_definitions_by_catalog_request, + build_deployment_environments_list_environment_definitions_request, + build_deployment_environments_list_environment_types_request, + build_deployment_environments_list_environments_request, + build_dev_boxes_create_dev_box_request, + build_dev_boxes_delay_action_request, + build_dev_boxes_delay_all_actions_request, + build_dev_boxes_delete_dev_box_request, + build_dev_boxes_get_dev_box_action_request, + build_dev_boxes_get_dev_box_request, + build_dev_boxes_get_pool_request, + build_dev_boxes_get_remote_connection_request, + build_dev_boxes_get_schedule_request, + build_dev_boxes_list_all_dev_boxes_by_user_request, + build_dev_boxes_list_all_dev_boxes_request, + build_dev_boxes_list_dev_box_actions_request, + build_dev_boxes_list_dev_boxes_request, + build_dev_boxes_list_pools_request, + build_dev_boxes_list_schedules_request, + build_dev_boxes_restart_dev_box_request, + build_dev_boxes_skip_action_request, + build_dev_boxes_start_dev_box_request, + build_dev_boxes_stop_dev_box_request, build_dev_center_get_project_request, - build_dev_center_get_remote_connection_request, - build_dev_center_get_schedule_request, - build_dev_center_list_all_dev_boxes_by_user_request, - build_dev_center_list_all_dev_boxes_request, - build_dev_center_list_all_environments_request, - build_dev_center_list_catalogs_request, - build_dev_center_list_dev_box_actions_request, - build_dev_center_list_dev_boxes_request, - build_dev_center_list_environment_definitions_by_catalog_request, - build_dev_center_list_environment_definitions_request, - build_dev_center_list_environment_types_request, - build_dev_center_list_environments_request, - build_dev_center_list_pools_request, build_dev_center_list_projects_request, - build_dev_center_list_schedules_request, - build_dev_center_restart_dev_box_request, - build_dev_center_skip_dev_box_action_request, - build_dev_center_start_dev_box_request, - build_dev_center_stop_dev_box_request, ) -from .._vendor import DevCenterClientMixinABC +from .._vendor import DeploymentEnvironmentsClientMixinABC, DevBoxesClientMixinABC, DevCenterClientMixinABC if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class DevCenterClientOperationsMixin(DevCenterClientMixinABC): # pylint: disable=too-many-public-methods +class DevCenterClientOperationsMixin(DevCenterClientMixinABC): @distributed_trace def list_projects(self, **kwargs: Any) -> AsyncIterable["_models.Project"]: - # pylint: disable=line-too-long """Lists all projects. :return: An iterator like instance of Project :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.Project] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Name of the project. Required. - "description": "str", # Optional. Description of the project. - "maxDevBoxesPerUser": 0 # Optional. When specified, indicates the maximum - number of Dev Boxes a single user can create across all pools in the project. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -166,8 +170,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -177,7 +179,6 @@ async def get_next(next_link=None): @distributed_trace_async async def get_project(self, project_name: str, **kwargs: Any) -> _models.Project: - # pylint: disable=line-too-long """Gets a project. :param project_name: Name of the project. Required. @@ -185,17 +186,6 @@ async def get_project(self, project_name: str, **kwargs: Any) -> _models.Project :return: Project. The Project is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Project :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Name of the project. Required. - "description": "str", # Optional. Description of the project. - "maxDevBoxesPerUser": 0 # Optional. When specified, indicates the maximum - number of Dev Boxes a single user can create across all pools in the project. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -230,7 +220,10 @@ async def get_project(self, project_name: str, **kwargs: Any) -> _models.Project if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -244,9 +237,11 @@ async def get_project(self, project_name: str, **kwargs: Any) -> _models.Project return deserialized # type: ignore + +class DevBoxesClientOperationsMixin(DevBoxesClientMixinABC): # pylint: disable=too-many-public-methods + @distributed_trace def list_pools(self, project_name: str, **kwargs: Any) -> AsyncIterable["_models.Pool"]: - # pylint: disable=line-too-long """Lists available pools. :param project_name: Name of the project. Required. @@ -254,68 +249,6 @@ def list_pools(self, project_name: str, **kwargs: Any) -> AsyncIterable["_models :return: An iterator like instance of Pool :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.Pool] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "healthStatus": "str", # Overall health status of the Pool. Indicates - whether or not the Pool is available to create Dev Boxes. Required. Known values - are: "Unknown", "Pending", "Healthy", "Warning", and "Unhealthy". - "location": "str", # Azure region where Dev Boxes in the pool are located. - Required. - "name": "str", # Pool name. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether owners of Dev - Boxes in this pool are local administrators on the Dev Boxes. Known values are: - "Enabled" and "Disabled". - "osType": "str", # Optional. The operating system type of Dev Boxes in this - pool. "Windows" - "stopOnDisconnect": { - "status": "str", # Indicates whether the feature to stop the devbox - on disconnect once the grace period has lapsed is enabled. Required. Known - values are: "Enabled" and "Disabled". - "gracePeriodMinutes": 0 # Optional. The specified time in minutes to - wait before stopping a Dev Box once disconnect is detected. - }, - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -333,7 +266,7 @@ def list_pools(self, project_name: str, **kwargs: Any) -> AsyncIterable["_models def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_pools_request( + _request = build_dev_boxes_list_pools_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -385,8 +318,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -396,7 +327,6 @@ async def get_next(next_link=None): @distributed_trace_async async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _models.Pool: - # pylint: disable=line-too-long """Gets a pool. :param project_name: Name of the project. Required. @@ -406,68 +336,6 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _m :return: Pool. The Pool is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Pool :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "healthStatus": "str", # Overall health status of the Pool. Indicates - whether or not the Pool is available to create Dev Boxes. Required. Known values - are: "Unknown", "Pending", "Healthy", "Warning", and "Unhealthy". - "location": "str", # Azure region where Dev Boxes in the pool are located. - Required. - "name": "str", # Pool name. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether owners of Dev - Boxes in this pool are local administrators on the Dev Boxes. Known values are: - "Enabled" and "Disabled". - "osType": "str", # Optional. The operating system type of Dev Boxes in this - pool. "Windows" - "stopOnDisconnect": { - "status": "str", # Indicates whether the feature to stop the devbox - on disconnect once the grace period has lapsed is enabled. Required. Known - values are: "Enabled" and "Disabled". - "gracePeriodMinutes": 0 # Optional. The specified time in minutes to - wait before stopping a Dev Box once disconnect is detected. - }, - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - } - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -482,7 +350,7 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _m cls: ClsType[_models.Pool] = kwargs.pop("cls", None) - _request = build_dev_center_get_pool_request( + _request = build_dev_boxes_get_pool_request( project_name=project_name, pool_name=pool_name, api_version=self._config.api_version, @@ -503,7 +371,10 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> _m if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -528,22 +399,6 @@ def list_schedules(self, project_name: str, pool_name: str, **kwargs: Any) -> As :return: An iterator like instance of Schedule :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "frequency": "str", # The frequency of this scheduled task. Required. - "Daily" - "name": "str", # Display name for the Schedule. Required. - "time": "str", # The target time to trigger the action. The format is HH:MM. - Required. - "timeZone": "str", # The IANA timezone id at which the schedule should - execute. Required. - "type": "str" # Supported type this scheduled task represents. Required. - "StopDevBox" - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -561,7 +416,7 @@ def list_schedules(self, project_name: str, pool_name: str, **kwargs: Any) -> As def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_schedules_request( + _request = build_dev_boxes_list_schedules_request( project_name=project_name, pool_name=pool_name, api_version=self._config.api_version, @@ -614,8 +469,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -638,22 +491,6 @@ async def get_schedule( :return: Schedule. The Schedule is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "frequency": "str", # The frequency of this scheduled task. Required. - "Daily" - "name": "str", # Display name for the Schedule. Required. - "time": "str", # The target time to trigger the action. The format is HH:MM. - Required. - "timeZone": "str", # The IANA timezone id at which the schedule should - execute. Required. - "type": "str" # Supported type this scheduled task represents. Required. - "StopDevBox" - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -668,7 +505,7 @@ async def get_schedule( cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) - _request = build_dev_center_get_schedule_request( + _request = build_dev_boxes_get_schedule_request( project_name=project_name, pool_name=pool_name, schedule_name=schedule_name, @@ -690,7 +527,10 @@ async def get_schedule( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -706,97 +546,11 @@ async def get_schedule( @distributed_trace def list_all_dev_boxes(self, **kwargs: Any) -> AsyncIterable["_models.DevBox"]: - # pylint: disable=line-too-long """Lists Dev Boxes that the caller has access to in the DevCenter. :return: An iterator like instance of DevBox :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.DevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -814,7 +568,7 @@ def list_all_dev_boxes(self, **kwargs: Any) -> AsyncIterable["_models.DevBox"]: def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_all_dev_boxes_request( + _request = build_dev_boxes_list_all_dev_boxes_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -865,8 +619,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -876,7 +628,6 @@ async def get_next(next_link=None): @distributed_trace def list_all_dev_boxes_by_user(self, user_id: str, **kwargs: Any) -> AsyncIterable["_models.DevBox"]: - # pylint: disable=line-too-long """Lists Dev Boxes in the Dev Center for a particular user. :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the @@ -885,91 +636,6 @@ def list_all_dev_boxes_by_user(self, user_id: str, **kwargs: Any) -> AsyncIterab :return: An iterator like instance of DevBox :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.DevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -987,7 +653,7 @@ def list_all_dev_boxes_by_user(self, user_id: str, **kwargs: Any) -> AsyncIterab def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_all_dev_boxes_by_user_request( + _request = build_dev_boxes_list_all_dev_boxes_by_user_request( user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -1039,8 +705,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1050,7 +714,6 @@ async def get_next(next_link=None): @distributed_trace def list_dev_boxes(self, project_name: str, user_id: str, **kwargs: Any) -> AsyncIterable["_models.DevBox"]: - # pylint: disable=line-too-long """Lists Dev Boxes in the project for a particular user. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -1061,91 +724,6 @@ def list_dev_boxes(self, project_name: str, user_id: str, **kwargs: Any) -> Asyn :return: An iterator like instance of DevBox :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.DevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -1163,7 +741,7 @@ def list_dev_boxes(self, project_name: str, user_id: str, **kwargs: Any) -> Asyn def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_dev_boxes_request( + _request = build_dev_boxes_list_dev_boxes_request( project_name=project_name, user_id=user_id, api_version=self._config.api_version, @@ -1216,8 +794,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1227,7 +803,6 @@ async def get_next(next_link=None): @distributed_trace_async async def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any) -> _models.DevBox: - # pylint: disable=line-too-long """Gets a Dev Box. :param project_name: Name of the project. Required. @@ -1240,91 +815,6 @@ async def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, :return: DevBox. The DevBox is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.DevBox :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -1339,7 +829,7 @@ async def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, cls: ClsType[_models.DevBox] = kwargs.pop("cls", None) - _request = build_dev_center_get_dev_box_request( + _request = build_dev_boxes_get_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -1361,7 +851,10 @@ async def get_dev_box(self, project_name: str, user_id: str, dev_box_name: str, if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -1382,7 +875,7 @@ async def _create_dev_box_initial( dev_box_name: str, body: Union[_models.DevBox, JSON, IO[bytes]], **kwargs: Any - ) -> JSON: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1395,7 +888,7 @@ async def _create_dev_box_initial( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -1404,7 +897,7 @@ async def _create_dev_box_initial( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_dev_center_create_dev_box_request( + _request = build_dev_boxes_create_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -1419,7 +912,7 @@ async def _create_dev_box_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1427,22 +920,21 @@ async def _create_dev_box_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: - if _stream: + try: await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} - if response.status_code == 200: - deserialized = _deserialize(JSON, response.json()) - if response.status_code == 201: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Operation-Location"] = self._deserialize( "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1459,8 +951,7 @@ async def begin_create_dev_box( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -1476,177 +967,11 @@ async def begin_create_dev_box( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of AsyncLROPoller that returns ErrorResponseDevBox. The + ErrorResponseDevBox is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ @overload @@ -1659,8 +984,7 @@ async def begin_create_dev_box( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -1676,95 +1000,11 @@ async def begin_create_dev_box( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of AsyncLROPoller that returns ErrorResponseDevBox. The + ErrorResponseDevBox is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ @overload @@ -1777,8 +1017,7 @@ async def begin_create_dev_box( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -1794,95 +1033,11 @@ async def begin_create_dev_box( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of AsyncLROPoller that returns ErrorResponseDevBox. The + ErrorResponseDevBox is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ @distributed_trace_async @@ -1893,8 +1048,7 @@ async def begin_create_dev_box( dev_box_name: str, body: Union[_models.DevBox, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.DevBox]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseDevBox]: """Creates or replaces a Dev Box. :param project_name: The DevCenter Project upon which to execute the operation. Required. @@ -1908,183 +1062,17 @@ async def begin_create_dev_box( Optionally set the owner of the Dev Box as local administrator. Is one of the following types: DevBox, JSON, IO[bytes] Required. :type body: ~azure.developer.devcenter.models.DevBox or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns DevBox. The DevBox is compatible with - MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.DevBox] + :return: An instance of AsyncLROPoller that returns ErrorResponseDevBox. The + ErrorResponseDevBox is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseDevBox] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } - - # response body for status code(s): 200, 201 - response == { - "name": "str", # Display name for the Dev Box. Required. - "poolName": "str", # The name of the Dev Box pool this machine belongs to. - Required. - "actionState": "str", # Optional. The current action state of the Dev Box. - This is state is based on previous action performed by user. - "createdTime": "2020-02-20 00:00:00", # Optional. Creation time of this Dev - Box. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. Known values are: - "general_i_8c32gb256ssd_v2", "general_i_8c32gb512ssd_v2", - "general_i_8c32gb1024ssd_v2", "general_i_8c32gb2048ssd_v2", - "general_i_16c64gb256ssd_v2", "general_i_16c64gb512ssd_v2", - "general_i_16c64gb1024ssd_v2", "general_i_16c64gb2048ssd_v2", - "general_i_32c128gb512ssd_v2", "general_i_32c128gb1024ssd_v2", - "general_i_32c128gb2048ssd_v2", "general_a_8c32gb256ssd_v2", - "general_a_8c32gb512ssd_v2", "general_a_8c32gb1024ssd_v2", - "general_a_8c32gb2048ssd_v2", "general_a_16c64gb256ssd_v2", - "general_a_16c64gb512ssd_v2", "general_a_16c64gb1024ssd_v2", - "general_a_16c64gb2048ssd_v2", "general_a_32c128gb512ssd_v2", - "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. - }, - "hibernateSupport": "str", # Optional. Indicates whether hibernate is - enabled/disabled or unknown. Known values are: "Enabled", "Disabled", and - "OsUnsupported". - "imageReference": { - "name": "str", # Optional. The name of the image used. - "operatingSystem": "str", # Optional. The operating system of the - image. - "osBuildNumber": "str", # Optional. The operating system build - number of the image. - "publishedDate": "2020-02-20 00:00:00", # Optional. The datetime - that the backing image version was published. - "version": "str" # Optional. The version of the image. - }, - "localAdministrator": "str", # Optional. Indicates whether the owner of the - Dev Box is a local administrator. Known values are: "Enabled" and "Disabled". - "location": "str", # Optional. Azure region where this Dev Box is located. - This will be the same region as the Virtual Network it is attached to. - "osType": "str", # Optional. The operating system type of this Dev Box. - "Windows" - "powerState": "str", # Optional. The current power state of the Dev Box. - Known values are: "Unknown", "Running", "Deallocated", "PoweredOff", and - "Hibernated". - "projectName": "str", # Optional. Name of the project this Dev Box belongs - to. - "provisioningState": "str", # Optional. The current provisioning state of - the Dev Box. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Deleting", "Updating", "Starting", "Stopping", "Provisioning", - "ProvisionedWithWarning", "InGracePeriod", and "NotProvisioned". - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. - } """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DevBox] = kwargs.pop("cls", None) + cls: ClsType[_models.ErrorResponseDevBox] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -2100,11 +1088,12 @@ async def begin_create_dev_box( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response = pipeline_response.http_response - deserialized = _deserialize(_models.DevBox, response.json()) + deserialized = _deserialize(_models.ErrorResponseDevBox, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -2123,19 +1112,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.DevBox].from_continuation_token( + return AsyncLROPoller[_models.ErrorResponseDevBox].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.DevBox]( + return AsyncLROPoller[_models.ErrorResponseDevBox]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _delete_dev_box_initial( self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> Optional[JSON]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2147,9 +1136,9 @@ async def _delete_dev_box_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_delete_dev_box_request( + _request = build_dev_boxes_delete_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2162,7 +1151,7 @@ async def _delete_dev_box_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2170,12 +1159,13 @@ async def _delete_dev_box_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: + try: await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -2183,7 +1173,7 @@ async def _delete_dev_box_initial( "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2193,8 +1183,7 @@ async def _delete_dev_box_initial( @distributed_trace_async async def begin_delete_dev_box( self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[None]: """Deletes a Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -2204,49 +1193,14 @@ async def begin_delete_dev_box( :type user_id: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :return: An instance of AsyncLROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -2260,20 +1214,12 @@ async def begin_delete_dev_box( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -2289,17 +1235,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.OperationDetails].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any) -> JSON: + async def _start_dev_box_initial( + self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2311,9 +1257,9 @@ async def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_start_dev_box_request( + _request = build_dev_boxes_start_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2326,7 +1272,7 @@ async def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_ } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2334,15 +1280,17 @@ async def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_ response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: + try: await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2352,8 +1300,7 @@ async def _start_dev_box_initial(self, project_name: str, user_id: str, dev_box_ @distributed_trace_async async def begin_start_dev_box( self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[None]: """Starts a Dev Box. :param project_name: Name of the project. Required. @@ -2363,49 +1310,14 @@ async def begin_start_dev_box( :type user_id: str :param dev_box_name: Display name for the Dev Box. Required. :type dev_box_name: str - :return: An instance of AsyncLROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -2419,19 +1331,12 @@ async def begin_start_dev_box( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -2447,19 +1352,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.OperationDetails].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _stop_dev_box_initial( self, project_name: str, user_id: str, dev_box_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any - ) -> JSON: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2471,9 +1374,9 @@ async def _stop_dev_box_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_stop_dev_box_request( + _request = build_dev_boxes_stop_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2487,7 +1390,7 @@ async def _stop_dev_box_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2495,15 +1398,17 @@ async def _stop_dev_box_initial( response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: + try: await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2513,8 +1418,7 @@ async def _stop_dev_box_initial( @distributed_trace_async async def begin_stop_dev_box( self, project_name: str, user_id: str, dev_box_name: str, *, hibernate: Optional[bool] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[None]: """Stops a Dev Box. :param project_name: Name of the project. Required. @@ -2526,49 +1430,14 @@ async def begin_stop_dev_box( :type dev_box_name: str :keyword hibernate: Optional parameter to hibernate the dev box. Default value is None. :paramtype hibernate: bool - :return: An instance of AsyncLROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -2583,19 +1452,12 @@ async def begin_stop_dev_box( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -2611,17 +1473,17 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.OperationDetails].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any) -> JSON: + async def _restart_dev_box_initial( + self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2633,9 +1495,9 @@ async def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_bo _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_restart_dev_box_request( + _request = build_dev_boxes_restart_dev_box_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2648,7 +1510,7 @@ async def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_bo } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -2656,15 +1518,17 @@ async def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_bo response = pipeline_response.http_response if response.status_code not in [202]: - if _stream: + try: await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -2674,8 +1538,7 @@ async def _restart_dev_box_initial(self, project_name: str, user_id: str, dev_bo @distributed_trace_async async def begin_restart_dev_box( self, project_name: str, user_id: str, dev_box_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[None]: """Restarts a Dev Box. :param project_name: Name of the project. Required. @@ -2685,49 +1548,14 @@ async def begin_restart_dev_box( :type user_id: str :param dev_box_name: Display name for the Dev Box. Required. :type dev_box_name: str - :return: An instance of AsyncLROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -2741,19 +1569,12 @@ async def begin_restart_dev_box( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -2769,15 +1590,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.OperationDetails].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get_remote_connection( @@ -2795,16 +1614,6 @@ async def get_remote_connection( :return: RemoteConnection. The RemoteConnection is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.RemoteConnection :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "rdpConnectionUrl": "str", # Optional. Link to open a Remote Desktop - session. - "webUrl": "str" # Optional. URL to open a browser based RDP session. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -2819,7 +1628,7 @@ async def get_remote_connection( cls: ClsType[_models.RemoteConnection] = kwargs.pop("cls", None) - _request = build_dev_center_get_remote_connection_request( + _request = build_dev_boxes_get_remote_connection_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2841,7 +1650,10 @@ async def get_remote_connection( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2871,23 +1683,6 @@ def list_dev_box_actions( :return: An iterator like instance of DevBoxAction :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.DevBoxAction] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "actionType": "str", # The action that will be taken. Required. "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this action. - Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -2905,7 +1700,7 @@ def list_dev_box_actions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_dev_box_actions_request( + _request = build_dev_boxes_list_dev_box_actions_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -2959,8 +1754,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -2986,23 +1779,6 @@ async def get_dev_box_action( :return: DevBoxAction. The DevBoxAction is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.DevBoxAction :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "actionType": "str", # The action that will be taken. Required. "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this action. - Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -3017,7 +1793,7 @@ async def get_dev_box_action( cls: ClsType[_models.DevBoxAction] = kwargs.pop("cls", None) - _request = build_dev_center_get_dev_box_action_request( + _request = build_dev_boxes_get_dev_box_action_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3040,7 +1816,10 @@ async def get_dev_box_action( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3055,7 +1834,7 @@ async def get_dev_box_action( return deserialized # type: ignore @distributed_trace_async - async def skip_dev_box_action( # pylint: disable=inconsistent-return-statements + async def skip_action( # pylint: disable=inconsistent-return-statements self, project_name: str, user_id: str, dev_box_name: str, action_name: str, **kwargs: Any ) -> None: """Skips an occurrence of an action. @@ -3086,7 +1865,7 @@ async def skip_dev_box_action( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_dev_center_skip_dev_box_action_request( + _request = build_dev_boxes_skip_action_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3108,8 +1887,6 @@ async def skip_dev_box_action( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [204]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3117,7 +1894,7 @@ async def skip_dev_box_action( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def delay_dev_box_action( + async def delay_action( self, project_name: str, user_id: str, @@ -3143,23 +1920,6 @@ async def delay_dev_box_action( :return: DevBoxAction. The DevBoxAction is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.DevBoxAction :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "actionType": "str", # The action that will be taken. Required. "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this action. - Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -3174,7 +1934,7 @@ async def delay_dev_box_action( cls: ClsType[_models.DevBoxAction] = kwargs.pop("cls", None) - _request = build_dev_center_delay_dev_box_action_request( + _request = build_dev_boxes_delay_action_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3198,7 +1958,10 @@ async def delay_dev_box_action( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3213,10 +1976,9 @@ async def delay_dev_box_action( return deserialized # type: ignore @distributed_trace - def delay_all_dev_box_actions( + def delay_all_actions( self, project_name: str, user_id: str, dev_box_name: str, *, delay_until: datetime.datetime, **kwargs: Any ) -> AsyncIterable["_models.DevBoxActionDelayResult"]: - # pylint: disable=line-too-long """Delays all actions. :param project_name: Name of the project. Required. @@ -3232,44 +1994,6 @@ def delay_all_dev_box_actions( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.DevBoxActionDelayResult] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str", # The name of the action. Required. - "result": "str", # The result of the delay operation on this action. - Required. Known values are: "Succeeded" and "Failed". - "action": { - "actionType": "str", # The action that will be taken. Required. - "Stop" - "name": "str", # The name of the action. Required. - "sourceId": "str", # The id of the resource which triggered this - action. Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action - will be triggered (UTC). Required. - }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest - time that the action could occur (UTC). - }, - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - } - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -3287,7 +2011,7 @@ def delay_all_dev_box_actions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_delay_all_dev_box_actions_request( + _request = build_dev_boxes_delay_all_actions_request( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -3342,8 +2066,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3351,9 +2073,13 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + +class DeploymentEnvironmentsClientOperationsMixin( # pylint: disable=name-too-long + DeploymentEnvironmentsClientMixinABC +): + @distributed_trace def list_all_environments(self, project_name: str, **kwargs: Any) -> AsyncIterable["_models.Environment"]: - # pylint: disable=line-too-long """Lists the environments for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -3361,44 +2087,6 @@ def list_all_environments(self, project_name: str, **kwargs: Any) -> AsyncIterab :return: An iterator like instance of Environment :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.Environment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -3416,7 +2104,7 @@ def list_all_environments(self, project_name: str, **kwargs: Any) -> AsyncIterab def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_all_environments_request( + _request = build_deployment_environments_list_all_environments_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -3468,8 +2156,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3479,7 +2165,6 @@ async def get_next(next_link=None): @distributed_trace def list_environments(self, project_name: str, user_id: str, **kwargs: Any) -> AsyncIterable["_models.Environment"]: - # pylint: disable=line-too-long """Lists the environments for a project and user. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -3490,44 +2175,6 @@ def list_environments(self, project_name: str, user_id: str, **kwargs: Any) -> A :return: An iterator like instance of Environment :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.Environment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -3545,7 +2192,7 @@ def list_environments(self, project_name: str, user_id: str, **kwargs: Any) -> A def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environments_request( + _request = build_deployment_environments_list_environments_request( project_name=project_name, user_id=user_id, api_version=self._config.api_version, @@ -3598,8 +2245,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3611,7 +2256,6 @@ async def get_next(next_link=None): async def get_environment( self, project_name: str, user_id: str, environment_name: str, **kwargs: Any ) -> _models.Environment: - # pylint: disable=line-too-long """Gets an environment. :param project_name: Name of the project. Required. @@ -3624,44 +2268,6 @@ async def get_environment( :return: Environment. The Environment is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Environment :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -3676,7 +2282,7 @@ async def get_environment( cls: ClsType[_models.Environment] = kwargs.pop("cls", None) - _request = build_dev_center_get_environment_request( + _request = build_deployment_environments_get_environment_request( project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -3698,7 +2304,10 @@ async def get_environment( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -3719,7 +2328,7 @@ async def _create_or_update_environment_initial( environment_name: str, body: Union[_models.Environment, JSON, IO[bytes]], **kwargs: Any - ) -> JSON: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3732,7 +2341,7 @@ async def _create_or_update_environment_initial( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None @@ -3741,7 +2350,7 @@ async def _create_or_update_environment_initial( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_dev_center_create_or_update_environment_request( + _request = build_deployment_environments_create_or_update_environment_request( project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -3756,7 +2365,7 @@ async def _create_or_update_environment_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3764,15 +2373,17 @@ async def _create_or_update_environment_initial( response = pipeline_response.http_response if response.status_code not in [201]: - if _stream: + try: await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) response_headers = {} response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3789,8 +2400,7 @@ async def begin_create_or_update_environment( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -3805,83 +2415,11 @@ async def begin_create_or_update_environment( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns Environment. The Environment is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of AsyncLROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ @overload @@ -3894,8 +2432,7 @@ async def begin_create_or_update_environment( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -3910,48 +2447,11 @@ async def begin_create_or_update_environment( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns Environment. The Environment is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of AsyncLROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ @overload @@ -3964,8 +2464,7 @@ async def begin_create_or_update_environment( *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -3980,48 +2479,11 @@ async def begin_create_or_update_environment( :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns Environment. The Environment is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of AsyncLROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ @distributed_trace_async @@ -4032,8 +2494,7 @@ async def begin_create_or_update_environment( environment_name: str, body: Union[_models.Environment, JSON, IO[bytes]], **kwargs: Any - ) -> AsyncLROPoller[_models.Environment]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[_models.ErrorResponseEnvironment]: """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4046,89 +2507,17 @@ async def begin_create_or_update_environment( :param body: Represents an environment. Is one of the following types: Environment, JSON, IO[bytes] Required. :type body: ~azure.developer.devcenter.models.Environment or JSON or IO[bytes] - :return: An instance of AsyncLROPoller that returns Environment. The Environment is compatible - with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.Environment] + :return: An instance of AsyncLROPoller that returns ErrorResponseEnvironment. The + ErrorResponseEnvironment is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.ErrorResponseEnvironment] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # JSON input template you can fill out and use as your body input. - body = { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } - - # response body for status code(s): 201 - response == { - "catalogName": "str", # Name of the catalog. Required. - "environmentDefinitionName": "str", # Name of the environment definition. - Required. - "environmentType": "str", # Environment type. Required. - "name": "str", # Environment name. Required. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "parameters": { - "str": {} # Optional. Parameters object for the environment. - }, - "provisioningState": "str", # Optional. The provisioning state of the - environment. Known values are: "Succeeded", "Failed", "Canceled", "Creating", - "Accepted", "Deleting", "Updating", "Preparing", "Running", "Syncing", - "MovingResources", "TransientFailure", and "StorageProvisioningFailed". - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Environment] = kwargs.pop("cls", None) + cls: ClsType[_models.ErrorResponseEnvironment] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -4144,6 +2533,7 @@ async def begin_create_or_update_environment( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): @@ -4153,7 +2543,7 @@ def get_long_running_output(pipeline_response): "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(_models.Environment, response.json()) + deserialized = _deserialize(_models.ErrorResponseEnvironment, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized @@ -4172,19 +2562,19 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.Environment].from_continuation_token( + return AsyncLROPoller[_models.ErrorResponseEnvironment].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.Environment]( + return AsyncLROPoller[_models.ErrorResponseEnvironment]( self._client, raw_result, get_long_running_output, polling_method # type: ignore ) async def _delete_environment_initial( self, project_name: str, user_id: str, environment_name: str, **kwargs: Any - ) -> Optional[JSON]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4196,9 +2586,9 @@ async def _delete_environment_initial( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_center_delete_environment_request( + _request = build_deployment_environments_delete_environment_request( project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -4211,7 +2601,7 @@ async def _delete_environment_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -4219,12 +2609,13 @@ async def _delete_environment_initial( response = pipeline_response.http_response if response.status_code not in [202, 204]: - if _stream: + try: await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = None response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) @@ -4232,7 +2623,7 @@ async def _delete_environment_initial( "str", response.headers.get("Operation-Location") ) - deserialized = _deserialize(JSON, response.json()) + deserialized = response.iter_bytes() if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -4242,8 +2633,7 @@ async def _delete_environment_initial( @distributed_trace_async async def begin_delete_environment( self, project_name: str, user_id: str, environment_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.OperationDetails]: - # pylint: disable=line-too-long + ) -> AsyncLROPoller[None]: """Deletes an environment and all its associated resources. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4253,49 +2643,14 @@ async def begin_delete_environment( :type user_id: str :param environment_name: The name of the environment. Required. :type environment_name: str - :return: An instance of AsyncLROPoller that returns OperationDetails. The OperationDetails is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.developer.devcenter.models.OperationDetails] + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "id": "str", # Fully qualified ID for the operation status. Required. - "name": "str", # The operation id name. Required. - "status": "str", # Provisioning state of the resource. Required. Known - values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # One of a server-defined set of error codes. - Required. - "message": "str", # A human-readable representation of the error. - Required. - "details": [ - ... - ], - "innererror": { - "code": "str", # Optional. One of a server-defined set of - error codes. - "innererror": ... - }, - "target": "str" # Optional. The target of the error. - }, - "percentComplete": 0.0, # Optional. Percent of the operation that is - complete. - "properties": {}, # Optional. Custom operation properties, populated only - for a successful operation. - "resourceId": "str", # Optional. The id of the resource. - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.OperationDetails] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) @@ -4309,20 +2664,12 @@ async def begin_delete_environment( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - deserialized = _deserialize(_models.OperationDetails, response.json()) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), @@ -4338,15 +2685,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[_models.OperationDetails].from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[_models.OperationDetails]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_catalogs(self, project_name: str, **kwargs: Any) -> AsyncIterable["_models.Catalog"]: @@ -4357,14 +2702,6 @@ def list_catalogs(self, project_name: str, **kwargs: Any) -> AsyncIterable["_mod :return: An iterator like instance of Catalog :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.Catalog] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str" # Name of the catalog. Required. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -4382,7 +2719,7 @@ def list_catalogs(self, project_name: str, **kwargs: Any) -> AsyncIterable["_mod def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_catalogs_request( + _request = build_deployment_environments_list_catalogs_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -4434,8 +2771,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4454,14 +2789,6 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) :return: Catalog. The Catalog is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.Catalog :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "name": "str" # Name of the catalog. Required. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -4476,7 +2803,7 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) cls: ClsType[_models.Catalog] = kwargs.pop("cls", None) - _request = build_dev_center_get_catalog_request( + _request = build_deployment_environments_get_catalog_request( project_name=project_name, catalog_name=catalog_name, api_version=self._config.api_version, @@ -4497,7 +2824,10 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4515,7 +2845,6 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) def list_environment_definitions( self, project_name: str, **kwargs: Any ) -> AsyncIterable["_models.EnvironmentDefinition"]: - # pylint: disable=line-too-long """Lists all environment definitions available for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4524,42 +2853,6 @@ def list_environment_definitions( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.EnvironmentDefinition] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "id": "str", # The ID of the environment definition. Required. - "name": "str", # Name of the environment definition. Required. - "description": "str", # Optional. A short description of the environment - definition. - "parameters": [ - { - "id": "str", # Unique ID of the parameter. Required. - "required": bool, # Whether or not this parameter is - required. Required. - "type": "str", # A string of one of the basic JSON types - (number, integer, array, object, boolean, string). Required. Known values - are: "array", "boolean", "integer", "number", "object", and "string". - "allowed": [ - "str" # Optional. An array of allowed values. - ], - "default": "str", # Optional. Default value of the - parameter. - "description": "str", # Optional. Description of the - parameter. - "name": "str", # Optional. Display name of the parameter. - "readOnly": bool # Optional. Whether or not this parameter - is read-only. If true, default should have a value. - } - ], - "parametersSchema": "str", # Optional. JSON schema defining the parameters - object passed to an environment. - "templatePath": "str" # Optional. Path to the Environment Definition - entrypoint file. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -4577,7 +2870,7 @@ def list_environment_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environment_definitions_request( + _request = build_deployment_environments_list_environment_definitions_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -4629,8 +2922,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4642,7 +2933,6 @@ async def get_next(next_link=None): def list_environment_definitions_by_catalog( self, project_name: str, catalog_name: str, **kwargs: Any ) -> AsyncIterable["_models.EnvironmentDefinition"]: - # pylint: disable=line-too-long """Lists all environment definitions available within a catalog. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -4653,42 +2943,6 @@ def list_environment_definitions_by_catalog( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.EnvironmentDefinition] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "id": "str", # The ID of the environment definition. Required. - "name": "str", # Name of the environment definition. Required. - "description": "str", # Optional. A short description of the environment - definition. - "parameters": [ - { - "id": "str", # Unique ID of the parameter. Required. - "required": bool, # Whether or not this parameter is - required. Required. - "type": "str", # A string of one of the basic JSON types - (number, integer, array, object, boolean, string). Required. Known values - are: "array", "boolean", "integer", "number", "object", and "string". - "allowed": [ - "str" # Optional. An array of allowed values. - ], - "default": "str", # Optional. Default value of the - parameter. - "description": "str", # Optional. Description of the - parameter. - "name": "str", # Optional. Display name of the parameter. - "readOnly": bool # Optional. Whether or not this parameter - is read-only. If true, default should have a value. - } - ], - "parametersSchema": "str", # Optional. JSON schema defining the parameters - object passed to an environment. - "templatePath": "str" # Optional. Path to the Environment Definition - entrypoint file. - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -4706,7 +2960,7 @@ def list_environment_definitions_by_catalog( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environment_definitions_by_catalog_request( + _request = build_deployment_environments_list_environment_definitions_by_catalog_request( project_name=project_name, catalog_name=catalog_name, api_version=self._config.api_version, @@ -4759,8 +3013,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4772,7 +3024,6 @@ async def get_next(next_link=None): async def get_environment_definition( self, project_name: str, catalog_name: str, definition_name: str, **kwargs: Any ) -> _models.EnvironmentDefinition: - # pylint: disable=line-too-long """Get an environment definition from a catalog. :param project_name: Name of the project. Required. @@ -4784,42 +3035,6 @@ async def get_environment_definition( :return: EnvironmentDefinition. The EnvironmentDefinition is compatible with MutableMapping :rtype: ~azure.developer.devcenter.models.EnvironmentDefinition :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "catalogName": "str", # Name of the catalog. Required. - "id": "str", # The ID of the environment definition. Required. - "name": "str", # Name of the environment definition. Required. - "description": "str", # Optional. A short description of the environment - definition. - "parameters": [ - { - "id": "str", # Unique ID of the parameter. Required. - "required": bool, # Whether or not this parameter is - required. Required. - "type": "str", # A string of one of the basic JSON types - (number, integer, array, object, boolean, string). Required. Known values - are: "array", "boolean", "integer", "number", "object", and "string". - "allowed": [ - "str" # Optional. An array of allowed values. - ], - "default": "str", # Optional. Default value of the - parameter. - "description": "str", # Optional. Description of the - parameter. - "name": "str", # Optional. Display name of the parameter. - "readOnly": bool # Optional. Whether or not this parameter - is read-only. If true, default should have a value. - } - ], - "parametersSchema": "str", # Optional. JSON schema defining the parameters - object passed to an environment. - "templatePath": "str" # Optional. Path to the Environment Definition - entrypoint file. - } """ error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, @@ -4834,7 +3049,7 @@ async def get_environment_definition( cls: ClsType[_models.EnvironmentDefinition] = kwargs.pop("cls", None) - _request = build_dev_center_get_environment_definition_request( + _request = build_deployment_environments_get_environment_definition_request( project_name=project_name, catalog_name=catalog_name, definition_name=definition_name, @@ -4856,7 +3071,10 @@ async def get_environment_definition( if response.status_code not in [200]: if _stream: - await response.read() # Load the body in memory and close the socket + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) @@ -4872,28 +3090,14 @@ async def get_environment_definition( @distributed_trace def list_environment_types(self, project_name: str, **kwargs: Any) -> AsyncIterable["_models.EnvironmentType"]: - # pylint: disable=line-too-long """Lists all environment types configured for a project. - :param project_name: The DevCenter Project upon which to execute operations. Required. + :param project_name: Name of the project. Required. :type project_name: str :return: An iterator like instance of EnvironmentType :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.developer.devcenter.models.EnvironmentType] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deploymentTargetId": "str", # Id of a subscription or management group that - the environment type will be mapped to. The environment's resources will be - deployed into this subscription or management group. Required. - "name": "str", # Name of the environment type. Required. - "status": "str" # Indicates whether this environment type is enabled for use - in this project. Required. Known values are: "Enabled" and "Disabled". - } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -4911,7 +3115,7 @@ def list_environment_types(self, project_name: str, **kwargs: Any) -> AsyncItera def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_environment_types_request( + _request = build_deployment_environments_list_environment_types_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -4963,8 +3167,6 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - if _stream: - await response.read() # Load the body in memory and close the socket map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_vendor.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_vendor.py index a6ebf7871547..fdf71e577bdd 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_vendor.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/aio/_vendor.py @@ -8,7 +8,11 @@ from abc import ABC from typing import TYPE_CHECKING -from ._configuration import DevCenterClientConfiguration +from ._configuration import ( + DeploymentEnvironmentsClientConfiguration, + DevBoxesClientConfiguration, + DevCenterClientConfiguration, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -24,3 +28,21 @@ class DevCenterClientMixinABC(ABC): _config: DevCenterClientConfiguration _serialize: "Serializer" _deserialize: "Deserializer" + + +class DevBoxesClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: DevBoxesClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" + + +class DeploymentEnvironmentsClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: DeploymentEnvironmentsClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/__init__.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/__init__.py index 89f8c60752cf..b38768b0189c 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/__init__.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/__init__.py @@ -15,12 +15,10 @@ from ._models import EnvironmentDefinition from ._models import EnvironmentDefinitionParameter from ._models import EnvironmentType -from ._models import Error from ._models import HardwareProfile from ._models import ImageReference -from ._models import InnerError -from ._models import OSDisk -from ._models import OperationDetails +from ._models import OperationStatus +from ._models import OsDisk from ._models import Pool from ._models import Project from ._models import RemoteConnection @@ -35,8 +33,8 @@ from ._enums import EnvironmentTypeStatus from ._enums import HibernateSupport from ._enums import LocalAdministratorStatus -from ._enums import OSType -from ._enums import OperationStatus +from ._enums import OperationState +from ._enums import OsType from ._enums import ParameterType from ._enums import PoolHealthStatus from ._enums import PowerState @@ -58,12 +56,10 @@ "EnvironmentDefinition", "EnvironmentDefinitionParameter", "EnvironmentType", - "Error", "HardwareProfile", "ImageReference", - "InnerError", - "OSDisk", - "OperationDetails", + "OperationStatus", + "OsDisk", "Pool", "Project", "RemoteConnection", @@ -77,8 +73,8 @@ "EnvironmentTypeStatus", "HibernateSupport", "LocalAdministratorStatus", - "OSType", - "OperationStatus", + "OperationState", + "OsType", "ParameterType", "PoolHealthStatus", "PowerState", diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_enums.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_enums.py index ca1fa8869828..9f23d840ef4d 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_enums.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_enums.py @@ -117,7 +117,7 @@ class LocalAdministratorStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Owners of Dev Boxes in the pool are not local administrators on the Dev Boxes.""" -class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class OperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Enum describing allowed operation states.""" NOT_STARTED = "NotStarted" @@ -132,7 +132,7 @@ class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operation has been canceled by the user.""" -class OSType(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class OsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system type.""" WINDOWS = "Windows" diff --git a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_models.py b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_models.py index 9154decbf8f0..7379d424bd53 100644 --- a/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_models.py +++ b/sdk/devcenter/azure-developer-devcenter/azure/developer/devcenter/models/_models.py @@ -23,7 +23,6 @@ class Catalog(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar name: Name of the catalog. Required. :vartype name: str @@ -38,7 +37,6 @@ class DevBox(_model_base.Model): # pylint: disable=too-many-instance-attributes Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar name: Display name for the Dev Box. Required. :vartype name: str @@ -68,7 +66,7 @@ class DevBox(_model_base.Model): # pylint: disable=too-many-instance-attributes Virtual Network it is attached to. :vartype location: str :ivar os_type: The operating system type of this Dev Box. "Windows" - :vartype os_type: str or ~azure.developer.devcenter.models.OSType + :vartype os_type: str or ~azure.developer.devcenter.models.OsType :ivar user: The AAD object id of the user this Dev Box is assigned to. :vartype user: str :ivar hardware_profile: Information about the Dev Box's hardware resources. @@ -115,7 +113,7 @@ class DevBox(_model_base.Model): # pylint: disable=too-many-instance-attributes location: Optional[str] = rest_field(visibility=["read"]) """Azure region where this Dev Box is located. This will be the same region as the Virtual Network it is attached to.""" - os_type: Optional[Union[str, "_models.OSType"]] = rest_field(name="osType", visibility=["read"]) + os_type: Optional[Union[str, "_models.OsType"]] = rest_field(name="osType", visibility=["read"]) """The operating system type of this Dev Box. \"Windows\"""" user: Optional[str] = rest_field(visibility=["read"]) """The AAD object id of the user this Dev Box is assigned to.""" @@ -157,7 +155,6 @@ class DevBoxAction(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar name: The name of the action. Required. :vartype name: str @@ -206,13 +203,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles class DevBoxActionDelayResult(_model_base.Model): """The action delay result. - All required parameters must be populated in order to send to server. :ivar name: The name of the action. Required. :vartype name: str - :ivar result: The result of the delay operation on this action. Required. Known values are: - "Succeeded" and "Failed". - :vartype result: str or ~azure.developer.devcenter.models.DevBoxActionDelayStatus + :ivar delay_status: The result of the delay operation on this action. Required. Known values + are: "Succeeded" and "Failed". + :vartype delay_status: str or ~azure.developer.devcenter.models.DevBoxActionDelayStatus :ivar action: The delayed action. :vartype action: ~azure.developer.devcenter.models.DevBoxAction :ivar error: Information about the error that occurred. Only populated on error. @@ -221,7 +217,7 @@ class DevBoxActionDelayResult(_model_base.Model): name: str = rest_field() """The name of the action. Required.""" - result: Union[str, "_models.DevBoxActionDelayStatus"] = rest_field() + delay_status: Union[str, "_models.DevBoxActionDelayStatus"] = rest_field(name="result") """The result of the delay operation on this action. Required. Known values are: \"Succeeded\" and \"Failed\".""" action: Optional["_models.DevBoxAction"] = rest_field() @@ -234,7 +230,7 @@ def __init__( self, *, name: str, - result: Union[str, "_models.DevBoxActionDelayStatus"], + delay_status: Union[str, "_models.DevBoxActionDelayStatus"], action: Optional["_models.DevBoxAction"] = None, error: Optional["_models.Error"] = None, ): ... @@ -253,7 +249,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles class DevBoxNextAction(_model_base.Model): """Details about the next run of an action. - All required parameters must be populated in order to send to server. :ivar scheduled_time: The time the action will be triggered (UTC). Required. :vartype scheduled_time: ~datetime.datetime @@ -285,7 +280,6 @@ class Environment(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar parameters: Parameters object for the environment. :vartype parameters: dict[str, any] @@ -361,7 +355,6 @@ class EnvironmentDefinition(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar id: The ID of the environment definition. Required. :vartype id: str @@ -420,7 +413,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles class EnvironmentDefinitionParameter(_model_base.Model): """Properties of an Environment Definition parameter. - All required parameters must be populated in order to send to server. :ivar id: Unique ID of the parameter. Required. :vartype id: str @@ -491,7 +483,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles class EnvironmentType(_model_base.Model): """Properties of an environment type. - All required parameters must be populated in order to send to server. + Readonly variables are only populated by the server, and will be ignored when sending a request. + :ivar name: Name of the environment type. Required. :vartype name: str @@ -505,7 +498,7 @@ class EnvironmentType(_model_base.Model): :vartype status: str or ~azure.developer.devcenter.models.EnvironmentTypeStatus """ - name: str = rest_field() + name: str = rest_field(visibility=["read"]) """Name of the environment type. Required.""" deployment_target_id: str = rest_field(name="deploymentTargetId") """Id of a subscription or management group that the environment type will be @@ -519,7 +512,6 @@ class EnvironmentType(_model_base.Model): def __init__( self, *, - name: str, deployment_target_id: str, status: Union[str, "_models.EnvironmentTypeStatus"], ): ... @@ -535,57 +527,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles super().__init__(*args, **kwargs) -class Error(_model_base.Model): - """The error object. - - All required parameters must be populated in order to send to server. - - :ivar code: One of a server-defined set of error codes. Required. - :vartype code: str - :ivar message: A human-readable representation of the error. Required. - :vartype message: str - :ivar target: The target of the error. - :vartype target: str - :ivar details: An array of details about specific errors that led to this reported error. - :vartype details: list[~azure.developer.devcenter.models.Error] - :ivar innererror: An object containing more specific information than the current object about - the error. - :vartype innererror: ~azure.developer.devcenter.models.InnerError - """ - - code: str = rest_field() - """One of a server-defined set of error codes. Required.""" - message: str = rest_field() - """A human-readable representation of the error. Required.""" - target: Optional[str] = rest_field() - """The target of the error.""" - details: Optional[List["_models.Error"]] = rest_field() - """An array of details about specific errors that led to this reported error.""" - innererror: Optional["_models.InnerError"] = rest_field() - """An object containing more specific information than the current object about the error.""" - - @overload - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - details: Optional[List["_models.Error"]] = None, - innererror: Optional["_models.InnerError"] = None, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - class HardwareProfile(_model_base.Model): """Hardware specifications for the Dev Box. @@ -601,10 +542,10 @@ class HardwareProfile(_model_base.Model): "general_a_32c128gb512ssd_v2", "general_a_32c128gb1024ssd_v2", and "general_a_32c128gb2048ssd_v2". :vartype sku_name: str or ~azure.developer.devcenter.models.SkuName - :ivar vcpus: The number of vCPUs available for the Dev Box. - :vartype vcpus: int - :ivar memory_gb: The amount of memory available for the Dev Box. - :vartype memory_gb: int + :ivar v_c_p_us: The number of vCPUs available for the Dev Box. + :vartype v_c_p_us: int + :ivar memory_g_b: The amount of memory available for the Dev Box. + :vartype memory_g_b: int """ sku_name: Optional[Union[str, "_models.SkuName"]] = rest_field(name="skuName", visibility=["read"]) @@ -618,9 +559,9 @@ class HardwareProfile(_model_base.Model): \"general_a_16c64gb512ssd_v2\", \"general_a_16c64gb1024ssd_v2\", \"general_a_16c64gb2048ssd_v2\", \"general_a_32c128gb512ssd_v2\", \"general_a_32c128gb1024ssd_v2\", and \"general_a_32c128gb2048ssd_v2\".""" - vcpus: Optional[int] = rest_field(name="vCPUs", visibility=["read"]) + v_c_p_us: Optional[int] = rest_field(name="vCPUs", visibility=["read"]) """The number of vCPUs available for the Dev Box.""" - memory_gb: Optional[int] = rest_field(name="memoryGB", visibility=["read"]) + memory_g_b: Optional[int] = rest_field(name="memoryGB", visibility=["read"]) """The amount of memory available for the Dev Box.""" @@ -655,47 +596,11 @@ class ImageReference(_model_base.Model): """The datetime that the backing image version was published.""" -class InnerError(_model_base.Model): - """An object containing more specific information about the error. As per Microsoft One API - guidelines - - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. - - :ivar code: One of a server-defined set of error codes. - :vartype code: str - :ivar innererror: Inner error. - :vartype innererror: ~azure.developer.devcenter.models.InnerError - """ - - code: Optional[str] = rest_field() - """One of a server-defined set of error codes.""" - innererror: Optional["_models.InnerError"] = rest_field() - """Inner error.""" - - @overload - def __init__( - self, - *, - code: Optional[str] = None, - innererror: Optional["_models.InnerError"] = None, - ): ... - - @overload - def __init__(self, mapping: Mapping[str, Any]): - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useless-super-delegation - super().__init__(*args, **kwargs) - - -class OperationDetails(_model_base.Model): +class OperationStatus(_model_base.Model): """The current status of an async operation. Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar id: Fully qualified ID for the operation status. Required. :vartype id: str @@ -703,7 +608,7 @@ class OperationDetails(_model_base.Model): :vartype name: str :ivar status: Provisioning state of the resource. Required. Known values are: "NotStarted", "Running", "Succeeded", "Failed", and "Canceled". - :vartype status: str or ~azure.developer.devcenter.models.OperationStatus + :vartype status: str or ~azure.developer.devcenter.models.OperationState :ivar resource_id: The id of the resource. :vartype resource_id: str :ivar start_time: The start time of the operation. @@ -722,7 +627,7 @@ class OperationDetails(_model_base.Model): """Fully qualified ID for the operation status. Required.""" name: str = rest_field(visibility=["read"]) """The operation id name. Required.""" - status: Union[str, "_models.OperationStatus"] = rest_field() + status: Union[str, "_models.OperationState"] = rest_field() """Provisioning state of the resource. Required. Known values are: \"NotStarted\", \"Running\", \"Succeeded\", \"Failed\", and \"Canceled\".""" resource_id: Optional[str] = rest_field(name="resourceId") @@ -742,7 +647,7 @@ class OperationDetails(_model_base.Model): def __init__( self, *, - status: Union[str, "_models.OperationStatus"], + status: Union[str, "_models.OperationState"], resource_id: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, @@ -762,16 +667,16 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles super().__init__(*args, **kwargs) -class OSDisk(_model_base.Model): +class OsDisk(_model_base.Model): """Settings for the operating system disk. Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar disk_size_gb: The size of the OS Disk in gigabytes. - :vartype disk_size_gb: int + :ivar disk_size_g_b: The size of the OS Disk in gigabytes. + :vartype disk_size_g_b: int """ - disk_size_gb: Optional[int] = rest_field(name="diskSizeGB", visibility=["read"]) + disk_size_g_b: Optional[int] = rest_field(name="diskSizeGB", visibility=["read"]) """The size of the OS Disk in gigabytes.""" @@ -780,14 +685,13 @@ class Pool(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar name: Pool name. Required. :vartype name: str :ivar location: Azure region where Dev Boxes in the pool are located. Required. :vartype location: str :ivar os_type: The operating system type of Dev Boxes in this pool. "Windows" - :vartype os_type: str or ~azure.developer.devcenter.models.OSType + :vartype os_type: str or ~azure.developer.devcenter.models.OsType :ivar hardware_profile: Hardware settings for the Dev Boxes created in this pool. :vartype hardware_profile: ~azure.developer.devcenter.models.HardwareProfile :ivar hibernate_support: Indicates whether hibernate is enabled/disabled or unknown. Known @@ -814,7 +718,7 @@ class Pool(_model_base.Model): """Pool name. Required.""" location: str = rest_field() """Azure region where Dev Boxes in the pool are located. Required.""" - os_type: Optional[Union[str, "_models.OSType"]] = rest_field(name="osType") + os_type: Optional[Union[str, "_models.OsType"]] = rest_field(name="osType") """The operating system type of Dev Boxes in this pool. \"Windows\"""" hardware_profile: Optional["_models.HardwareProfile"] = rest_field(name="hardwareProfile") """Hardware settings for the Dev Boxes created in this pool.""" @@ -843,7 +747,7 @@ def __init__( *, location: str, health_status: Union[str, "_models.PoolHealthStatus"], - os_type: Optional[Union[str, "_models.OSType"]] = None, + os_type: Optional[Union[str, "_models.OsType"]] = None, hardware_profile: Optional["_models.HardwareProfile"] = None, hibernate_support: Optional[Union[str, "_models.HibernateSupport"]] = None, storage_profile: Optional["_models.StorageProfile"] = None, @@ -868,7 +772,6 @@ class Project(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar name: Name of the project. Required. :vartype name: str @@ -945,7 +848,6 @@ class Schedule(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to server. :ivar name: Display name for the Schedule. Required. :vartype name: str @@ -994,7 +896,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles class StopOnDisconnectConfiguration(_model_base.Model): """Stop on disconnect configuration settings for Dev Boxes created in this pool. - All required parameters must be populated in order to send to server. :ivar status: Indicates whether the feature to stop the devbox on disconnect once the grace period has lapsed is enabled. Required. Known values are: "Enabled" and "Disabled". @@ -1035,17 +936,17 @@ class StorageProfile(_model_base.Model): """Storage settings for the Dev Box's disks. :ivar os_disk: Settings for the operating system disk. - :vartype os_disk: ~azure.developer.devcenter.models.OSDisk + :vartype os_disk: ~azure.developer.devcenter.models.OsDisk """ - os_disk: Optional["_models.OSDisk"] = rest_field(name="osDisk") + os_disk: Optional["_models.OsDisk"] = rest_field(name="osDisk") """Settings for the operating system disk.""" @overload def __init__( self, *, - os_disk: Optional["_models.OSDisk"] = None, + os_disk: Optional["_models.OsDisk"] = None, ): ... @overload diff --git a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/deployment_environments_async_sample.py b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/deployment_environments_async_sample.py index c09e6cd08891..76f7fd09939d 100644 --- a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/deployment_environments_async_sample.py +++ b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/deployment_environments_async_sample.py @@ -90,7 +90,9 @@ async def environment_create_and_delete_async(): # List available Environment Definitions environment_definitions = [] - async for environment_definition in client.list_environment_definitions_by_catalog(target_project_name, target_catalog_name): + async for environment_definition in client.list_environment_definitions_by_catalog( + target_project_name, target_catalog_name + ): environment_definitions.append(environment_definition) if environment_definitions: print("\nList of environment definitions: ") @@ -141,8 +143,10 @@ async def environment_create_and_delete_async(): print(f"Completed deletion for the environment with status {delete_result.status}") # [END environment_create_and_delete_async] + async def main(): await environment_create_and_delete_async() -if __name__ == '__main__': + +if __name__ == "__main__": asyncio.run(main()) diff --git a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_action_async_sample.py b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_action_async_sample.py index f07a385725d8..3c22d6be12b1 100644 --- a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_action_async_sample.py +++ b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_action_async_sample.py @@ -47,6 +47,7 @@ 1) DEVCENTER_ENDPOINT - the endpoint for your devcenter """ + async def dev_box_action_async(): # Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables: @@ -75,7 +76,9 @@ async def dev_box_action_async(): raise ValueError("Missing Dev Box - please create one before running the example.") # Get the schedule default action. This action should exist for dev boxes created with auto-stop enabled - action = await client.get_dev_box_action(target_dev_box.project_name, "me", target_dev_box.name, "schedule-default") + action = await client.get_dev_box_action( + target_dev_box.project_name, "me", target_dev_box.name, "schedule-default" + ) next_action_time = action.next.scheduled_time print(f"\nAction {action.Name} is schedule to {action.ActionType} at {next_action_time}.") @@ -92,8 +95,10 @@ async def dev_box_action_async(): await client.skip_dev_box_action(target_dev_box.project_name, "me", target_dev_box.name, "schedule-default") print(f"\nThe scheduled auto-stop action in dev box {target_dev_box.name} has been skipped") + async def main(): await dev_box_action_async() -if __name__ == '__main__': + +if __name__ == "__main__": asyncio.run(main()) diff --git a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_create_async_sample.py b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_create_async_sample.py index a2335ad58a19..5c2dd1b02fd5 100644 --- a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_create_async_sample.py +++ b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_create_async_sample.py @@ -45,6 +45,7 @@ from azure.developer.devcenter.aio import DevCenterClient from azure.identity import DefaultAzureCredential + async def dev_box_create_connect_delete_async(): # [START dev_box_create_connect_delete_async] # Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables: @@ -66,12 +67,12 @@ async def dev_box_create_connect_delete_async(): print("\nList of projects: ") for project in projects: print(f"{project.name}") - + # Select first project in the list target_project_name = projects[0].name else: raise ValueError("Missing Project - please create one before running the example") - + # List available Pools pools = [] async for pool in client.list_pools(target_project_name): @@ -80,35 +81,37 @@ async def dev_box_create_connect_delete_async(): print("\nList of pools: ") for pool in pools: print(f"{pool.name}") - + # Select first pool in the list target_pool_name = pools[0].name else: raise ValueError("Missing Pool - please create one before running the example") - + # Stand up a new Dev Box print(f"\nStarting to create dev box in project {target_project_name} and pool {target_pool_name}") - + dev_box_poller = await client.begin_create_dev_box( target_project_name, "me", "Test_DevBox", {"poolName": target_pool_name} ) dev_box = await dev_box_poller.result() print(f"Provisioned dev box with status {dev_box.provisioning_state}.") - + # Connect to the provisioned Dev Box remote_connection = await client.get_remote_connection(target_project_name, "me", dev_box.name) print(f"Connect to the dev box using web URL {remote_connection.web_url}") - + # Tear down the Dev Box when finished print(f"Starting to delete dev box.") - + delete_poller = await client.begin_delete_dev_box(target_project_name, "me", "Test_DevBox") delete_result = await delete_poller.result() print(f"Completed deletion for the dev box with status {delete_result.status}") # [END dev_box_create_connect_delete_async] + async def main(): await dev_box_create_connect_delete_async() -if __name__ == '__main__': + +if __name__ == "__main__": asyncio.run(main()) diff --git a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_restart_async_sample.py b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_restart_async_sample.py index 8cff68746acd..dad191d28b54 100644 --- a/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_restart_async_sample.py +++ b/sdk/devcenter/azure-developer-devcenter/samples/async_samples/dev_box_restart_async_sample.py @@ -46,6 +46,7 @@ 1) DEVCENTER_ENDPOINT - the endpoint for your devcenter """ + async def dev_box_restart_stop_start_async(): # Set the values of the dev center endpoint, client ID, and client secret of the AAD application as environment variables: @@ -67,35 +68,37 @@ async def dev_box_restart_stop_start_async(): print("List of dev boxes: ") for dev_box in dev_boxes: print(f"{dev_box.name}") - + # Select first dev box in the list target_dev_box = dev_boxes[0] else: raise ValueError("Missing Dev Box - please create one before running the example.") - + # Get the target dev box properties project_name = target_dev_box.project_name user = target_dev_box.user dev_box_name = target_dev_box.name - + # Stop dev box if it's running if target_dev_box.power_state == PowerState.Running: stop_poller = await client.begin_stop_dev_box(project_name, user, dev_box_name) stop_result = await stop_poller.result() print(f"Stopping dev box completed with status {stop_result.status}") - + # At this point we should have a stopped dev box . Let's start it start_poller = await client.begin_start_dev_box(project_name, user, dev_box_name) start_result = await start_poller.result() print(f"Starting dev box completed with status {start_result.status}") - + # Restart the dev box restart_poller = await client.begin_restart_dev_box(project_name, user, dev_box_name) restart_result = await restart_poller.result() print(f"Done restarting the dev box with status {start_result.status}") + async def main(): await dev_box_restart_stop_start_async() -if __name__ == '__main__': + +if __name__ == "__main__": asyncio.run(main()) diff --git a/sdk/devcenter/azure-developer-devcenter/samples/create_client_sample.py b/sdk/devcenter/azure-developer-devcenter/samples/create_client_sample.py index 70836ae439c7..49d102565fbf 100644 --- a/sdk/devcenter/azure-developer-devcenter/samples/create_client_sample.py +++ b/sdk/devcenter/azure-developer-devcenter/samples/create_client_sample.py @@ -39,6 +39,7 @@ 1) DEVCENTER_ENDPOINT - the endpoint for your devcenter """ + def create_dev_center_client(): # [START create_dev_center_client] import os @@ -57,5 +58,6 @@ def create_dev_center_client(): client = DevCenterClient(endpoint, credential=DefaultAzureCredential()) # [END create_dev_center_client] + if __name__ == "__main__": create_dev_center_client() diff --git a/sdk/devcenter/azure-developer-devcenter/samples/deployment_environments_sample.py b/sdk/devcenter/azure-developer-devcenter/samples/deployment_environments_sample.py index 4ffaf5d12603..7e0fef55b9e6 100644 --- a/sdk/devcenter/azure-developer-devcenter/samples/deployment_environments_sample.py +++ b/sdk/devcenter/azure-developer-devcenter/samples/deployment_environments_sample.py @@ -40,6 +40,7 @@ 1) DEVCENTER_ENDPOINT - the endpoint for your devcenter """ + def environment_create_and_delete(): # [START environment_create_and_delete] import os diff --git a/sdk/devcenter/azure-developer-devcenter/samples/dev_box_create_sample.py b/sdk/devcenter/azure-developer-devcenter/samples/dev_box_create_sample.py index c8cefb4c41c8..3a181bbfca5a 100644 --- a/sdk/devcenter/azure-developer-devcenter/samples/dev_box_create_sample.py +++ b/sdk/devcenter/azure-developer-devcenter/samples/dev_box_create_sample.py @@ -40,6 +40,7 @@ 1) DEVCENTER_ENDPOINT - the endpoint for your devcenter """ + def dev_box_create_connect_delete(): # [START dev_box_create_connect_delete] import os @@ -102,5 +103,6 @@ def dev_box_create_connect_delete(): print(f"Completed deletion for the dev box with status {delete_result.status}") # [END dev_box_create_connect_delete] + if __name__ == "__main__": dev_box_create_connect_delete() diff --git a/sdk/devcenter/azure-developer-devcenter/tests/conftest.py b/sdk/devcenter/azure-developer-devcenter/tests/conftest.py index 07e19a00eff0..a759437b05a2 100644 --- a/sdk/devcenter/azure-developer-devcenter/tests/conftest.py +++ b/sdk/devcenter/azure-developer-devcenter/tests/conftest.py @@ -15,19 +15,23 @@ ) import pytest + # autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method @pytest.fixture(scope="session", autouse=True) def start_proxy(test_proxy): add_body_key_sanitizer(json_path="$..id_token", value="Sanitized") add_body_key_sanitizer(json_path="$..client_info", value="Sanitized") add_oauth_response_sanitizer() - add_uri_regex_sanitizer(regex="\\.(?.*)\\.devcenter\\.azure\\.com", group_for_replace="location", value="location") + add_uri_regex_sanitizer( + regex="\\.(?.*)\\.devcenter\\.azure\\.com", group_for_replace="location", value="location" + ) # Remove the following sanitizers since certain fields are needed in tests and are non-sensitive: # - AZSDK2003: Location # - AZSDK3493: $..name remove_batch_sanitizers(["AZSDK2003", "AZSDK3493"]) return + @pytest.fixture(scope="session", autouse=True) def patch_async_sleep(): async def immediate_return(_): diff --git a/sdk/devcenter/azure-developer-devcenter/tests/test_devcenter_operations_async.py b/sdk/devcenter/azure-developer-devcenter/tests/test_devcenter_operations_async.py index d5023a07a7e0..5eed70e20e02 100644 --- a/sdk/devcenter/azure-developer-devcenter/tests/test_devcenter_operations_async.py +++ b/sdk/devcenter/azure-developer-devcenter/tests/test_devcenter_operations_async.py @@ -139,13 +139,15 @@ async def test_create_dev_box_async(self, **kwargs): async with client: # Create DevBox - create_devbox_response = await client.begin_create_dev_box(project_name, user, devbox_name, {"poolName": pool_name}) + create_devbox_response = await client.begin_create_dev_box( + project_name, user, devbox_name, {"poolName": pool_name} + ) devbox_result = await create_devbox_response.result() assert devbox_result is not None assert devbox_result.provisioning_state in [ DevBoxProvisioningState.SUCCEEDED, DevBoxProvisioningState.PROVISIONED_WITH_WARNING, - ] + ] @DevcenterPowerShellPreparer() @recorded_by_proxy_async @@ -160,7 +162,9 @@ async def test_dev_box_action_async(self, **kwargs): async with client: # Actions - action_response = await client.get_dev_box_action(project_name, default_user, devbox_name, "schedule-default") + action_response = await client.get_dev_box_action( + project_name, default_user, devbox_name, "schedule-default" + ) next_time_date = action_response.next.scheduled_time assert next_time_date is not None assert action_response.name == "schedule-default" @@ -172,7 +176,9 @@ async def test_dev_box_action_async(self, **kwargs): next_time_date = next_time_date + timedelta(hours=1) delay_all_response = [] - async for action in client.delay_all_dev_box_actions(project_name, default_user, devbox_name, delay_until=next_time_date): + async for action in client.delay_all_dev_box_actions( + project_name, default_user, devbox_name, delay_until=next_time_date + ): delay_all_response.append(action) assert delay_all_response[0].action.next.scheduled_time == next_time_date @@ -247,7 +253,7 @@ async def test_list_all_dev_boxes_by_user_async(self, **kwargs): default_user = "me" client = self.create_client(endpoint) - + async with client: devboxes = [] async for devbox in client.list_all_dev_boxes_by_user(default_user): @@ -320,7 +326,7 @@ async def test_get_catalog_async(self, **kwargs): catalog_name = kwargs.pop("devcenter_catalog_name") client = self.create_client(endpoint) - + async with client: catalog_response = await client.get_catalog(project_name, catalog_name) assert catalog_response.name == catalog_name @@ -340,7 +346,7 @@ async def test_list_catalogs_async(self, **kwargs): async for catalog in client.list_catalogs(project_name): if catalog.name == catalog_name: catalogs.append(catalog) - + assert len(catalogs) == 1 assert catalogs[0].name == catalog_name @@ -356,7 +362,9 @@ async def test_get_environment_definition_async(self, **kwargs): client = self.create_client(endpoint) async with client: - env_definition_response = await client.get_environment_definition(project_name, catalog_name, env_definition_name) + env_definition_response = await client.get_environment_definition( + project_name, catalog_name, env_definition_name + ) assert env_definition_response.name == env_definition_name @DevcenterPowerShellPreparer() @@ -368,13 +376,13 @@ async def test_list_environment_definitions_async(self, **kwargs): env_definition_name = kwargs.pop("devcenter_environment_definition_name") client = self.create_client(endpoint) - + async with client: env_definitions = [] async for env_definition in client.list_environment_definitions(project_name): if env_definition.name == env_definition_name: env_definitions.append(env_definition) - + assert len(env_definitions) == 1 assert env_definitions[0].name == env_definition_name @@ -443,26 +451,26 @@ async def test_environments_async(self, **kwargs): ) create_env_result = await create_env_response.result() assert create_env_result.provisioning_state == DevBoxProvisioningState.SUCCEEDED - + env_response = await client.get_environment(project_name, default_user, env_name) assert env_response.name == env_name - + envs = [] async for env in client.list_environments(project_name, default_user): if env.name == env_name: envs.append(env) - + assert len(envs) == 1 assert envs[0].name == env_name - + all_envs = [] async for env in client.list_all_environments(project_name): if env.name == env_name: all_envs.append(env) - + assert len(all_envs) == 1 assert all_envs[0].name == env_name - + delete_response = await client.begin_delete_environment(project_name, default_user, env_name) delete_result = await delete_response.result() - assert delete_result.status == OperationStatus.SUCCEEDED \ No newline at end of file + assert delete_result.status == OperationStatus.SUCCEEDED diff --git a/sdk/devcenter/azure-developer-devcenter/tsp-location.yaml b/sdk/devcenter/azure-developer-devcenter/tsp-location.yaml index c0db4e4e25d4..974362676ecc 100644 --- a/sdk/devcenter/azure-developer-devcenter/tsp-location.yaml +++ b/sdk/devcenter/azure-developer-devcenter/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/devcenter/DevCenter -commit: d17b385b2e840c541b50f1d415dab6fd408d0814 -repo: Azure/azure-rest-api-specs -cleanup: true +commit: e8136c11848f05e79597bab310539c506b4af9df +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: