From 50e26d72dd636d692b0e08c5f5e80ad6aad44e1f Mon Sep 17 00:00:00 2001 From: Amanda Lim Date: Fri, 3 Nov 2023 00:01:18 -0700 Subject: [PATCH 1/3] Remove customization --- .../catalog_devbox_definition/__cmd_group.py | 23 -- .../catalog_devbox_definition/__init__.py | 14 - .../_get_error_detail.py | 209 ------------ .../admin/catalog_devbox_definition/_list.py | 306 ----------------- .../admin/catalog_devbox_definition/_show.py | 309 ------------------ .../admin/catalog_task/__cmd_group.py | 23 -- .../devcenter/admin/catalog_task/__init__.py | 14 - .../admin/catalog_task/_get_error_detail.py | 209 ------------ .../devcenter/admin/catalog_task/_list.py | 257 --------------- .../devcenter/admin/catalog_task/_show.py | 260 --------------- 10 files changed, 1624 deletions(-) delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__cmd_group.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__init__.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_get_error_detail.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_list.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_show.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__cmd_group.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__init__.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_get_error_detail.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_list.py delete mode 100644 src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_show.py diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__cmd_group.py deleted file mode 100644 index e71aba2da45..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__cmd_group.py +++ /dev/null @@ -1,23 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command_group( - "devcenter admin catalog-devbox-definition", -) -class __CMDGroup(AAZCommandGroup): - """Manage catalog dev box definitions. - """ - pass - - -__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__init__.py deleted file mode 100644 index a88f2db9d0d..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from .__cmd_group import * -from ._get_error_detail import * -from ._list import * -from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_get_error_detail.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_get_error_detail.py deleted file mode 100644 index c2f5b3cd411..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_get_error_detail.py +++ /dev/null @@ -1,209 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "devcenter admin catalog-devbox-definition get-error-detail", -) -class GetErrorDetail(AAZCommand): - """Gets catalog dev box definition error details. - - :example: Get error detail - az devcenter admin catalog-devbox-definition get-error-detail --catalog-name "CentralCatalog" --dev-center-name "Contoso" --resource-group "rg1" --devbox-definition-name "WebDevBox" - """ - - _aaz_info = { - "version": "2023-10-01-preview", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devcenter/devcenters/{}/catalogs/{}/devboxdefinitions/{}/geterrordetails", "2023-10-01-preview"], - ] - } - - def _handler(self, command_args): - super()._handler(command_args) - self._execute_operations() - return self._output() - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.catalog_name = AAZStrArg( - options=["--catalog-name"], - help="The name of the catalog.", - required=True, - id_part="child_name_1", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.devbox_definition_name = AAZStrArg( - options=["-n", "--name", "--devbox-definition-name"], - help="The name of the dev box definition.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.dev_center_name = AAZStrArg( - options=["-d", "--dev-center", "--dev-center-name"], - help="The name of the dev center.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-]{2,25}$", - max_length=26, - min_length=3, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.CatalogDevBoxDefinitionsGetErrorDetails(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) - return result - - class CatalogDevBoxDefinitionsGetErrorDetails(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200]: - return self.on_200(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/devboxdefinitions/{devBoxDefinitionName}/getErrorDetails", - **self.url_parameters - ) - - @property - def method(self): - return "POST" - - @property - def error_format(self): - return "ODataV4Format" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "catalogName", self.ctx.args.catalog_name, - required=True, - ), - **self.serialize_url_param( - "devBoxDefinitionName", self.ctx.args.devbox_definition_name, - required=True, - ), - **self.serialize_url_param( - "devCenterName", self.ctx.args.dev_center_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-10-01-preview", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.errors = AAZListType( - flags={"read_only": True}, - ) - - errors = cls._schema_on_200.errors - errors.Element = AAZObjectType() - - _element = cls._schema_on_200.errors.Element - _element.code = AAZStrType() - _element.message = AAZStrType() - - return cls._schema_on_200 - - -class _GetErrorDetailHelper: - """Helper class for GetErrorDetail""" - - -__all__ = ["GetErrorDetail"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_list.py deleted file mode 100644 index beac981c34a..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_list.py +++ /dev/null @@ -1,306 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "devcenter admin catalog-devbox-definition list", -) -class List(AAZCommand): - """List dev box definitions in the catalog. - - :example: List - az devcenter admin catalog-devbox-definition list --catalog-name "CentralCatalog" --dev-center-name "Contoso" --resource-group "rg1" - """ - - _aaz_info = { - "version": "2023-10-01-preview", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devcenter/devcenters/{}/catalogs/{}/devboxdefinitions", "2023-10-01-preview"], - ] - } - - AZ_SUPPORT_PAGINATION = True - - def _handler(self, command_args): - super()._handler(command_args) - return self.build_paging(self._execute_operations, self._output) - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.catalog_name = AAZStrArg( - options=["--catalog-name"], - help="The name of the catalog.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.dev_center_name = AAZStrArg( - options=["-d", "--dev-center", "--dev-center-name"], - help="The name of the dev center.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-]{2,25}$", - max_length=26, - min_length=3, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.CatalogDevBoxDefinitionsListByCatalog(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) - next_link = self.deserialize_output(self.ctx.vars.instance.next_link) - return result, next_link - - class CatalogDevBoxDefinitionsListByCatalog(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200]: - return self.on_200(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/devboxdefinitions", - **self.url_parameters - ) - - @property - def method(self): - return "GET" - - @property - def error_format(self): - return "ODataV4Format" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "catalogName", self.ctx.args.catalog_name, - required=True, - ), - **self.serialize_url_param( - "devCenterName", self.ctx.args.dev_center_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-10-01-preview", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.next_link = AAZStrType( - serialized_name="nextLink", - flags={"read_only": True}, - ) - _schema_on_200.value = AAZListType( - flags={"read_only": True}, - ) - - value = cls._schema_on_200.value - value.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element - _element.id = AAZStrType( - flags={"read_only": True}, - ) - _element.location = AAZStrType( - flags={"required": True}, - ) - _element.name = AAZStrType( - flags={"read_only": True}, - ) - _element.properties = AAZObjectType( - flags={"client_flatten": True}, - ) - _element.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _element.tags = AAZDictType() - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.value.Element.properties - properties.active_image_reference = AAZObjectType( - serialized_name="activeImageReference", - ) - _ListHelper._build_schema_image_reference_read(properties.active_image_reference) - properties.hibernate_support = AAZStrType( - serialized_name="hibernateSupport", - ) - properties.image_reference = AAZObjectType( - serialized_name="imageReference", - flags={"required": True}, - ) - _ListHelper._build_schema_image_reference_read(properties.image_reference) - properties.image_validation_error_details = AAZObjectType( - serialized_name="imageValidationErrorDetails", - ) - properties.image_validation_status = AAZStrType( - serialized_name="imageValidationStatus", - ) - properties.os_storage_type = AAZStrType( - serialized_name="osStorageType", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.sku = AAZObjectType( - flags={"required": True}, - ) - properties.validation_status = AAZStrType( - serialized_name="validationStatus", - ) - - image_validation_error_details = cls._schema_on_200.value.Element.properties.image_validation_error_details - image_validation_error_details.code = AAZStrType() - image_validation_error_details.message = AAZStrType() - - sku = cls._schema_on_200.value.Element.properties.sku - sku.capacity = AAZIntType() - sku.family = AAZStrType() - sku.name = AAZStrType( - flags={"required": True}, - ) - sku.size = AAZStrType() - sku.tier = AAZStrType() - - system_data = cls._schema_on_200.value.Element.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by = AAZStrType( - serialized_name="createdBy", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - tags = cls._schema_on_200.value.Element.tags - tags.Element = AAZStrType() - - return cls._schema_on_200 - - -class _ListHelper: - """Helper class for List""" - - _schema_image_reference_read = None - - @classmethod - def _build_schema_image_reference_read(cls, _schema): - if cls._schema_image_reference_read is not None: - _schema.exact_version = cls._schema_image_reference_read.exact_version - _schema.id = cls._schema_image_reference_read.id - return - - cls._schema_image_reference_read = _schema_image_reference_read = AAZObjectType() - - image_reference_read = _schema_image_reference_read - image_reference_read.exact_version = AAZStrType( - serialized_name="exactVersion", - flags={"read_only": True}, - ) - image_reference_read.id = AAZStrType() - - _schema.exact_version = cls._schema_image_reference_read.exact_version - _schema.id = cls._schema_image_reference_read.id - - -__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_show.py deleted file mode 100644 index 784dac882ad..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_devbox_definition/_show.py +++ /dev/null @@ -1,309 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "devcenter admin catalog-devbox-definition show", -) -class Show(AAZCommand): - """Get a dev box definition from the catalog. - - :example: Get - az devcenter admin catalog-devbox-definition show --catalog-name "CentralCatalog" -devbox-definition-name "devBoxDef" --dev-center-name "Contoso" --resource-group "rg1" - """ - - _aaz_info = { - "version": "2023-10-01-preview", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devcenter/devcenters/{}/catalogs/{}/devboxdefinitions/{}", "2023-10-01-preview"], - ] - } - - def _handler(self, command_args): - super()._handler(command_args) - self._execute_operations() - return self._output() - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.catalog_name = AAZStrArg( - options=["--catalog-name"], - help="The name of the catalog.", - required=True, - id_part="child_name_1", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.devbox_definition_name = AAZStrArg( - options=["-n", "--name", "--devbox-definition-name"], - help="The name of the dev box definition.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.dev_center_name = AAZStrArg( - options=["-d", "--dev-center", "--dev-center-name"], - help="The name of the dev center.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-]{2,25}$", - max_length=26, - min_length=3, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.CatalogDevBoxDefinitionsGet(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) - return result - - class CatalogDevBoxDefinitionsGet(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200]: - return self.on_200(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/devboxdefinitions/{devBoxDefinitionName}", - **self.url_parameters - ) - - @property - def method(self): - return "GET" - - @property - def error_format(self): - return "ODataV4Format" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "catalogName", self.ctx.args.catalog_name, - required=True, - ), - **self.serialize_url_param( - "devBoxDefinitionName", self.ctx.args.devbox_definition_name, - required=True, - ), - **self.serialize_url_param( - "devCenterName", self.ctx.args.dev_center_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-10-01-preview", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.id = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.location = AAZStrType( - flags={"required": True}, - ) - _schema_on_200.name = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, - ) - _schema_on_200.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _schema_on_200.tags = AAZDictType() - _schema_on_200.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.properties - properties.active_image_reference = AAZObjectType( - serialized_name="activeImageReference", - ) - _ShowHelper._build_schema_image_reference_read(properties.active_image_reference) - properties.hibernate_support = AAZStrType( - serialized_name="hibernateSupport", - ) - properties.image_reference = AAZObjectType( - serialized_name="imageReference", - flags={"required": True}, - ) - _ShowHelper._build_schema_image_reference_read(properties.image_reference) - properties.image_validation_error_details = AAZObjectType( - serialized_name="imageValidationErrorDetails", - ) - properties.image_validation_status = AAZStrType( - serialized_name="imageValidationStatus", - ) - properties.os_storage_type = AAZStrType( - serialized_name="osStorageType", - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - properties.sku = AAZObjectType( - flags={"required": True}, - ) - properties.validation_status = AAZStrType( - serialized_name="validationStatus", - ) - - image_validation_error_details = cls._schema_on_200.properties.image_validation_error_details - image_validation_error_details.code = AAZStrType() - image_validation_error_details.message = AAZStrType() - - sku = cls._schema_on_200.properties.sku - sku.capacity = AAZIntType() - sku.family = AAZStrType() - sku.name = AAZStrType( - flags={"required": True}, - ) - sku.size = AAZStrType() - sku.tier = AAZStrType() - - system_data = cls._schema_on_200.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by = AAZStrType( - serialized_name="createdBy", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - tags = cls._schema_on_200.tags - tags.Element = AAZStrType() - - return cls._schema_on_200 - - -class _ShowHelper: - """Helper class for Show""" - - _schema_image_reference_read = None - - @classmethod - def _build_schema_image_reference_read(cls, _schema): - if cls._schema_image_reference_read is not None: - _schema.exact_version = cls._schema_image_reference_read.exact_version - _schema.id = cls._schema_image_reference_read.id - return - - cls._schema_image_reference_read = _schema_image_reference_read = AAZObjectType() - - image_reference_read = _schema_image_reference_read - image_reference_read.exact_version = AAZStrType( - serialized_name="exactVersion", - flags={"read_only": True}, - ) - image_reference_read.id = AAZStrType() - - _schema.exact_version = cls._schema_image_reference_read.exact_version - _schema.id = cls._schema_image_reference_read.id - - -__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__cmd_group.py deleted file mode 100644 index 563e3787fd7..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__cmd_group.py +++ /dev/null @@ -1,23 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command_group( - "devcenter admin catalog-task", -) -class __CMDGroup(AAZCommandGroup): - """Manage tasks in catalog. - """ - pass - - -__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__init__.py deleted file mode 100644 index a88f2db9d0d..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from .__cmd_group import * -from ._get_error_detail import * -from ._list import * -from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_get_error_detail.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_get_error_detail.py deleted file mode 100644 index 123799c73be..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_get_error_detail.py +++ /dev/null @@ -1,209 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "devcenter admin catalog-task get-error-detail", -) -class GetErrorDetail(AAZCommand): - """Gets customization task error details. - - :example: Get error detail - az devcenter admin catalog-task get-error-detail --catalog-name "CentralCatalog" --task-name "SampleTask" --dev-center-name "Contoso" --resource-group "rg1" - """ - - _aaz_info = { - "version": "2023-10-01-preview", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devcenter/devcenters/{}/catalogs/{}/tasks/{}/geterrordetails", "2023-10-01-preview"], - ] - } - - def _handler(self, command_args): - super()._handler(command_args) - self._execute_operations() - return self._output() - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.catalog_name = AAZStrArg( - options=["--catalog-name"], - help="The name of the catalog.", - required=True, - id_part="child_name_1", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.dev_center_name = AAZStrArg( - options=["-d", "--dev-center", "--dev-center-name"], - help="The name of the dev center.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-]{2,25}$", - max_length=26, - min_length=3, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.task_name = AAZStrArg( - options=["-n", "--name", "--task-name"], - help="The name of the task.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.CustomizationTasksGetErrorDetails(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) - return result - - class CustomizationTasksGetErrorDetails(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200]: - return self.on_200(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/tasks/{taskName}/getErrorDetails", - **self.url_parameters - ) - - @property - def method(self): - return "POST" - - @property - def error_format(self): - return "ODataV4Format" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "catalogName", self.ctx.args.catalog_name, - required=True, - ), - **self.serialize_url_param( - "devCenterName", self.ctx.args.dev_center_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - **self.serialize_url_param( - "taskName", self.ctx.args.task_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-10-01-preview", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.errors = AAZListType( - flags={"read_only": True}, - ) - - errors = cls._schema_on_200.errors - errors.Element = AAZObjectType() - - _element = cls._schema_on_200.errors.Element - _element.code = AAZStrType() - _element.message = AAZStrType() - - return cls._schema_on_200 - - -class _GetErrorDetailHelper: - """Helper class for GetErrorDetail""" - - -__all__ = ["GetErrorDetail"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_list.py deleted file mode 100644 index a8fa4cd5adb..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_list.py +++ /dev/null @@ -1,257 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "devcenter admin catalog-task list", -) -class List(AAZCommand): - """List tasks in the catalog. - - :example: List - az devcenter admin catalog-task list --catalog-name "CentralCatalog" --dev-center-name "Contoso" --resource-group "rg1" - """ - - _aaz_info = { - "version": "2023-10-01-preview", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devcenter/devcenters/{}/catalogs/{}/tasks", "2023-10-01-preview"], - ] - } - - AZ_SUPPORT_PAGINATION = True - - def _handler(self, command_args): - super()._handler(command_args) - return self.build_paging(self._execute_operations, self._output) - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.catalog_name = AAZStrArg( - options=["--catalog-name"], - help="The name of the catalog.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.dev_center_name = AAZStrArg( - options=["-d", "--dev-center", "--dev-center-name"], - help="The name of the dev center.", - required=True, - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-]{2,25}$", - max_length=26, - min_length=3, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.CustomizationTasksListByCatalog(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) - next_link = self.deserialize_output(self.ctx.vars.instance.next_link) - return result, next_link - - class CustomizationTasksListByCatalog(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200]: - return self.on_200(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/tasks", - **self.url_parameters - ) - - @property - def method(self): - return "GET" - - @property - def error_format(self): - return "ODataV4Format" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "catalogName", self.ctx.args.catalog_name, - required=True, - ), - **self.serialize_url_param( - "devCenterName", self.ctx.args.dev_center_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-10-01-preview", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.next_link = AAZStrType( - serialized_name="nextLink", - flags={"read_only": True}, - ) - _schema_on_200.value = AAZListType( - flags={"read_only": True}, - ) - - value = cls._schema_on_200.value - value.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element - _element.id = AAZStrType( - flags={"read_only": True}, - ) - _element.name = AAZStrType( - flags={"read_only": True}, - ) - _element.properties = AAZObjectType( - flags={"client_flatten": True}, - ) - _element.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.value.Element.properties - properties.inputs = AAZDictType( - flags={"read_only": True}, - ) - properties.timeout = AAZIntType( - flags={"read_only": True}, - ) - properties.validation_status = AAZStrType( - serialized_name="validationStatus", - ) - - inputs = cls._schema_on_200.value.Element.properties.inputs - inputs.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element.properties.inputs.Element - _element.description = AAZStrType( - flags={"read_only": True}, - ) - _element.required = AAZBoolType( - flags={"read_only": True}, - ) - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - system_data = cls._schema_on_200.value.Element.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by = AAZStrType( - serialized_name="createdBy", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - return cls._schema_on_200 - - -class _ListHelper: - """Helper class for List""" - - -__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_show.py deleted file mode 100644 index 4d8bade9221..00000000000 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/catalog_task/_show.py +++ /dev/null @@ -1,260 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -# Code generated by aaz-dev-tools -# -------------------------------------------------------------------------------------------- - -# pylint: skip-file -# flake8: noqa - -from azure.cli.core.aaz import * - - -@register_command( - "devcenter admin catalog-task show", -) -class Show(AAZCommand): - """Get a task from the catalog. - - :example: Get - az devcenter admin catalog-task show --catalog-name "CentralCatalog" --task-name "SampleTask" --dev-center-name "Contoso" --resource-group "rg1" - """ - - _aaz_info = { - "version": "2023-10-01-preview", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.devcenter/devcenters/{}/catalogs/{}/tasks/{}", "2023-10-01-preview"], - ] - } - - def _handler(self, command_args): - super()._handler(command_args) - self._execute_operations() - return self._output() - - _args_schema = None - - @classmethod - def _build_arguments_schema(cls, *args, **kwargs): - if cls._args_schema is not None: - return cls._args_schema - cls._args_schema = super()._build_arguments_schema(*args, **kwargs) - - # define Arg Group "" - - _args_schema = cls._args_schema - _args_schema.catalog_name = AAZStrArg( - options=["--catalog-name"], - help="The name of the catalog.", - required=True, - id_part="child_name_1", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - _args_schema.dev_center_name = AAZStrArg( - options=["-d", "--dev-center", "--dev-center-name"], - help="The name of the dev center.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-]{2,25}$", - max_length=26, - min_length=3, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.task_name = AAZStrArg( - options=["-n", "--name", "--task-name"], - help="The name of the task.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - max_length=63, - min_length=3, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.CustomizationTasksGet(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) - return result - - class CustomizationTasksGet(AAZHttpOperation): - CLIENT_TYPE = "MgmtClient" - - def __call__(self, *args, **kwargs): - request = self.make_request() - session = self.client.send_request(request=request, stream=False, **kwargs) - if session.http_response.status_code in [200]: - return self.on_200(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/tasks/{taskName}", - **self.url_parameters - ) - - @property - def method(self): - return "GET" - - @property - def error_format(self): - return "ODataV4Format" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "catalogName", self.ctx.args.catalog_name, - required=True, - ), - **self.serialize_url_param( - "devCenterName", self.ctx.args.dev_center_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - **self.serialize_url_param( - "taskName", self.ctx.args.task_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-10-01-preview", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - - _schema_on_200 = cls._schema_on_200 - _schema_on_200.id = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.name = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, - ) - _schema_on_200.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _schema_on_200.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.properties - properties.inputs = AAZDictType( - flags={"read_only": True}, - ) - properties.timeout = AAZIntType( - flags={"read_only": True}, - ) - properties.validation_status = AAZStrType( - serialized_name="validationStatus", - ) - - inputs = cls._schema_on_200.properties.inputs - inputs.Element = AAZObjectType() - - _element = cls._schema_on_200.properties.inputs.Element - _element.description = AAZStrType( - flags={"read_only": True}, - ) - _element.required = AAZBoolType( - flags={"read_only": True}, - ) - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - system_data = cls._schema_on_200.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by = AAZStrType( - serialized_name="createdBy", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - return cls._schema_on_200 - - -class _ShowHelper: - """Helper class for Show""" - - -__all__ = ["Show"] From 7c2d5d4baefdf326148531d03bd09a2c62ff1c4f Mon Sep 17 00:00:00 2001 From: Amanda Lim Date: Fri, 3 Nov 2023 02:35:07 -0700 Subject: [PATCH 2/3] Update data plane CLI to 2023-10-01-preview --- .../azext_devcenter/_client_factory.py | 8 +- src/devcenter/azext_devcenter/_params.py | 294 + src/devcenter/azext_devcenter/commands.py | 9 + src/devcenter/azext_devcenter/custom.py | 136 +- .../devcenter_dataplane/_client.py | 46 +- .../devcenter_dataplane/_configuration.py | 11 +- .../devcenter_dataplane/_serialization.py | 49 +- .../devcenter_dataplane/_version.py | 2 +- .../devcenter_dataplane/aio/_client.py | 49 +- .../devcenter_dataplane/aio/_configuration.py | 11 +- .../aio/operations/__init__.py | 8 +- .../aio/operations/_operations.py | 4949 +++++-- .../operations/__init__.py | 8 +- .../operations/_operations.py | 11057 ++++++++++------ 14 files changed, 10976 insertions(+), 5661 deletions(-) diff --git a/src/devcenter/azext_devcenter/_client_factory.py b/src/devcenter/azext_devcenter/_client_factory.py index 73ceb1c149a..06ec9abead7 100644 --- a/src/devcenter/azext_devcenter/_client_factory.py +++ b/src/devcenter/azext_devcenter/_client_factory.py @@ -40,16 +40,16 @@ def cf_dev_boxes_dp(cli_ctx, dev_center, *_): return cf_devcenter_dataplane(cli_ctx, dev_center).dev_boxes -def cf_dev_box_operations_dp(cli_ctx, dev_center, *_): - return cf_devcenter_dataplane(cli_ctx, dev_center).dev_box_operations +def cf_project_operations_dp(cli_ctx, dev_center, *_): + return cf_devcenter_dataplane(cli_ctx, dev_center).projects def cf_environments_dp(cli_ctx, dev_center, *_): return cf_devcenter_dataplane(cli_ctx, dev_center).environments -def cf_environment_operations_dp(cli_ctx, dev_center, *_): - return cf_devcenter_dataplane(cli_ctx, dev_center).environment_operations +def cf_deployment_environment_operations_dp(cli_ctx, dev_center, *_): + return cf_devcenter_dataplane(cli_ctx, dev_center).deployment_environments # Control plane diff --git a/src/devcenter/azext_devcenter/_params.py b/src/devcenter/azext_devcenter/_params.py index 669e36e7b6b..807ec9ff3af 100644 --- a/src/devcenter/azext_devcenter/_params.py +++ b/src/devcenter/azext_devcenter/_params.py @@ -679,6 +679,12 @@ def load_arguments(self, _): type=str, help="Name of the environment definition.", ) + c.argument( + "expiration_date", + options_list=["--expiration_date", "--expiration"], + type=str, + help="The date of environment expiration. Must be an ISO string", + ) with self.argument_context("devcenter dev environment update") as c: c.argument( @@ -711,6 +717,12 @@ def load_arguments(self, _): help="Parameters object for the environment. Expected " "value: json-string/json-file/@json-file.", ) + c.argument( + "expiration_date", + options_list=["--expiration_date", "--expiration"], + type=str, + help="The date of environment expiration. Must be an ISO string", + ) with self.argument_context("devcenter dev environment deploy") as c: c.argument( @@ -743,6 +755,12 @@ def load_arguments(self, _): help="Parameters object for the environment. Expected " "value: json-string/json-file/@json-file.", ) + c.argument( + "expiration_date", + options_list=["--expiration_date", "--expiration"], + type=str, + help="The date of environment expiration. Must be an ISO string", + ) with self.argument_context("devcenter dev environment delete") as c: c.argument( @@ -855,3 +873,279 @@ def load_arguments(self, _): "endpoint", arg_type=endpoint, ) + + with self.argument_context("devcenter dev environment list-operation") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + + with self.argument_context("devcenter dev environment show-operation") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + c.argument( + "operation_id", + options_list=["--operation-id", "-o"], + type=str, + help="The ID " "of the operation.", + ) + + with self.argument_context("devcenter dev environment show-logs-by-operation") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + c.argument( + "operation_id", + options_list=["--operation-id", "-o"], + type=str, + help="The ID " "of the operation.", + ) + + with self.argument_context("devcenter dev environment show-action") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + c.argument( + "action_name", + options_list=["--action-name"], + type=str, + help="The name of an action that will take place on an environment.", + ) + + with self.argument_context("devcenter dev environment skip-action") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + c.argument( + "action_name", + options_list=["--action-name"], + type=str, + help="The name of an action that will take place on an environment.", + ) + + with self.argument_context("devcenter dev environment list-action") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + + with self.argument_context("devcenter dev environment delay-action") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + c.argument( + "action_name", + options_list=["--action-name"], + type=str, + help="The name of an action that will take place on an environment.", + ) + c.argument( + "until", + options_list=["--until"], + type=str, + help="The time to delay the environment action until. Must be an ISO string", + ) + + with self.argument_context("devcenter dev environment show-outputs") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + + with self.argument_context("devcenter dev environment update-environment-expiration-date") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "project_name", + arg_type=project_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "user_id", + type=str, + help="The AAD object id of the user. If value is 'me', the identity is taken from the " + "authentication context", + ) + c.argument( + "environment_name", + options_list=["--name", "-n", "--environment-name"], + type=str, + help="The name " "of the environment.", + ) + c.argument( + "expiration_date", + options_list=["--expiration_date", "--expiration"], + type=str, + help="The date of environment expiration. Must be an ISO string", + ) diff --git a/src/devcenter/azext_devcenter/commands.py b/src/devcenter/azext_devcenter/commands.py index 31a5640025c..d8d7accfcc7 100644 --- a/src/devcenter/azext_devcenter/commands.py +++ b/src/devcenter/azext_devcenter/commands.py @@ -272,6 +272,15 @@ def load_command_table(self, _): supports_no_wait=True, confirmation=True, ) + g.custom_command("list-operation", "devcenter_environment_operation_list") + g.custom_command("show-operation", "devcenter_environment_operation_show") + g.custom_command("show-logs-by-operation", "devcenter_environment_operation_show_logs_by_operation") + g.custom_command("show-action", "devcenter_environment_operation_show_action") + g.custom_command("list-action", "devcenter_environment_operation_list_action") + g.custom_command("delay-action", "devcenter_environment_operation_delay_action") + g.custom_command("skip-action", "devcenter_environment_operation_skip_action") + g.custom_command("show-outputs", "devcenter_environment_operation_show_outputs") + g.custom_command("update-environment-expiration-date", "devcenter_environment_operation_update_environment") with self.command_group("devcenter dev catalog", environments_dp) as g: g.custom_command("list", "devcenter_catalog_list_dp") diff --git a/src/devcenter/azext_devcenter/custom.py b/src/devcenter/azext_devcenter/custom.py index 6594b14925c..82a20c50cae 100644 --- a/src/devcenter/azext_devcenter/custom.py +++ b/src/devcenter/azext_devcenter/custom.py @@ -623,7 +623,7 @@ def devcenter_schedule_list_dp( ) if pool_name is None: return cf_dataplane.dev_boxes.list_schedules_by_project(project_name=project_name) - return cf_dataplane.dev_boxes.list_schedules_by_pool(project_name=project_name, pool_name=pool_name) + return cf_dataplane.dev_boxes.list_schedules(project_name=project_name, pool_name=pool_name) def devcenter_schedule_show_dp( @@ -632,7 +632,7 @@ def devcenter_schedule_show_dp( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.dev_boxes.get_schedule_by_pool( + return cf_dataplane.dev_boxes.get_schedule( project_name=project_name, pool_name=pool_name, schedule_name="default") @@ -645,10 +645,10 @@ def devcenter_dev_box_list( cmd.cli_ctx, endpoint, dev_center, project_name ) if project_name is not None and user_id is not None: - return cf_dataplane.dev_boxes.list_dev_boxes_by_user(project_name=project_name, user_id=user_id) + return cf_dataplane.dev_boxes.list_dev_boxes(project_name=project_name, user_id=user_id) if user_id is not None: - return cf_dataplane.dev_center.list_all_dev_boxes_by_user(user_id=user_id) - return cf_dataplane.dev_center.list_all_dev_boxes() + return cf_dataplane.dev_boxes.list_all_dev_boxes_by_user(user_id=user_id) + return cf_dataplane.dev_boxes.list_all_dev_boxes() def devcenter_dev_box_show( @@ -657,7 +657,7 @@ def devcenter_dev_box_show( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.dev_boxes.get_dev_box_by_user( + return cf_dataplane.dev_boxes.get_dev_box( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name) @@ -912,7 +912,7 @@ def devcenter_dev_box_delay_all_actions( delayed_time = get_delayed_time(delay_time, earliest_time) - return cf_dataplane.dev_boxes.delay_actions( + return cf_dataplane.dev_boxes.delay_all_actions( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -926,7 +926,7 @@ def devcenter_dev_box_list_operation( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.dev_box_operations.list(project_name=project_name, user_id=user_id, dev_box_name=dev_box_name) + return cf_dataplane.dev_boxes.list_operations(project_name=project_name, user_id=user_id, dev_box_name=dev_box_name) def devcenter_dev_box_show_operation( @@ -941,7 +941,7 @@ def devcenter_dev_box_show_operation( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.dev_box_operations.get( + return cf_dataplane.dev_boxes.get_operation( project_name=project_name, user_id=user_id, dev_box_name=dev_box_name, @@ -957,8 +957,8 @@ def devcenter_environment_list( ) if user_id is not None: - return cf_dataplane.environments.list_environments_by_user(project_name=project_name, user_id=user_id) - return cf_dataplane.environments.list_environments(project_name=project_name) + return cf_dataplane.deployment_environments.list_all_environments(project_name=project_name, user_id=user_id) + return cf_dataplane.deployment_environments.list_environments(project_name=project_name) def devcenter_environment_show( @@ -968,11 +968,10 @@ def devcenter_environment_show( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environments.get_environment_by_user( + return cf_dataplane.deployment_environments.get_environment( project_name=project_name, user_id=user_id, environment_name=environment_name ) - def devcenter_environment_create( cmd, environment_name, @@ -980,6 +979,7 @@ def devcenter_environment_create( project_name, catalog_name, environment_definition_name, + expiration_date=None, parameters=None, no_wait=False, user_id="me", @@ -989,7 +989,7 @@ def devcenter_environment_create( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - environments_iterator = cf_dataplane.environments.list_environments_by_user( + environments_iterator = cf_dataplane.deployment_environments.list_environments( project_name=project_name, user_id=user_id ) validate_env_name_already_exists( @@ -1001,9 +1001,10 @@ def devcenter_environment_create( body["environmentType"] = environment_type body["catalogName"] = catalog_name body["environmentDefinitionName"] = environment_definition_name + body["expirationDate"] = datetime.strptime(expiration_date, "%Y-%m-%dT%H:%M:%S.%fZ") return sdk_no_wait( no_wait, - cf_dataplane.environments.begin_create_or_replace_environment, + cf_dataplane.deployment_environments.begin_create_or_update_environment, project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -1020,11 +1021,12 @@ def devcenter_environment_update( user_id="me", dev_center=None, endpoint=None, + expiration_date=None ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - environment = cf_dataplane.environments.get_environment_by_user( + environment = cf_dataplane.deployment_environments.get_environment( project_name=project_name, user_id=user_id, environment_name=environment_name ) body = {} @@ -1033,9 +1035,10 @@ def devcenter_environment_update( body["environmentType"] = environment["environmentType"] body["catalogName"] = environment["catalogName"] body["environmentDefinitionName"] = environment["environmentDefinitionName"] + body["expirationDate"] = datetime.strptime(expiration_date, "%Y-%m-%dT%H:%M:%S.%fZ") return sdk_no_wait( no_wait, - cf_dataplane.environments.begin_create_or_replace_environment, + cf_dataplane.deployment_environments.begin_create_or_update_environment, project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -1057,7 +1060,7 @@ def devcenter_environment_delete( ) return sdk_no_wait( no_wait, - cf_dataplane.environments.begin_delete_environment, + cf_dataplane.deployment_environments.begin_delete_environment, project_name=project_name, user_id=user_id, environment_name=environment_name, @@ -1068,7 +1071,7 @@ def devcenter_catalog_list_dp(cmd, project_name, dev_center=None, endpoint=None) cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environments.list_catalogs_by_project(project_name=project_name) + return cf_dataplane.deployment_environments.list_catalogs(project_name=project_name) def devcenter_catalog_show_dp( @@ -1077,7 +1080,7 @@ def devcenter_catalog_show_dp( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environments.get_catalog(project_name=project_name, catalog_name=catalog_name) + return cf_dataplane.deployment_environments.get_catalog(project_name=project_name, catalog_name=catalog_name) def devcenter_environment_definition_list_dp( @@ -1087,10 +1090,10 @@ def devcenter_environment_definition_list_dp( cmd.cli_ctx, endpoint, dev_center, project_name ) if catalog_name is not None: - return cf_dataplane.environments.list_environment_definitions_by_catalog( + return cf_dataplane.deployment_environments.list_environment_definitions_by_catalog( project_name=project_name, catalog_name=catalog_name ) - return cf_dataplane.environments.list_environment_definitions_by_project(project_name=project_name) + return cf_dataplane.deployment_environments.list_environment_definitions(project_name=project_name) def devcenter_environment_definition_show_dp( @@ -1099,7 +1102,7 @@ def devcenter_environment_definition_show_dp( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environments.get_environment_definition( + return cf_dataplane.deployment_environments.get_environment_definition( project_name=project_name, catalog_name=catalog_name, definition_name=definition_name ) @@ -1110,7 +1113,7 @@ def devcenter_environment_type_list_dp( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environments.list_environment_types(project_name=project_name) + return cf_dataplane.deployment_environments.list_environment_types(project_name=project_name) def devcenter_environment_operation_list( @@ -1120,7 +1123,7 @@ def devcenter_environment_operation_list( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environment_operations.list_by_environment(project_name=project_name, + return cf_dataplane.environments.list_operations(project_name=project_name, environment_name=environment_name, user_id=user_id) @@ -1131,6 +1134,87 @@ def devcenter_environment_operation_show( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environment_operations.get_by_environment( + return cf_dataplane.environments.get_operation( project_name=project_name, operation_id=operation_id, user_id=user_id, environment_name=environment_name ) + +def devcenter_environment_operation_show_logs_by_operation( + cmd, project_name, environment_name, operation_id, user_id="me", dev_center=None, endpoint=None +): + cf_dataplane = cf_devcenter_dataplane( + cmd.cli_ctx, endpoint, dev_center, project_name + ) + + return cf_dataplane.environments.get_logs_by_operation( + project_name=project_name, operation_id=operation_id, user_id=user_id, environment_name=environment_name + ) + +def devcenter_environment_operation_show_action( + cmd, project_name, environment_name, action_name, user_id="me", dev_center=None, endpoint=None +): + cf_dataplane = cf_devcenter_dataplane( + cmd.cli_ctx, endpoint, dev_center, project_name + ) + + return cf_dataplane.environments.get_action( + project_name=project_name, user_id=user_id, action_name=action_name, environment_name=environment_name + ) + +def devcenter_environment_operation_list_action( + cmd, project_name, environment_name, user_id="me", dev_center=None, endpoint=None +): + cf_dataplane = cf_devcenter_dataplane( + cmd.cli_ctx, endpoint, dev_center, project_name + ) + + return cf_dataplane.environments.list_actions( + project_name=project_name, user_id=user_id, environment_name=environment_name + ) + +def devcenter_environment_operation_delay_action( + cmd, project_name, environment_name, action_name, until, user_id="me", dev_center=None, endpoint=None +): + cf_dataplane = cf_devcenter_dataplane( + cmd.cli_ctx, endpoint, dev_center, project_name + ) + + return cf_dataplane.environments.delay_action( + project_name=project_name, action_name=action_name, user_id=user_id, until=until, environment_name=environment_name + ) + +def devcenter_environment_operation_skip_action( + cmd, project_name, environment_name, action_name, user_id="me", dev_center=None, endpoint=None +): + cf_dataplane = cf_devcenter_dataplane( + cmd.cli_ctx, endpoint, dev_center, project_name + ) + + return cf_dataplane.environments.skip_action( + project_name=project_name, action_name=action_name, user_id=user_id, environment_name=environment_name + ) + + +def devcenter_environment_operation_show_outputs( + cmd, project_name, environment_name, user_id="me", dev_center=None, endpoint=None +): + cf_dataplane = cf_devcenter_dataplane( + cmd.cli_ctx, endpoint, dev_center, project_name + ) + + return cf_dataplane.environments.get_outputs( + project_name=project_name, user_id=user_id, environment_name=environment_name + ) + +def devcenter_environment_operation_update_environment( + cmd, project_name, environment_name, user_id="me", dev_center=None, endpoint=None, expiration_date=None, +): + cf_dataplane = cf_devcenter_dataplane( + cmd.cli_ctx, endpoint, dev_center, project_name + ) + body={} + body["expirationDate"] = datetime.strptime(expiration_date, "%Y-%m-%dT%H:%M:%S.%fZ") + + return cf_dataplane.environments.patch_environment( + project_name=project_name, user_id=user_id, environment_name=environment_name, body=body + ) + diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py index 6b8a49e6cf2..3c13bbd4a52 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py @@ -10,16 +10,17 @@ from typing import Any, TYPE_CHECKING from azure.core import PipelineClient +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from ._configuration import DevCenterClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( - DevBoxOperationsOperations, + DeploymentEnvironmentsOperations, DevBoxesOperations, DevCenterOperations, - EnvironmentOperationsOperations, EnvironmentsOperations, + ProjectsOperations, ) if TYPE_CHECKING: @@ -34,18 +35,18 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword :vartype dev_center: azure.developer.devcenter.operations.DevCenterOperations :ivar dev_boxes: DevBoxesOperations operations :vartype dev_boxes: azure.developer.devcenter.operations.DevBoxesOperations - :ivar dev_box_operations: DevBoxOperationsOperations operations - :vartype dev_box_operations: azure.developer.devcenter.operations.DevBoxOperationsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.developer.devcenter.operations.ProjectsOperations + :ivar deployment_environments: DeploymentEnvironmentsOperations operations + :vartype deployment_environments: + azure.developer.devcenter.operations.DeploymentEnvironmentsOperations :ivar environments: EnvironmentsOperations operations :vartype environments: azure.developer.devcenter.operations.EnvironmentsOperations - :ivar environment_operations: EnvironmentOperationsOperations operations - :vartype environment_operations: - azure.developer.devcenter.operations.EnvironmentOperationsOperations :param endpoint: The DevCenter-specific URI to operate on. Required. :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-10-01-preview". 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 @@ -55,22 +56,37 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: _endpoint = "{endpoint}" self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) - self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **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 self.dev_center = DevCenterOperations(self._client, self._config, self._serialize, self._deserialize) self.dev_boxes = DevBoxesOperations(self._client, self._config, self._serialize, self._deserialize) - self.dev_box_operations = DevBoxOperationsOperations( + self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_environments = DeploymentEnvironmentsOperations( self._client, self._config, self._serialize, self._deserialize ) self.environments = EnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.environment_operations = EnvironmentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + 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 @@ -94,7 +110,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py index 4ebc891e132..ad2614568f0 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from ._version import VERSION @@ -18,7 +17,7 @@ from azure.core.credentials import TokenCredential -class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DevCenterClient. Note that all parameters used to create this instance are saved as instance @@ -28,14 +27,13 @@ class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-i :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-10-01-preview". 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: - super(DevCenterClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-07-01-preview") + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -47,6 +45,7 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) 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: @@ -55,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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( diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py index 4bae2292227..1247eb71a98 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py @@ -63,7 +63,7 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,7 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -295,7 +295,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +340,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +351,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +390,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +415,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +445,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -668,7 +668,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +710,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +730,8 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + # https://github.com/Azure/autorest.python/issues/2063 + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -753,7 +755,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -824,7 +826,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -1170,10 +1172,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1481,7 +1483,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1652,7 +1654,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1808,7 +1810,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1865,7 +1866,7 @@ def deserialize_decimal(attr): return decimal.Decimal(attr) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1894,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1911,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1946,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1983,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -2001,6 +2002,6 @@ def deserialize_unix(attr): date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_version.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_version.py index 20971492f12..c47f66669f1 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_version.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b3" +VERSION = "1.0.0" diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py index 4f5b3b82c0d..fa779eb7b9b 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py @@ -10,16 +10,17 @@ from typing import Any, Awaitable, TYPE_CHECKING 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 ( - DevBoxOperationsOperations, + DeploymentEnvironmentsOperations, DevBoxesOperations, DevCenterOperations, - EnvironmentOperationsOperations, EnvironmentsOperations, + ProjectsOperations, ) if TYPE_CHECKING: @@ -34,19 +35,18 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword :vartype dev_center: azure.developer.devcenter.aio.operations.DevCenterOperations :ivar dev_boxes: DevBoxesOperations operations :vartype dev_boxes: azure.developer.devcenter.aio.operations.DevBoxesOperations - :ivar dev_box_operations: DevBoxOperationsOperations operations - :vartype dev_box_operations: - azure.developer.devcenter.aio.operations.DevBoxOperationsOperations + :ivar projects: ProjectsOperations operations + :vartype projects: azure.developer.devcenter.aio.operations.ProjectsOperations + :ivar deployment_environments: DeploymentEnvironmentsOperations operations + :vartype deployment_environments: + azure.developer.devcenter.aio.operations.DeploymentEnvironmentsOperations :ivar environments: EnvironmentsOperations operations :vartype environments: azure.developer.devcenter.aio.operations.EnvironmentsOperations - :ivar environment_operations: EnvironmentOperationsOperations operations - :vartype environment_operations: - azure.developer.devcenter.aio.operations.EnvironmentOperationsOperations :param endpoint: The DevCenter-specific URI to operate on. Required. :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-10-01-preview". 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 @@ -56,22 +56,39 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: _endpoint = "{endpoint}" self._config = DevCenterClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) - self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, config=self._config, **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 self.dev_center = DevCenterOperations(self._client, self._config, self._serialize, self._deserialize) self.dev_boxes = DevBoxesOperations(self._client, self._config, self._serialize, self._deserialize) - self.dev_box_operations = DevBoxOperationsOperations( + self.projects = ProjectsOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_environments = DeploymentEnvironmentsOperations( self._client, self._config, self._serialize, self._deserialize ) self.environments = EnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.environment_operations = EnvironmentOperationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + 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 @@ -95,7 +112,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHt } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py index a6f4e21463d..25673cef107 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from .._version import VERSION @@ -18,7 +17,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for DevCenterClient. Note that all parameters used to create this instance are saved as instance @@ -28,14 +27,13 @@ class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-i :type endpoint: str :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: Api Version. Default value is "2023-07-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-10-01-preview". 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: - super(DevCenterClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-07-01-preview") + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -47,6 +45,7 @@ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: 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: @@ -55,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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( diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/__init__.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/__init__.py index 7a867adbbb5..484f557dc65 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/__init__.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/__init__.py @@ -8,9 +8,9 @@ from ._operations import DevCenterOperations from ._operations import DevBoxesOperations -from ._operations import DevBoxOperationsOperations +from ._operations import ProjectsOperations +from ._operations import DeploymentEnvironmentsOperations from ._operations import EnvironmentsOperations -from ._operations import EnvironmentOperationsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -19,9 +19,9 @@ __all__ = [ "DevCenterOperations", "DevBoxesOperations", - "DevBoxOperationsOperations", + "ProjectsOperations", + "DeploymentEnvironmentsOperations", "EnvironmentsOperations", - "EnvironmentOperationsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py index 343645a3203..5817167d654 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py @@ -9,7 +9,7 @@ import datetime from io import IOBase import sys -from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -30,45 +30,58 @@ from azure.core.utils import case_insensitive_dict from ...operations._operations import ( - build_dev_box_operations_get_request, - build_dev_box_operations_list_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_customization_group_request, build_dev_boxes_create_dev_box_request, build_dev_boxes_delay_action_request, - build_dev_boxes_delay_actions_request, + build_dev_boxes_delay_all_actions_request, build_dev_boxes_delete_dev_box_request, build_dev_boxes_get_action_request, - build_dev_boxes_get_dev_box_by_user_request, + build_dev_boxes_get_customization_group_request, + build_dev_boxes_get_customization_task_log_request, + build_dev_boxes_get_dev_box_request, + build_dev_boxes_get_operation_request, build_dev_boxes_get_pool_request, build_dev_boxes_get_remote_connection_request, - build_dev_boxes_get_schedule_by_pool_request, + build_dev_boxes_get_schedule_request, build_dev_boxes_list_actions_request, - build_dev_boxes_list_dev_boxes_by_user_request, + build_dev_boxes_list_all_dev_boxes_by_user_request, + build_dev_boxes_list_all_dev_boxes_request, + build_dev_boxes_list_customization_groups_request, + build_dev_boxes_list_dev_boxes_request, + build_dev_boxes_list_operations_request, build_dev_boxes_list_pools_request, - build_dev_boxes_list_schedules_by_pool_request, build_dev_boxes_list_schedules_by_project_request, + build_dev_boxes_list_schedules_request, build_dev_boxes_repair_dev_box_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_list_all_dev_boxes_by_user_request, - build_dev_center_list_all_dev_boxes_request, build_dev_center_list_projects_request, - build_environment_operations_get_by_environment_request, - build_environment_operations_get_logs_request, - build_environment_operations_list_by_environment_request, - build_environments_create_or_replace_environment_request, - build_environments_delete_environment_request, - build_environments_get_catalog_request, - build_environments_get_environment_by_user_request, - build_environments_get_environment_definition_request, - build_environments_list_catalogs_by_project_request, - build_environments_list_environment_definitions_by_catalog_request, - build_environments_list_environment_definitions_by_project_request, - build_environments_list_environment_types_request, - build_environments_list_environments_by_user_request, - build_environments_list_environments_request, + build_environments_delay_action_request, + build_environments_get_action_request, + build_environments_get_logs_by_operation_request, + build_environments_get_operation_request, + build_environments_get_outputs_request, + build_environments_list_actions_request, + build_environments_list_operations_request, + build_environments_patch_environment_request, + build_environments_skip_action_request, + build_projects_get_customization_task_definition_request, + build_projects_list_customization_task_definitions_request, + build_projects_validate_customization_tasks_request, ) if sys.version_info >= (3, 9): @@ -120,6 +133,7 @@ def list_projects( "name": "str", # Name of the project. Required. "uri": "str", # The unique URI of the project. Required. "description": "str", # Optional. Description of the project. + "displayName": "str", # Optional. Display name 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. } @@ -140,7 +154,7 @@ def list_projects( def prepare_request(next_link=None): if not next_link: - request = build_dev_center_list_projects_request( + _request = build_dev_center_list_projects_request( filter=filter, top=top, api_version=self._config.api_version, @@ -152,7 +166,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -164,7 +178,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -172,9 +186,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -184,11 +198,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,6 +234,7 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: "name": "str", # Name of the project. Required. "uri": "str", # The unique URI of the project. Required. "description": "str", # Optional. Description of the project. + "displayName": "str", # Optional. Display name 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. } @@ -237,7 +252,7 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_center_get_project_request( + _request = build_dev_center_get_project_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -246,11 +261,11 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -267,21 +282,41 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + +class DevBoxesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.aio.DevCenterClient`'s + :attr:`dev_boxes` attribute. + """ - return cast(JSON, deserialized) + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_all_dev_boxes( - self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + def list_pools( + self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists Dev Boxes that the caller has access to in the DevCenter. + """Lists available pools. - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: @@ -291,23 +326,14 @@ def list_all_dev_boxes( # response body for status code(s): 200 response == { - "poolName": "str", # The name of the Dev Box pool this machine belongs to. + "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. - "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", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, + "name": "str", # Pool name. Required. + "uri": "str", # The unique URI of the pool. Required. + "displayName": "str", # Optional. Display name of the pool. "hardwareProfile": { "memoryGB": 0, # Optional. The amount of memory available for the Dev Box. @@ -328,31 +354,24 @@ def list_all_dev_boxes( 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. - "name": "str", # Optional. Display name for the Dev Box. - "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. + "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. } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + } } """ _headers = kwargs.pop("headers", {}) or {} @@ -371,9 +390,10 @@ def list_all_dev_boxes( def prepare_request(next_link=None): if not next_link: - request = build_dev_center_list_all_dev_boxes_request( - filter=filter, + _request = build_dev_boxes_list_pools_request( + project_name=project_name, top=top, + filter=filter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -383,7 +403,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -395,7 +415,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -403,9 +423,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -415,11 +435,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -433,22 +453,16 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list_all_dev_boxes_by_user( - self, user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[JSON]: - """Lists Dev Boxes in the Dev Center for a particular user. + @distributed_trace_async + async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: + """Gets a pool. - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param pool_name: The name of a pool of Dev Boxes. Required. + :type pool_name: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -456,23 +470,14 @@ def list_all_dev_boxes_by_user( # response body for status code(s): 200 response == { - "poolName": "str", # The name of the Dev Box pool this machine belongs to. + "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. - "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", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, + "name": "str", # Pool name. Required. + "uri": "str", # The unique URI of the pool. Required. + "displayName": "str", # Optional. Display name of the pool. "hardwareProfile": { "memoryGB": 0, # Optional. The amount of memory available for the Dev Box. @@ -493,31 +498,110 @@ def list_all_dev_boxes_by_user( 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. - "name": "str", # Optional. Display name for the Dev Box. - "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. + "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. } - }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + } + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_pool_request( + project_name=project_name, + pool_name=pool_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def list_schedules_by_project( + self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable[JSON]: + """Lists all schedules within a project that are configured by your project administrator. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] + :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. + "sourceType": "str", # The type of the resource that this schedule belongs + to. Required. "Pool" + "sourceUri": "str", # The URI of the resource that this schedule belongs to. + 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" + "uri": "str" # The unique URI of the schedule. Required. } """ _headers = kwargs.pop("headers", {}) or {} @@ -536,10 +620,10 @@ def list_all_dev_boxes_by_user( def prepare_request(next_link=None): if not next_link: - request = build_dev_center_list_all_dev_boxes_by_user_request( - user_id=user_id, - filter=filter, + _request = build_dev_boxes_list_schedules_by_project_request( + project_name=project_name, top=top, + filter=filter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -549,7 +633,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -561,7 +645,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -569,9 +653,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -581,11 +665,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -599,32 +683,22 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - -class DevBoxesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.aio.DevCenterClient`'s - :attr:`dev_boxes` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_pools( - self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + def list_schedules( + self, + project_name: str, + pool_name: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists available pools. + """Lists all schedules within a pool that are configured by your project administrator. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str + :param pool_name: The name of a pool of Dev Boxes. Required. + :type pool_name: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int @@ -639,51 +713,20 @@ def list_pools( # 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. + "frequency": "str", # The frequency of this scheduled task. Required. + "Daily" + "name": "str", # Display name for the Schedule. Required. + "sourceType": "str", # The type of the resource that this schedule belongs + to. Required. "Pool" + "sourceUri": "str", # The URI of the resource that this schedule belongs to. Required. - "name": "str", # Pool name. Required. - "uri": "str", # The unique URI of the pool. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - } - } + "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" + "uri": "str" # The unique URI of the schedule. Required. } """ _headers = kwargs.pop("headers", {}) or {} @@ -702,8 +745,9 @@ def list_pools( def prepare_request(next_link=None): if not next_link: - request = build_dev_boxes_list_pools_request( + _request = build_dev_boxes_list_schedules_request( project_name=project_name, + pool_name=pool_name, top=top, filter=filter, api_version=self._config.api_version, @@ -715,7 +759,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -727,7 +771,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -735,9 +779,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -747,11 +791,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -766,13 +810,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: - """Gets a pool. + async def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, **kwargs: Any) -> JSON: + """Gets a schedule. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param pool_name: The name of a pool of Dev Boxes. Required. :type pool_name: str + :param schedule_name: The name of a schedule. Required. + :type schedule_name: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -782,51 +828,20 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JS # 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. + "frequency": "str", # The frequency of this scheduled task. Required. + "Daily" + "name": "str", # Display name for the Schedule. Required. + "sourceType": "str", # The type of the resource that this schedule belongs + to. Required. "Pool" + "sourceUri": "str", # The URI of the resource that this schedule belongs to. Required. - "name": "str", # Pool name. Required. - "uri": "str", # The unique URI of the pool. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - } - } + "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" + "uri": "str" # The unique URI of the schedule. Required. } """ error_map = { @@ -842,9 +857,10 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JS cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_get_pool_request( + _request = build_dev_boxes_get_schedule_request( project_name=project_name, pool_name=pool_name, + schedule_name=schedule_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -852,11 +868,11 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JS path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -873,23 +889,21 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JS deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_schedules_by_project( - self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + def list_all_dev_boxes( + self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists all schedules within a project that are configured by your project administrator. + """Lists Dev Boxes that the caller has access to in the DevCenter. - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: @@ -899,20 +913,68 @@ def list_schedules_by_project( # 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. - "sourceType": "str", # The type of the resource that this schedule belongs - to. Required. "Pool" - "sourceUri": "str", # The URI of the resource that this schedule belongs to. - Required. - "time": "str", # The target time to trigger the action. The format is HH:MM. + "poolName": "str", # The name of the Dev Box pool this machine belongs to. Required. - "timeZone": "str", # The IANA timezone id at which the schedule should - execute. Required. - "type": "str", # Supported type this scheduled task represents. Required. - "StopDevBox" - "uri": "str" # The unique URI of the schedule. 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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "user": "str" # Optional. The AAD object id of the user this Dev Box is + assigned to. } """ _headers = kwargs.pop("headers", {}) or {} @@ -931,10 +993,9 @@ def list_schedules_by_project( def prepare_request(next_link=None): if not next_link: - request = build_dev_boxes_list_schedules_by_project_request( - project_name=project_name, - top=top, + _request = build_dev_boxes_list_all_dev_boxes_request( filter=filter, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -944,7 +1005,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -956,7 +1017,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -964,9 +1025,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -976,11 +1037,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -995,26 +1056,19 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_schedules_by_pool( - self, - project_name: str, - pool_name: str, - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any + def list_all_dev_boxes_by_user( + self, user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists all schedules within a pool that are configured by your project administrator. + """Lists Dev Boxes in the Dev Center for a particular user. - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param pool_name: The name of a pool of Dev Boxes. Required. - :type pool_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: @@ -1024,20 +1078,68 @@ def list_schedules_by_pool( # 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. - "sourceType": "str", # The type of the resource that this schedule belongs - to. Required. "Pool" - "sourceUri": "str", # The URI of the resource that this schedule belongs to. - Required. - "time": "str", # The target time to trigger the action. The format is HH:MM. + "poolName": "str", # The name of the Dev Box pool this machine belongs to. Required. - "timeZone": "str", # The IANA timezone id at which the schedule should - execute. Required. - "type": "str", # Supported type this scheduled task represents. Required. - "StopDevBox" - "uri": "str" # The unique URI of the schedule. 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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "user": "str" # Optional. The AAD object id of the user this Dev Box is + assigned to. } """ _headers = kwargs.pop("headers", {}) or {} @@ -1056,11 +1158,10 @@ def list_schedules_by_pool( def prepare_request(next_link=None): if not next_link: - request = build_dev_boxes_list_schedules_by_pool_request( - project_name=project_name, - pool_name=pool_name, - top=top, + _request = build_dev_boxes_list_all_dev_boxes_by_user_request( + user_id=user_id, filter=filter, + top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -1070,7 +1171,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -1082,7 +1183,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -1090,9 +1191,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -1102,11 +1203,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1120,92 +1221,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def get_schedule_by_pool(self, project_name: str, pool_name: str, schedule_name: str, **kwargs: Any) -> JSON: - """Gets a schedule. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param pool_name: The name of a pool of Dev Boxes. Required. - :type pool_name: str - :param schedule_name: The name of a schedule. Required. - :type schedule_name: str - :return: JSON object - :rtype: JSON - :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. - "sourceType": "str", # The type of the resource that this schedule belongs - to. Required. "Pool" - "sourceUri": "str", # The URI of the resource that this schedule belongs to. - 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" - "uri": "str" # The unique URI of the schedule. Required. - } - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_dev_boxes_get_schedule_by_pool_request( - project_name=project_name, - pool_name=pool_name, - schedule_name=schedule_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - 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) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - @distributed_trace - def list_dev_boxes_by_user( + def list_dev_boxes( self, project_name: str, user_id: str = "me", @@ -1315,7 +1332,7 @@ def list_dev_boxes_by_user( def prepare_request(next_link=None): if not next_link: - request = build_dev_boxes_list_dev_boxes_by_user_request( + _request = build_dev_boxes_list_dev_boxes_request( project_name=project_name, user_id=user_id, filter=filter, @@ -1329,7 +1346,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -1341,7 +1358,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -1349,9 +1366,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -1361,11 +1378,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1380,9 +1397,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_dev_box_by_user( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> JSON: + async def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: """Gets a Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -1478,7 +1493,7 @@ async def get_dev_box_by_user( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_get_dev_box_by_user_request( + _request = build_dev_boxes_get_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -1489,11 +1504,11 @@ async def get_dev_box_by_user( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1510,9 +1525,9 @@ async def get_dev_box_by_user( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore async def _create_dev_box_initial( self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any @@ -1539,7 +1554,7 @@ async def _create_dev_box_initial( else: _json = body - request = build_dev_boxes_create_dev_box_request( + _request = build_dev_boxes_create_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -1553,11 +1568,11 @@ async def _create_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2078,13 +2093,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _delete_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2102,7 +2117,7 @@ async def _delete_dev_box_initial( cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - request = build_dev_boxes_delete_dev_box_request( + _request = build_dev_boxes_delete_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2113,11 +2128,11 @@ async def _delete_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2141,9 +2156,9 @@ async def _delete_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + return deserialized # type: ignore @distributed_trace_async async def begin_delete_dev_box( @@ -2244,13 +2259,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _start_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2268,7 +2283,7 @@ async def _start_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_start_dev_box_request( + _request = build_dev_boxes_start_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2279,11 +2294,11 @@ async def _start_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2303,9 +2318,9 @@ async def _start_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace_async async def begin_start_dev_box( @@ -2406,13 +2421,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _stop_dev_box_initial( self, @@ -2436,7 +2451,7 @@ async def _stop_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_stop_dev_box_request( + _request = build_dev_boxes_stop_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2448,11 +2463,11 @@ async def _stop_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2472,9 +2487,9 @@ async def _stop_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace_async async def begin_stop_dev_box( @@ -2584,13 +2599,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restart_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2608,7 +2623,7 @@ async def _restart_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_restart_dev_box_request( + _request = build_dev_boxes_restart_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2619,11 +2634,11 @@ async def _restart_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2643,9 +2658,9 @@ async def _restart_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace_async async def begin_restart_dev_box( @@ -2746,13 +2761,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _repair_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2770,7 +2785,7 @@ async def _repair_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_repair_dev_box_request( + _request = build_dev_boxes_repair_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2781,11 +2796,11 @@ async def _repair_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2805,9 +2820,9 @@ async def _repair_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace_async async def begin_repair_dev_box( @@ -2909,19 +2924,26 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - @distributed_trace_async - async def get_remote_connection( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> JSON: - """Gets RDP Connection info. + @distributed_trace + def list_customization_groups( + self, + project_name: str, + dev_box_name: str, + user_id: str = "me", + *, + include: Optional[List[str]] = None, + **kwargs: Any + ) -> AsyncIterable[JSON]: + """Lists customization groups on the Dev Box. Listed customization groups exclude task information + unless specified via the include parameter. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str @@ -2930,8 +2952,11 @@ async def get_remote_connection( :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :return: JSON object - :rtype: JSON + :keyword include: Optional query parameter to specify what properties should be included in the + response. Default value is None. + :paramtype include: list[str] + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -2939,11 +2964,41 @@ async def get_remote_connection( # 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. + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. } """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2952,152 +3007,60 @@ async def get_remote_connection( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[JSON] = kwargs.pop("cls", None) + _request = build_dev_boxes_list_customization_groups_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + include=include, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - request = build_dev_boxes_get_remote_connection_request( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + return _request - 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) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def list_actions( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> AsyncIterable[JSON]: - """Lists actions on a Dev Box. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] - :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. - "sourceType": "str", # The type of the resource which triggered this action. - Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this action. - Required. - "uri": "str", # The unique URI for the Dev Box 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 {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_dev_boxes_list_actions_request( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3112,17 +3075,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_action( - self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any + async def get_customization_group( + self, project_name: str, dev_box_name: str, customization_group_name: str, user_id: str = "me", **kwargs: Any ) -> JSON: - """Gets an action. + """Gets a customization group. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :param action_name: The name of an action that will take place on a Dev Box. Required. - :type action_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str @@ -3135,21 +3098,34 @@ async def get_action( # 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. - "sourceType": "str", # The type of the resource which triggered this action. - Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this action. - Required. - "uri": "str", # The unique URI for the Dev Box 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). + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. } """ error_map = { @@ -3165,10 +3141,10 @@ async def get_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_get_action_request( + _request = build_dev_boxes_get_customization_group_request( project_name=project_name, dev_box_name=dev_box_name, - action_name=action_name, + customization_group_name=customization_group_name, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -3177,11 +3153,11 @@ async def get_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3198,96 +3174,138 @@ async def get_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def skip_action( # pylint: disable=inconsistent-return-statements - self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any - ) -> None: - """Skips an occurrence of an action. + @overload + async def create_customization_group( + self, + project_name: str, + dev_box_name: str, + customization_group_name: str, + body: JSON, + user_id: str = "me", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + """Applies customizations to the Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :param action_name: The name of an action that will take place on a Dev Box. Required. - :type action_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param body: Represents a customization group. Required. + :type body: JSON :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :return: None - :rtype: None + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - request = build_dev_boxes_skip_action_request( - project_name=project_name, - dev_box_name=dev_box_name, - action_name=action_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response + Example: + .. code-block:: python - 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) + # JSON input template you can fill out and use as your body input. + body = { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } - if cls: - return cls(pipeline_response, None, {}) + # response body for status code(s): 200 + response == { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } + """ - @distributed_trace_async - async def delay_action( + @overload + async def create_customization_group( self, project_name: str, dev_box_name: str, - action_name: str, + customization_group_name: str, + body: IO, user_id: str = "me", *, - until: datetime.datetime, + content_type: str = "application/json", **kwargs: Any ) -> JSON: - """Delays the occurrence of an action. + """Applies customizations to the Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :param action_name: The name of an action that will take place on a Dev Box. Required. - :type action_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param body: Represents a customization group. Required. + :type body: IO :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword until: The time to delay the Dev Box action or actions until. Required. - :paramtype until: ~datetime.datetime + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -3297,42 +3315,315 @@ async def delay_action( # 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. - "sourceType": "str", # The type of the resource which triggered this action. - Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this action. - Required. - "uri": "str", # The unique URI for the Dev Box 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). + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. } """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_delay_action_request( + @distributed_trace_async + async def create_customization_group( + self, + project_name: str, + dev_box_name: str, + customization_group_name: str, + body: Union[JSON, IO], + user_id: str = "me", + **kwargs: Any + ) -> JSON: + """Applies customizations to the Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param body: Represents a customization group. Is either a JSON type or a IO type. Required. + :type body: JSON or IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } + + # response body for status code(s): 200 + response == { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_dev_boxes_create_customization_group_request( + project_name=project_name, + dev_box_name=dev_box_name, + customization_group_name=customization_group_name, + user_id=user_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_customization_task_log( + self, + project_name: str, + dev_box_name: str, + customization_group_name: str, + customization_task_id: str, + user_id: str = "me", + **kwargs: Any + ) -> AsyncIterator[bytes]: + """Gets the log for a customization task. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param customization_task_id: A customization task ID. Required. + :type customization_task_id: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: Async iterator of the response bytes + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_customization_task_log_request( + project_name=project_name, + dev_box_name=dev_box_name, + customization_group_name=customization_group_name, + customization_task_id=customization_task_id, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, cast(AsyncIterator[bytes], deserialized), {}) # type: ignore + + return cast(AsyncIterator[bytes], deserialized) # type: ignore + + @distributed_trace_async + async def get_remote_connection( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + ) -> JSON: + """Gets RDP Connection info. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: JSON object + :rtype: JSON + :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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_remote_connection_request( project_name=project_name, dev_box_name=dev_box_name, - action_name=action_name, user_id=user_id, - until=until, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3340,11 +3631,11 @@ async def delay_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3361,15 +3652,15 @@ async def delay_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def delay_actions( - self, project_name: str, dev_box_name: str, user_id: str = "me", *, until: datetime.datetime, **kwargs: Any + def list_actions( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any ) -> AsyncIterable[JSON]: - """Delays all actions. + """Lists actions on a Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str @@ -3378,8 +3669,6 @@ def delay_actions( :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword until: The time to delay the Dev Box action or actions until. Required. - :paramtype until: ~datetime.datetime :return: An iterator like instance of JSON object :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: @@ -3389,39 +3678,21 @@ def delay_actions( # 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. - "result": "str", # The result of the delay operation on this action. - Required. Known values are: "Succeeded" and "Failed". - "uri": "str", # The unique URI of the action. Required. - "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. - "sourceType": "str", # The type of the resource which triggered this - action. Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this - action. Required. - "uri": "str", # The unique URI for the Dev Box 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). + "sourceId": "str", # The id of the resource which triggered this action. + Required. + "sourceType": "str", # The type of the resource which triggered this action. + Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this action. + Required. + "uri": "str", # The unique URI for the Dev Box action. Required. + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. }, - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - } + "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that + the action could occur (UTC). } """ _headers = kwargs.pop("headers", {}) or {} @@ -3440,11 +3711,10 @@ def delay_actions( def prepare_request(next_link=None): if not next_link: - request = build_dev_boxes_delay_actions_request( + _request = build_dev_boxes_list_actions_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, - until=until, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3454,7 +3724,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3466,7 +3736,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3474,9 +3744,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3486,11 +3756,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3504,26 +3774,401 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get_action( + self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any + ) -> JSON: + """Gets an action. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param action_name: The name of an action that will take place on a Dev Box. Required. + :type action_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: JSON object + :rtype: JSON + :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. + "sourceType": "str", # The type of the resource which triggered this action. + Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this action. + Required. + "uri": "str", # The unique URI for the Dev Box 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_action_request( + project_name=project_name, + dev_box_name=dev_box_name, + action_name=action_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def skip_action( # pylint: disable=inconsistent-return-statements + self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any + ) -> None: + """Skips an occurrence of an action. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param action_name: The name of an action that will take place on a Dev Box. Required. + :type action_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_dev_boxes_skip_action_request( + project_name=project_name, + dev_box_name=dev_box_name, + action_name=action_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def delay_action( + self, + project_name: str, + dev_box_name: str, + action_name: str, + user_id: str = "me", + *, + until: datetime.datetime, + **kwargs: Any + ) -> JSON: + """Delays the occurrence of an action. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param action_name: The name of an action that will take place on a Dev Box. Required. + :type action_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword until: The time to delay the Dev Box action or actions until. Required. + :paramtype until: ~datetime.datetime + :return: JSON object + :rtype: JSON + :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. + "sourceType": "str", # The type of the resource which triggered this action. + Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this action. + Required. + "uri": "str", # The unique URI for the Dev Box 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_delay_action_request( + project_name=project_name, + dev_box_name=dev_box_name, + action_name=action_name, + user_id=user_id, + until=until, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def delay_all_actions( + self, project_name: str, dev_box_name: str, user_id: str = "me", *, until: datetime.datetime, **kwargs: Any + ) -> AsyncIterable[JSON]: + """Delays all actions. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword until: The time to delay the Dev Box action or actions until. Required. + :paramtype until: ~datetime.datetime + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] + :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". + "uri": "str", # The unique URI of the action. Required. + "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. + "sourceType": "str", # The type of the resource which triggered this + action. Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this + action. Required. + "uri": "str", # The unique URI for the Dev Box 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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + } + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_delay_all_actions_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + until=until, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) -class DevBoxOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.aio.DevCenterClient`'s - :attr:`dev_box_operations` attribute. - """ + async def get_next(next_link=None): + _request = prepare_request(next_link) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list( + def list_operations( self, project_name: str, dev_box_name: str, @@ -3692,7 +4337,7 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_dev_box_operations_list_request( + _request = build_dev_boxes_list_operations_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -3707,7 +4352,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3719,7 +4364,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3727,9 +4372,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3739,11 +4384,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3758,7 +4403,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get( + async def get_operation( self, project_name: str, dev_box_name: str, operation_id: str, user_id: str = "me", **kwargs: Any ) -> JSON: """Gets an operation on a Dev Box. @@ -3898,9 +4543,305 @@ async def get( started. } - # response body for status code(s): 200 - response == dev_box_operation - """ + # response body for status code(s): 200 + response == dev_box_operation + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_operation_request( + project_name=project_name, + dev_box_name=dev_box_name, + operation_id=operation_id, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + +class ProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.aio.DevCenterClient`'s + :attr:`projects` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_customization_task_definitions( + self, project_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable[JSON]: + """Lists all customization tasks available to the project. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "catalogName": "str", # Name of the catalog that the task belongs to. + Required. + "name": "str", # Full name of the task: {catalogName}/{taskName}. Required. + "description": "str", # Optional. Description of the task. + "parameters": { + "str": { + "type": "str", # Type of the parameter. Required. Known + values are: "string", "number", and "boolean". + "allowed": [ + "str" # Optional. Allowed values for the parameter. + ], + "default": "str", # Optional. Default value for the + parameter. + "description": "str", # Optional. Description of the + parameter. + "required": bool # Optional. Whether or not the parameter is + required. + } + }, + "uri": "str" # Optional. The unique URI of the customization task. + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_projects_list_customization_task_definitions_request( + project_name=project_name, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_customization_task_definition( + self, + project_name: str, + catalog_name: str, + task_name: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Gets a customization task. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param catalog_name: The name of the catalog. Required. + :type catalog_name: str + :param task_name: A customization task name. Required. + :type task_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "catalogName": "str", # Name of the catalog that the task belongs to. + Required. + "name": "str", # Full name of the task: {catalogName}/{taskName}. Required. + "description": "str", # Optional. Description of the task. + "parameters": { + "str": { + "type": "str", # Type of the parameter. Required. Known + values are: "string", "number", and "boolean". + "allowed": [ + "str" # Optional. Allowed values for the parameter. + ], + "default": "str", # Optional. Default value for the + parameter. + "description": "str", # Optional. Description of the + parameter. + "required": bool # Optional. Whether or not the parameter is + required. + } + }, + "uri": "str" # Optional. The unique URI of the customization task. + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_projects_get_customization_task_definition_request( + project_name=project_name, + catalog_name=catalog_name, + task_name=task_name, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + async def _validate_customization_tasks_initial( + self, project_name: str, body: Union[JSON, IO], **kwargs: Any + ) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3909,33 +4850,42 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _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[JSON] = kwargs.pop("cls", None) - request = build_dev_box_operations_get_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_projects_validate_customization_tasks_request( project_name=project_name, - dev_box_name=dev_box_name, - operation_id=operation_id, - user_id=user_id, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [202]: 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) @@ -3947,19 +4897,378 @@ async def get( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore + @overload + async def begin_validate_customization_tasks( + self, project_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[JSON]: + """Validates a list of customization tasks. -class EnvironmentsOperations: + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param body: Customization tasks to validate. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns JSON object + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ] + } + + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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. + "result": { + "validationResult": "str", # Outcome of validation. Required. Known + values are: "Succeeded" and "Failed". + "errors": [ + { + "details": [ + { + "code": "str", # An identifier for + the error. Codes are invariant and are intended to be + consumed programmatically. Required. + "message": "str" # A message + describing the error, intended to be suitable for display in + a user interface. Required. + } + ], + "target": { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display + name to help differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # + Optional. End time of the task. + "id": "str", # Optional. ID of the task + instance. + "logUri": "str", # Optional. The unique URI + for retrieving the task logs. + "parameters": { + "str": "str" # Optional. Parameters + for the task. + }, + "startTime": "2020-02-20 00:00:00", # + Optional. Start time of the task. + "status": "str" # Optional. Status of the + task. Known values are: "NotStarted", "Running", "Succeeded", + "FailedValidation", "Skipped", "TimedOut", and "Failed". + } + } + ] + }, + "startTime": "2020-02-20 00:00:00" # Optional. The start time of the + operation. + } + """ + + @overload + async def begin_validate_customization_tasks( + self, project_name: str, body: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[JSON]: + """Validates a list of customization tasks. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param body: Customization tasks to validate. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns JSON object + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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. + "result": { + "validationResult": "str", # Outcome of validation. Required. Known + values are: "Succeeded" and "Failed". + "errors": [ + { + "details": [ + { + "code": "str", # An identifier for + the error. Codes are invariant and are intended to be + consumed programmatically. Required. + "message": "str" # A message + describing the error, intended to be suitable for display in + a user interface. Required. + } + ], + "target": { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display + name to help differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # + Optional. End time of the task. + "id": "str", # Optional. ID of the task + instance. + "logUri": "str", # Optional. The unique URI + for retrieving the task logs. + "parameters": { + "str": "str" # Optional. Parameters + for the task. + }, + "startTime": "2020-02-20 00:00:00", # + Optional. Start time of the task. + "status": "str" # Optional. Status of the + task. Known values are: "NotStarted", "Running", "Succeeded", + "FailedValidation", "Skipped", "TimedOut", and "Failed". + } + } + ] + }, + "startTime": "2020-02-20 00:00:00" # Optional. The start time of the + operation. + } + """ + + @distributed_trace_async + async def begin_validate_customization_tasks( + self, project_name: str, body: Union[JSON, IO], **kwargs: Any + ) -> AsyncLROPoller[JSON]: + """Validates a list of customization tasks. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param body: Customization tasks to validate. Is either a JSON type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns JSON object + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ] + } + + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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. + "result": { + "validationResult": "str", # Outcome of validation. Required. Known + values are: "Succeeded" and "Failed". + "errors": [ + { + "details": [ + { + "code": "str", # An identifier for + the error. Codes are invariant and are intended to be + consumed programmatically. Required. + "message": "str" # A message + describing the error, intended to be suitable for display in + a user interface. Required. + } + ], + "target": { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display + name to help differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # + Optional. End time of the task. + "id": "str", # Optional. ID of the task + instance. + "logUri": "str", # Optional. The unique URI + for retrieving the task logs. + "parameters": { + "str": "str" # Optional. Parameters + for the task. + }, + "startTime": "2020-02-20 00:00:00", # + Optional. Start time of the task. + "status": "str" # Optional. Status of the + task. Known values are: "NotStarted", "Running", "Succeeded", + "FailedValidation", "Skipped", "TimedOut", and "Failed". + } + } + ] + }, + "startTime": "2020-02-20 00:00:00" # Optional. The start time of the + operation. + } + """ + _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[JSON] = 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) + if cont_token is None: + raw_result = await self._validate_customization_tasks_initial( + project_name=project_name, + body=body, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling( + lro_delay, + lro_options={"final-state-via": "operation-location"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DeploymentEnvironmentsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.developer.devcenter.aio.DevCenterClient`'s - :attr:`environments` attribute. + :attr:`deployment_environments` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -3970,7 +5279,9 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_environments(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable[JSON]: + def list_all_environments( + self, project_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable[JSON]: """Lists the environments for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. @@ -3987,10 +5298,12 @@ def list_environments(self, project_name: str, *, top: Optional[int] = None, **k # 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4002,8 +5315,12 @@ def list_environments(self, project_name: str, *, top: Optional[int] = None, **k "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4029,7 +5346,7 @@ def list_environments(self, project_name: str, *, top: Optional[int] = None, **k def prepare_request(next_link=None): if not next_link: - request = build_environments_list_environments_request( + _request = build_deployment_environments_list_all_environments_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -4041,7 +5358,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -4053,7 +5370,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -4061,9 +5378,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -4073,11 +5390,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4092,7 +5409,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_environments_by_user( + def list_environments( self, project_name: str, user_id: str = "me", *, top: Optional[int] = None, **kwargs: Any ) -> AsyncIterable[JSON]: """Lists the environments for a project and user. @@ -4114,10 +5431,12 @@ def list_environments_by_user( # 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4129,8 +5448,12 @@ def list_environments_by_user( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4156,7 +5479,7 @@ def list_environments_by_user( def prepare_request(next_link=None): if not next_link: - request = build_environments_list_environments_by_user_request( + _request = build_deployment_environments_list_environments_request( project_name=project_name, user_id=user_id, top=top, @@ -4169,7 +5492,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -4181,7 +5504,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -4189,9 +5512,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -4201,11 +5524,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4220,7 +5543,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_environment_by_user( + async def get_environment( self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> JSON: """Gets an environment. @@ -4241,10 +5564,12 @@ async def get_environment_by_user( # 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4256,8 +5581,12 @@ async def get_environment_by_user( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4280,7 +5609,7 @@ async def get_environment_by_user( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environments_get_environment_by_user_request( + _request = build_deployment_environments_get_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -4291,11 +5620,11 @@ async def get_environment_by_user( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4312,11 +5641,11 @@ async def get_environment_by_user( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore - async def _create_or_replace_environment_initial( + async def _create_or_update_environment_initial( self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any ) -> JSON: error_map = { @@ -4341,7 +5670,7 @@ async def _create_or_replace_environment_initial( else: _json = body - request = build_environments_create_or_replace_environment_request( + _request = build_deployment_environments_create_or_update_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -4355,11 +5684,11 @@ async def _create_or_replace_environment_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4379,12 +5708,12 @@ async def _create_or_replace_environment_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @overload - async def begin_create_or_replace_environment( + async def begin_create_or_update_environment( self, project_name: str, environment_name: str, @@ -4424,10 +5753,12 @@ async def begin_create_or_replace_environment( # 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4439,8 +5770,12 @@ async def begin_create_or_replace_environment( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4451,11 +5786,13 @@ async def begin_create_or_replace_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. + response == { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4467,8 +5804,12 @@ async def begin_create_or_replace_environment( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4480,7 +5821,7 @@ async def begin_create_or_replace_environment( """ @overload - async def begin_create_or_replace_environment( + async def begin_create_or_update_environment( self, project_name: str, environment_name: str, @@ -4520,10 +5861,12 @@ async def begin_create_or_replace_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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4535,8 +5878,12 @@ async def begin_create_or_replace_environment( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4548,7 +5895,7 @@ async def begin_create_or_replace_environment( """ @distributed_trace_async - async def begin_create_or_replace_environment( + async def begin_create_or_update_environment( self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any ) -> AsyncLROPoller[JSON]: """Creates or updates an environment. @@ -4581,10 +5928,12 @@ async def begin_create_or_replace_environment( # 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4596,8 +5945,12 @@ async def begin_create_or_replace_environment( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4609,10 +5962,12 @@ async def begin_create_or_replace_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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -4624,8 +5979,12 @@ async def begin_create_or_replace_environment( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -4644,7 +6003,7 @@ async def begin_create_or_replace_environment( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_replace_environment_initial( + raw_result = await self._create_or_update_environment_initial( project_name=project_name, environment_name=environment_name, body=body, @@ -4691,17 +6050,296 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _delete_environment_initial( + self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any + ) -> Optional[JSON]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_deployment_environments_delete_environment_request( + project_name=project_name, + environment_name=environment_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 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) + + deserialized = None + response_headers = {} + if response.status_code == 202: + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete_environment( + self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any + ) -> AsyncLROPoller[JSON]: + """Deletes an environment and all its associated resources. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False + for this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns JSON object + :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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[JSON] = 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) + if cont_token is None: + raw_result = await self._delete_environment_initial( + project_name=project_name, + environment_name=environment_name, + user_id=user_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_catalogs(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable[JSON]: + """Lists all of the catalogs available for a project. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "name": "str", # Name of the catalog. Required. + "uri": "str" # The unique URI of the catalog. Required. + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployment_environments_list_catalogs_request( + project_name=project_name, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JSON: + """Gets the specified catalog within the project. - async def _delete_environment_initial( - self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any - ) -> Optional[JSON]: + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param catalog_name: The name of the catalog. Required. + :type catalog_name: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "name": "str", # Name of the catalog. Required. + "uri": "str" # The unique URI of the catalog. Required. + } + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4713,12 +6351,11 @@ 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[JSON] = kwargs.pop("cls", None) - request = build_environments_delete_environment_request( + _request = build_deployment_environments_get_catalog_request( project_name=project_name, - environment_name=environment_name, - user_id=user_id, + catalog_name=catalog_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4726,148 +6363,171 @@ async def _delete_environment_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202, 204]: + 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) - deserialized = None - response_headers = {} - if response.status_code == 202: - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return deserialized + return cast(JSON, deserialized) # type: ignore - @distributed_trace_async - async def begin_delete_environment( - self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Deletes an environment and all its associated resources. + @distributed_trace + def list_environment_definitions( + self, project_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable[JSON]: + """Lists all environment definitions available for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param environment_name: The name of the environment. Required. - :type environment_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. Pass in False - for this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns JSON object - :rtype: ~azure.core.polling.AsyncLROPoller[JSON] + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 202 + # response body for status code(s): 200 response == { - "status": "str", # Provisioning state of the resource. Required. - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # Optional. The error code. - "message": "str" # Optional. The error message. - }, - "id": "str", # Optional. Fully qualified ID for the operation status. - "name": "str", # Optional. The operation id name. - "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. + "catalogName": "str", # Name of the catalog. Required. + "id": "str", # The ID of the environment definition. Required. + "name": "str", # Name of the environment definition. Required. + "uri": "str", # The unique URI 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 {} cls: ClsType[JSON] = 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) - if cont_token is None: - raw_result = await self._delete_environment_initial( - project_name=project_name, - environment_name=environment_name, - user_id=user_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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") - ) + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployment_environments_list_environment_definitions_request( + project_name=project_name, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if response.content: - deserialized = response.json() else: - deserialized = None + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + async def get_next(next_link=None): + _request = prepare_request(next_link) - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + 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) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_catalogs_by_project( - self, project_name: str, *, top: Optional[int] = None, **kwargs: Any + def list_environment_definitions_by_catalog( + self, project_name: str, catalog_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists all of the catalogs available for a project. + """Lists all environment definitions available within a catalog. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str + :param catalog_name: The name of the catalog. Required. + :type catalog_name: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int @@ -4880,8 +6540,36 @@ def list_catalogs_by_project( # response body for status code(s): 200 response == { - "name": "str", # Name of the catalog. Required. - "uri": "str" # The unique URI of the catalog. Required. + "catalogName": "str", # Name of the catalog. Required. + "id": "str", # The ID of the environment definition. Required. + "name": "str", # Name of the environment definition. Required. + "uri": "str", # The unique URI 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 {} @@ -4900,8 +6588,9 @@ def list_catalogs_by_project( def prepare_request(next_link=None): if not next_link: - request = build_environments_list_catalogs_by_project_request( + _request = build_deployment_environments_list_environment_definitions_by_catalog_request( project_name=project_name, + catalog_name=catalog_name, top=top, api_version=self._config.api_version, headers=_headers, @@ -4912,7 +6601,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -4924,7 +6613,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -4932,9 +6621,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -4944,11 +6633,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4963,13 +6652,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JSON: - """Gets the specified catalog within the project. + async def get_environment_definition( + self, project_name: str, catalog_name: str, definition_name: str, **kwargs: Any + ) -> JSON: + """Get an environment definition from a catalog. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param catalog_name: The name of the catalog. Required. :type catalog_name: str + :param definition_name: The name of the environment definition. Required. + :type definition_name: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -4979,8 +6672,36 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) # response body for status code(s): 200 response == { - "name": "str", # Name of the catalog. Required. - "uri": "str" # The unique URI of the catalog. Required. + "catalogName": "str", # Name of the catalog. Required. + "id": "str", # The ID of the environment definition. Required. + "name": "str", # Name of the environment definition. Required. + "uri": "str", # The unique URI 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 = { @@ -4996,9 +6717,10 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environments_get_catalog_request( + _request = build_deployment_environments_get_environment_definition_request( project_name=project_name, catalog_name=catalog_name, + definition_name=definition_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5006,11 +6728,11 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5027,15 +6749,15 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_environment_definitions_by_project( + def list_environment_types( self, project_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists all environment definitions available for a project. + """Lists all environment types configured for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str @@ -5051,36 +6773,14 @@ def list_environment_definitions_by_project( # 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. - "uri": "str", # The unique URI 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. + "deploymentTargetId": "str", # The 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". + "uri": "str", # The unique URI of the environment type. Required. + "displayName": "str" # Optional. Display name of the environment type. } """ _headers = kwargs.pop("headers", {}) or {} @@ -5099,7 +6799,7 @@ def list_environment_definitions_by_project( def prepare_request(next_link=None): if not next_link: - request = build_environments_list_environment_definitions_by_project_request( + _request = build_deployment_environments_list_environment_types_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -5111,7 +6811,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5123,7 +6823,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5131,9 +6831,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5143,11 +6843,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5161,65 +6861,285 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list_environment_definitions_by_catalog( - self, project_name: str, catalog_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[JSON]: - """Lists all environment definitions available within a catalog. + +class EnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.aio.DevCenterClient`'s + :attr:`environments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def patch_environment( + self, + project_name: str, + environment_name: str, + body: JSON, + user_id: str = "me", + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Partially updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param catalog_name: The name of the catalog. Required. - :type catalog_name: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param body: Updatable environment properties. Required. + :type body: JSON + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :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", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + + # response body for status code(s): 200 + response == { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + """ + + @overload + async def patch_environment( + self, + project_name: str, + environment_name: str, + body: IO, + user_id: str = "me", + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Partially updates an environment. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param body: Updatable environment properties. Required. + :type body: IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + """ + + @distributed_trace_async + async def patch_environment( + self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any + ) -> JSON: + """Partially updates an environment. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param body: Updatable environment properties. Is either a JSON type or a IO type. Required. + :type body: JSON or IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON :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", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + # 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. - "uri": "str", # The unique URI 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5228,84 +7148,69 @@ def list_environment_definitions_by_catalog( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - request = build_environments_list_environment_definitions_by_catalog_request( - project_name=project_name, - catalog_name=catalog_name, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[JSON] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - return request + _request = build_environments_patch_environment_request( + project_name=project_name, + environment_name=environment_name, + user_id=user_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - 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) - 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) + if response.content: + deserialized = response.json() + else: + deserialized = None - return pipeline_response + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_environment_definition( - self, project_name: str, catalog_name: str, definition_name: str, **kwargs: Any - ) -> JSON: - """Get an environment definition from a catalog. + async def get_outputs(self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any) -> JSON: + """Gets Outputs from the environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param catalog_name: The name of the catalog. Required. - :type catalog_name: str - :param definition_name: The name of the environment definition. Required. - :type definition_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -5315,36 +7220,15 @@ async def get_environment_definition( # 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. - "uri": "str", # The unique URI 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. + "outputs": { + "str": { + "sensitive": bool, # Optional. Indicates if the value is + sensitive. + "type": "str", # Optional. Type of the output value. Known + values are: "array", "boolean", "number", "object", and "string". + "value": {} # Optional. The output 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 = { @@ -5360,10 +7244,10 @@ async def get_environment_definition( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environments_get_environment_definition_request( + _request = build_environments_get_outputs_request( project_name=project_name, - catalog_name=catalog_name, - definition_name=definition_name, + environment_name=environment_name, + user_id=user_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5371,11 +7255,11 @@ async def get_environment_definition( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5392,38 +7276,104 @@ async def get_environment_definition( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_environment_types( - self, project_name: str, *, top: Optional[int] = None, **kwargs: Any + def list_operations( + self, + project_name: str, + environment_name: str, + user_id: str = "me", + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists all environment types configured for a project. + """Lists operations on the environment which have occurred within the past 90 days. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: - Example: - .. code-block:: python + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": + + # JSON input template for discriminator value "Delete": + environment_operation = { + "kind": "Delete", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } + + # JSON input template for discriminator value "Deploy": + environment_operation = { + "kind": "Deploy", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } # response body for status code(s): 200 - response == { - "deploymentTargetId": "str", # The 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". - "uri": "str" # The unique URI of the environment type. Required. - } + response == environment_operation """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -5441,9 +7391,12 @@ def list_environment_types( def prepare_request(next_link=None): if not next_link: - request = build_environments_list_environment_types_request( + _request = build_environments_list_operations_request( project_name=project_name, + environment_name=environment_name, + user_id=user_id, top=top, + filter=filter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5453,7 +7406,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5465,7 +7418,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5473,9 +7426,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5485,11 +7438,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5503,36 +7456,212 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @distributed_trace_async + async def get_operation( + self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any + ) -> JSON: + """Gets an environment action result. -class EnvironmentOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param operation_id: The id of the operation on an environment. Required. + :type operation_id: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.aio.DevCenterClient`'s - :attr:`environment_operations` attribute. - """ + Example: + .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + # JSON input template for discriminator value "Delete": + environment_operation = { + "kind": "Delete", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } - @distributed_trace - def list_by_environment( - self, - project_name: str, - environment_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any + # JSON input template for discriminator value "Deploy": + environment_operation = { + "kind": "Deploy", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } + + # response body for status code(s): 200 + response == environment_operation + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_environments_get_operation_request( + project_name=project_name, + environment_name=environment_name, + operation_id=operation_id, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_logs_by_operation( + self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any + ) -> AsyncIterator[bytes]: + """Gets the logs for an operation on an environment. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param operation_id: The id of the operation on an environment. Required. + :type operation_id: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: Async iterator of the response bytes + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_environments_get_logs_by_operation_request( + project_name=project_name, + environment_name=environment_name, + operation_id=operation_id, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, cast(AsyncIterator[bytes], deserialized), {}) # type: ignore + + return cast(AsyncIterator[bytes], deserialized) # type: ignore + + @distributed_trace + def list_actions( + self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> AsyncIterable[JSON]: - """Lists operations on the environment which have occurred within the past 90 days. + """Get all scheduled actions for a user within an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str @@ -5541,80 +7670,27 @@ def list_by_environment( :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.async_paging.AsyncItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "Delete": - environment_operation = { - "kind": "Delete", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - # JSON input template for discriminator value "Deploy": - environment_operation = { - "kind": "Deploy", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. + # response body for status code(s): 200 + response == { + "actionType": "str", # The action that will be taken. Required. "Delete" + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. time the object was + last modified. + "lastModifiedBy": "str", # Optional. Object Id of the user who last modified + the action. + "name": "str", # Optional. Uniquely identifies the action. + "uri": "str" # Optional. Uri of the action resource. } - - # response body for status code(s): 200 - response == environment_operation """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -5632,12 +7708,10 @@ def list_by_environment( def prepare_request(next_link=None): if not next_link: - request = build_environment_operations_list_by_environment_request( + _request = build_environments_list_actions_request( project_name=project_name, environment_name=environment_name, user_id=user_id, - top=top, - filter=filter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5647,7 +7721,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5659,7 +7733,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5667,9 +7741,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5679,11 +7753,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5698,17 +7772,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_by_environment( - self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any + async def get_action( + self, project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any ) -> JSON: - """Gets an environment action result. + """Retrieve a specific environment action. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :param operation_id: The id of the operation on an environment. Required. - :type operation_id: str + :param action_name: The name of an action that will take place on an Environment. Required. + :type action_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str @@ -5718,69 +7792,21 @@ async def get_by_environment( Example: .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "Delete": - environment_operation = { - "kind": "Delete", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - # JSON input template for discriminator value "Deploy": - environment_operation = { - "kind": "Deploy", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. + # response body for status code(s): 200 + response == { + "actionType": "str", # The action that will be taken. Required. "Delete" + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. time the object was + last modified. + "lastModifiedBy": "str", # Optional. Object Id of the user who last modified + the action. + "name": "str", # Optional. Uniquely identifies the action. + "uri": "str" # Optional. Uri of the action resource. } - - # response body for status code(s): 200 - response == environment_operation """ error_map = { 401: ClientAuthenticationError, @@ -5795,10 +7821,10 @@ async def get_by_environment( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environment_operations_get_by_environment_request( + _request = build_environments_get_action_request( project_name=project_name, environment_name=environment_name, - operation_id=operation_id, + action_name=action_name, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -5807,11 +7833,11 @@ async def get_by_environment( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5828,27 +7854,27 @@ async def get_by_environment( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace_async - async def get_logs( - self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any - ) -> AsyncIterator[bytes]: - """Gets the logs for an operation on an environment. + async def skip_action( # pylint: disable=inconsistent-return-statements + self, project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any + ) -> None: + """Skips an occurrence of an action. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :param operation_id: The id of the operation on an environment. Required. - :type operation_id: str + :param action_name: The name of an action that will take place on an Environment. Required. + :type action_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :return: Async iterator of the response bytes - :rtype: AsyncIterator[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -5862,12 +7888,12 @@ async def get_logs( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_environment_operations_get_logs_request( + _request = build_environments_skip_action_request( project_name=project_name, environment_name=environment_name, - operation_id=operation_id, + action_name=action_name, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -5876,11 +7902,101 @@ async def get_logs( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = True + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace_async + async def delay_action( + self, + project_name: str, + environment_name: str, + action_name: str, + user_id: str = "me", + *, + until: datetime.datetime, + **kwargs: Any + ) -> JSON: + """Delays the occurrence of an action. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param action_name: The name of an action that will take place on an Environment. Required. + :type action_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword until: The time to delay the Environment action until. Required. + :paramtype until: ~datetime.datetime + :return: JSON object + :rtype: JSON + :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. "Delete" + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. + }, + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. time the object was + last modified. + "lastModifiedBy": "str", # Optional. Object Id of the user who last modified + the action. + "name": "str", # Optional. Uniquely identifies the action. + "uri": "str" # Optional. Uri of the action resource. + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_environments_delay_action_request( + project_name=project_name, + environment_name=environment_name, + action_name=action_name, + user_id=user_id, + until=until, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5891,9 +8007,12 @@ async def get_logs( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, cast(AsyncIterator[bytes], deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(AsyncIterator[bytes], deserialized) + return cast(JSON, deserialized) # type: ignore diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/__init__.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/__init__.py index 7a867adbbb5..484f557dc65 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/__init__.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/__init__.py @@ -8,9 +8,9 @@ from ._operations import DevCenterOperations from ._operations import DevBoxesOperations -from ._operations import DevBoxOperationsOperations +from ._operations import ProjectsOperations +from ._operations import DeploymentEnvironmentsOperations from ._operations import EnvironmentsOperations -from ._operations import EnvironmentOperationsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -19,9 +19,9 @@ __all__ = [ "DevCenterOperations", "DevBoxesOperations", - "DevBoxOperationsOperations", + "ProjectsOperations", + "DeploymentEnvironmentsOperations", "EnvironmentsOperations", - "EnvironmentOperationsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py index 578edee5088..3ea2bac7681 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py @@ -9,7 +9,7 @@ import datetime from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -48,7 +48,7 @@ def build_dev_center_list_projects_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -71,7 +71,7 @@ def build_dev_center_get_project_request(project_name: str, **kwargs: Any) -> Ht _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,75 +93,13 @@ 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_all_dev_boxes_request( - *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/devboxes" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dev_center_list_all_dev_boxes_by_user_request( - user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/users/{userId}/devboxes" - path_format_arguments = { - "userId": _SERIALIZER.url( - "user_id", - user_id, - "str", - max_length=36, - min_length=2, - pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if filter is not None: - _params["filter"] = _SERIALIZER.query("filter", filter, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - def build_dev_boxes_list_pools_request( project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -196,7 +134,7 @@ def build_dev_boxes_get_pool_request(project_name: str, pool_name: str, **kwargs _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -226,13 +164,13 @@ def build_dev_boxes_get_pool_request(project_name: str, pool_name: str, **kwargs return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_schedules_by_project_request( +def build_dev_boxes_list_schedules_by_project_request( # pylint: disable=name-too-long project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -263,13 +201,13 @@ def build_dev_boxes_list_schedules_by_project_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_schedules_by_pool_request( +def build_dev_boxes_list_schedules_request( project_name: str, pool_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -303,13 +241,13 @@ def build_dev_boxes_list_schedules_by_pool_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_get_schedule_by_pool_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 {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -340,13 +278,75 @@ def build_dev_boxes_get_schedule_by_pool_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_dev_boxes_by_user_request( +def build_dev_boxes_list_all_dev_boxes_request( # pylint: disable=name-too-long + *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/devboxes" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_dev_boxes_list_all_dev_boxes_by_user_request( # pylint: disable=name-too-long + user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/users/{userId}/devboxes" + path_format_arguments = { + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_dev_boxes_list_dev_boxes_request( project_name: str, user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -385,13 +385,13 @@ def build_dev_boxes_list_dev_boxes_by_user_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_get_dev_box_by_user_request( +def build_dev_boxes_get_dev_box_request( project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -441,7 +441,7 @@ def build_dev_boxes_create_dev_box_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -492,7 +492,7 @@ def build_dev_boxes_delete_dev_box_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -541,7 +541,7 @@ def build_dev_boxes_start_dev_box_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -590,7 +590,7 @@ def build_dev_boxes_stop_dev_box_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -641,7 +641,7 @@ def build_dev_boxes_restart_dev_box_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -690,7 +690,7 @@ def build_dev_boxes_repair_dev_box_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -733,17 +733,17 @@ def build_dev_boxes_repair_dev_box_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_get_remote_connection_request( - project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any +def build_dev_boxes_list_customization_groups_request( # pylint: disable=name-too-long + project_name: str, dev_box_name: str, user_id: str = "me", *, include: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/remoteConnection" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -775,6 +775,8 @@ def build_dev_boxes_get_remote_connection_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include is not None: + _params["include"] = _SERIALIZER.query("include", include, "[str]", div=",") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -782,17 +784,17 @@ def build_dev_boxes_get_remote_connection_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_actions_request( - project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any +def build_dev_boxes_get_customization_group_request( # pylint: disable=name-too-long + project_name: str, dev_box_name: str, customization_group_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -818,6 +820,14 @@ def build_dev_boxes_list_actions_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), + "customizationGroupName": _SERIALIZER.url( + "customization_group_name", + customization_group_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -831,17 +841,18 @@ def build_dev_boxes_list_actions_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_get_action_request( - project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any +def build_dev_boxes_create_customization_group_request( # pylint: disable=name-too-long + project_name: str, dev_box_name: str, customization_group_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -867,8 +878,13 @@ def build_dev_boxes_get_action_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "actionName": _SERIALIZER.url( - "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + "customizationGroupName": _SERIALIZER.url( + "customization_group_name", + customization_group_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), } @@ -878,22 +894,29 @@ def build_dev_boxes_get_action_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_skip_action_request( - project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any +def build_dev_boxes_get_customization_task_log_request( # pylint: disable=name-too-long + project_name: str, + dev_box_name: str, + customization_group_name: str, + customization_task_id: str, + user_id: str = "me", + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) - accept = _headers.pop("Accept", "application/json") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "text/plain") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:skip" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}/logs/{customizationTaskId}" # pylint: disable=line-too-long path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -919,8 +942,21 @@ def build_dev_boxes_skip_action_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "actionName": _SERIALIZER.url( - "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + "customizationGroupName": _SERIALIZER.url( + "customization_group_name", + customization_group_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "customizationTaskId": _SERIALIZER.url( + "customization_task_id", + customization_task_id, + "str", + max_length=36, + min_length=36, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$", ), } @@ -932,26 +968,20 @@ def build_dev_boxes_skip_action_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_delay_action_request( - project_name: str, - dev_box_name: str, - action_name: str, - user_id: str = "me", - *, - until: datetime.datetime, - **kwargs: Any +def build_dev_boxes_get_remote_connection_request( # pylint: disable=name-too-long + project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:delay" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/remoteConnection" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -977,34 +1007,30 @@ def build_dev_boxes_delay_action_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "actionName": _SERIALIZER.url( - "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" - ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["until"] = _SERIALIZER.query("until", until, "iso-8601") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_delay_actions_request( - project_name: str, dev_box_name: str, user_id: str = "me", *, until: datetime.datetime, **kwargs: Any +def build_dev_boxes_list_actions_request( + project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions:delay" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1036,31 +1062,24 @@ def build_dev_boxes_delay_actions_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _params["until"] = _SERIALIZER.query("until", until, "iso-8601") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_box_operations_list_request( - project_name: str, - dev_box_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any +def build_dev_boxes_get_action_request( + project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/operations" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1086,16 +1105,15 @@ def build_dev_box_operations_list_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), + "actionName": _SERIALIZER.url( + "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if filter is not None: - _params["filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1103,17 +1121,17 @@ def build_dev_box_operations_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_box_operations_get_request( - project_name: str, dev_box_name: str, operation_id: str, user_id: str = "me", **kwargs: Any +def build_dev_boxes_skip_action_request( + project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/operations/{operationId}" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:skip" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1139,13 +1157,8 @@ def build_dev_box_operations_get_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "operationId": _SERIALIZER.url( - "operation_id", - operation_id, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + "actionName": _SERIALIZER.url( + "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" ), } @@ -1157,20 +1170,26 @@ def build_dev_box_operations_get_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_list_environments_request( - project_name: str, *, top: Optional[int] = None, **kwargs: Any +def build_dev_boxes_delay_action_request( + project_name: str, + dev_box_name: str, + action_name: str, + user_id: str = "me", + *, + until: datetime.datetime, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/environments" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:delay" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1180,32 +1199,50 @@ def build_environments_list_environments_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "devBoxName": _SERIALIZER.url( + "dev_box_name", + dev_box_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "actionName": _SERIALIZER.url( + "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") + _params["until"] = _SERIALIZER.query("until", until, "iso-8601") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_list_environments_by_user_request( - project_name: str, user_id: str = "me", *, top: Optional[int] = None, **kwargs: Any +def build_dev_boxes_delay_all_actions_request( # pylint: disable=name-too-long + project_name: str, dev_box_name: str, user_id: str = "me", *, until: datetime.datetime, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions:delay" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1223,32 +1260,45 @@ def build_environments_list_environments_by_user_request( min_length=2, pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", ), + "devBoxName": _SERIALIZER.url( + "dev_box_name", + dev_box_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") + _params["until"] = _SERIALIZER.query("until", until, "iso-8601") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_get_environment_by_user_request( - project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any +def build_dev_boxes_list_operations_request( + project_name: str, + dev_box_name: str, + user_id: str = "me", + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/operations" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1266,9 +1316,9 @@ def build_environments_get_environment_by_user_request( min_length=2, pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", ), - "environmentName": _SERIALIZER.url( - "environment_name", - environment_name, + "devBoxName": _SERIALIZER.url( + "dev_box_name", + dev_box_name, "str", max_length=63, min_length=3, @@ -1280,6 +1330,10 @@ def build_environments_get_environment_by_user_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1287,18 +1341,17 @@ def build_environments_get_environment_by_user_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_create_or_replace_environment_request( - project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any +def build_dev_boxes_get_operation_request( + project_name: str, dev_box_name: str, operation_id: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}" + _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/operations/{operationId}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1316,9 +1369,17 @@ def build_environments_create_or_replace_environment_request( min_length=2, pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", ), - "environmentName": _SERIALIZER.url( - "environment_name", - environment_name, + "devBoxName": _SERIALIZER.url( + "dev_box_name", + dev_box_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "operationId": _SERIALIZER.url( + "operation_id", + operation_id, "str", max_length=63, min_length=3, @@ -1332,24 +1393,22 @@ def build_environments_create_or_replace_environment_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_delete_environment_request( - project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any +def build_projects_list_customization_task_definitions_request( # pylint: disable=name-too-long + project_name: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}" + _url = "/projects/{projectName}/customizationTasks" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1359,46 +1418,38 @@ def build_environments_delete_environment_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "userId": _SERIALIZER.url( - "user_id", - user_id, - "str", - max_length=36, - min_length=2, - pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", - ), - "environmentName": _SERIALIZER.url( - "environment_name", - environment_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_list_catalogs_by_project_request( - project_name: str, *, top: Optional[int] = None, **kwargs: Any +def build_projects_get_customization_task_definition_request( # pylint: disable=name-too-long + project_name: str, + catalog_name: str, + task_name: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/catalogs" + _url = "/projects/{projectName}/catalogs/{catalogName}/customizationTasks/{taskName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1408,6 +1459,17 @@ def build_environments_list_catalogs_by_project_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), + "catalogName": _SERIALIZER.url( + "catalog_name", + catalog_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "taskName": _SERIALIZER.url( + "task_name", task_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1416,6 +1478,8 @@ def build_environments_list_catalogs_by_project_request( _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if top is not None: _params["top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1423,15 +1487,18 @@ def build_environments_list_catalogs_by_project_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_get_catalog_request(project_name: str, catalog_name: str, **kwargs: Any) -> HttpRequest: +def build_projects_validate_customization_tasks_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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/catalogs/{catalogName}" + _url = "/projects/{projectName}/customizationTasks:validateGroup" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1441,14 +1508,6 @@ def build_environments_get_catalog_request(project_name: str, catalog_name: str, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "catalogName": _SERIALIZER.url( - "catalog_name", - catalog_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1457,22 +1516,24 @@ def build_environments_get_catalog_request(project_name: str, catalog_name: str, _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_list_environment_definitions_by_project_request( +def build_deployment_environments_list_all_environments_request( # pylint: disable=name-too-long project_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/environmentDefinitions" + _url = "/projects/{projectName}/environments" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1497,17 +1558,17 @@ def build_environments_list_environment_definitions_by_project_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_list_environment_definitions_by_catalog_request( - project_name: str, catalog_name: str, *, top: Optional[int] = None, **kwargs: Any +def build_deployment_environments_list_environments_request( # pylint: disable=name-too-long + project_name: str, user_id: str = "me", *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/catalogs/{catalogName}/environmentDefinitions" + _url = "/projects/{projectName}/users/{userId}/environments" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1517,13 +1578,13 @@ def build_environments_list_environment_definitions_by_catalog_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "catalogName": _SERIALIZER.url( - "catalog_name", - catalog_name, + "userId": _SERIALIZER.url( + "user_id", + user_id, "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", ), } @@ -1540,17 +1601,17 @@ def build_environments_list_environment_definitions_by_catalog_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_get_environment_definition_request( - project_name: str, catalog_name: str, definition_name: str, **kwargs: Any +def build_deployment_environments_get_environment_request( # pylint: disable=name-too-long + project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/catalogs/{catalogName}/environmentDefinitions/{definitionName}" + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1560,17 +1621,17 @@ def build_environments_get_environment_definition_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "catalogName": _SERIALIZER.url( - "catalog_name", - catalog_name, + "userId": _SERIALIZER.url( + "user_id", + user_id, "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", ), - "definitionName": _SERIALIZER.url( - "definition_name", - definition_name, + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, "str", max_length=63, min_length=3, @@ -1589,17 +1650,18 @@ def build_environments_get_environment_definition_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_list_environment_types_request( - project_name: str, *, top: Optional[int] = None, **kwargs: Any +def build_deployment_environments_create_or_update_environment_request( # pylint: disable=name-too-long + project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/environmentTypes" + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1609,38 +1671,48 @@ def build_environments_list_environment_types_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_environment_operations_list_by_environment_request( - project_name: str, - environment_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any +def build_deployment_environments_delete_environment_request( # pylint: disable=name-too-long + project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations" + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1672,28 +1744,24 @@ def build_environment_operations_list_by_environment_request( # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["top"] = _SERIALIZER.query("top", top, "int") - if filter is not None: - _params["filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_environment_operations_get_by_environment_request( - project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any +def build_deployment_environments_list_catalogs_request( # pylint: disable=name-too-long + project_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations/{operationId}" + _url = "/projects/{projectName}/catalogs" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1703,36 +1771,14 @@ def build_environment_operations_get_by_environment_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "userId": _SERIALIZER.url( - "user_id", - user_id, - "str", - max_length=36, - min_length=2, - pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", - ), - "environmentName": _SERIALIZER.url( - "environment_name", - environment_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "operationId": _SERIALIZER.url( - "operation_id", - operation_id, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1740,17 +1786,17 @@ def build_environment_operations_get_by_environment_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environment_operations_get_logs_request( - project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any +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 {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01-preview")) - accept = _headers.pop("Accept", "text/plain") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations/{operationId}/logs" + _url = "/projects/{projectName}/catalogs/{catalogName}" path_format_arguments = { "projectName": _SERIALIZER.url( "project_name", @@ -1760,25 +1806,9 @@ def build_environment_operations_get_logs_request( min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", ), - "userId": _SERIALIZER.url( - "user_id", - user_id, - "str", - max_length=36, - min_length=2, - pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", - ), - "environmentName": _SERIALIZER.url( - "environment_name", - environment_name, - "str", - max_length=63, - min_length=3, - pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", - ), - "operationId": _SERIALIZER.url( - "operation_id", - operation_id, + "catalogName": _SERIALIZER.url( + "catalog_name", + catalog_name, "str", max_length=63, min_length=3, @@ -1797,286 +1827,3164 @@ def build_environment_operations_get_logs_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class DevCenterOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.DevCenterClient`'s - :attr:`dev_center` attribute. - """ +def build_deployment_environments_list_environment_definitions_request( # pylint: disable=name-too-long + project_name: str, *, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") - @distributed_trace - def list_projects( - self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists all projects. + # Construct URL + _url = "/projects/{projectName}/environmentDefinitions" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] - :raises ~azure.core.exceptions.HttpResponseError: + _url: str = _url.format(**path_format_arguments) # type: ignore - Example: - .. code-block:: python + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") - # response body for status code(s): 200 - response == { - "name": "str", # Name of the project. Required. - "uri": "str", # The unique URI 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 {} + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - cls: ClsType[JSON] = kwargs.pop("cls", None) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: +def build_deployment_environments_list_environment_definitions_by_catalog_request( # pylint: disable=name-too-long + project_name: str, catalog_name: str, *, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - request = build_dev_center_list_projects_request( - filter=filter, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + # Construct URL + _url = "/projects/{projectName}/catalogs/{catalogName}/environmentDefinitions" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "catalogName": _SERIALIZER.url( + "catalog_name", + catalog_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } - return request + _url: str = _url.format(**path_format_arguments) # type: ignore - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") - def get_next(next_link=None): - request = prepare_request(next_link) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - 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) - return pipeline_response +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 {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - return ItemPaged(get_next, extract_data) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") - @distributed_trace - def get_project(self, project_name: str, **kwargs: Any) -> JSON: - """Gets a project. + # Construct URL + _url = "/projects/{projectName}/catalogs/{catalogName}/environmentDefinitions/{definitionName}" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "catalogName": _SERIALIZER.url( + "catalog_name", + catalog_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "definitionName": _SERIALIZER.url( + "definition_name", + definition_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: + _url: str = _url.format(**path_format_arguments) # type: ignore - Example: - .. code-block:: python + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # response body for status code(s): 200 - response == { - "name": "str", # Name of the project. Required. - "uri": "str", # The unique URI 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 = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_center_get_project_request( - project_name=project_name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) +def build_deployment_environments_list_environment_types_request( # pylint: disable=name-too-long + project_name: str, *, top: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") - response = pipeline_response.http_response + # Construct URL + _url = "/projects/{projectName}/environmentTypes" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } - 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) + _url: str = _url.format(**path_format_arguments) # type: ignore - if response.content: + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_patch_environment_request( # pylint: disable=name-too-long + project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs) + + +def build_environments_get_outputs_request( + project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/outputs" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_list_operations_request( # pylint: disable=name-too-long + project_name: str, + environment_name: str, + user_id: str = "me", + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_get_operation_request( + project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations/{operationId}" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "operationId": _SERIALIZER.url( + "operation_id", + operation_id, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_get_logs_by_operation_request( # pylint: disable=name-too-long + project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "text/plain") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations/{operationId}/logs" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "operationId": _SERIALIZER.url( + "operation_id", + operation_id, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_list_actions_request( + project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_get_action_request( + project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions/{actionName}" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "actionName": _SERIALIZER.url( + "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_skip_action_request( + project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions/{actionName}:skip" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "actionName": _SERIALIZER.url( + "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_environments_delay_action_request( + project_name: str, + environment_name: str, + action_name: str, + user_id: str = "me", + *, + until: datetime.datetime, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions/{actionName}:delay" + path_format_arguments = { + "projectName": _SERIALIZER.url( + "project_name", + project_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "userId": _SERIALIZER.url( + "user_id", + user_id, + "str", + max_length=36, + min_length=2, + pattern=r"^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + ), + "environmentName": _SERIALIZER.url( + "environment_name", + environment_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + ), + "actionName": _SERIALIZER.url( + "action_name", action_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["until"] = _SERIALIZER.query("until", until, "iso-8601") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DevCenterOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.DevCenterClient`'s + :attr:`dev_center` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_projects( + self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists all projects. + + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "name": "str", # Name of the project. Required. + "uri": "str", # The unique URI of the project. Required. + "description": "str", # Optional. Description of the project. + "displayName": "str", # Optional. Display name 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 {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_center_list_projects_request( + filter=filter, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_project(self, project_name: str, **kwargs: Any) -> JSON: + """Gets a project. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "name": "str", # Name of the project. Required. + "uri": "str", # The unique URI of the project. Required. + "description": "str", # Optional. Description of the project. + "displayName": "str", # Optional. Display name 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_center_get_project_request( + project_name=project_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + +class DevBoxesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.DevCenterClient`'s + :attr:`dev_boxes` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_pools( + self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists available pools. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :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. + "uri": "str", # The unique URI of the pool. Required. + "displayName": "str", # Optional. Display name of the pool. + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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 {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_list_pools_request( + project_name=project_name, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: + """Gets a pool. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param pool_name: The name of a pool of Dev Boxes. Required. + :type pool_name: str + :return: JSON object + :rtype: JSON + :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. + "uri": "str", # The unique URI of the pool. Required. + "displayName": "str", # Optional. Display name of the pool. + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_pool_request( + project_name=project_name, + pool_name=pool_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def list_schedules_by_project( + self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists all schedules within a project that are configured by your project administrator. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :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. + "sourceType": "str", # The type of the resource that this schedule belongs + to. Required. "Pool" + "sourceUri": "str", # The URI of the resource that this schedule belongs to. + 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" + "uri": "str" # The unique URI of the schedule. Required. + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_list_schedules_by_project_request( + project_name=project_name, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_schedules( + self, + project_name: str, + pool_name: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[JSON]: + """Lists all schedules within a pool that are configured by your project administrator. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param pool_name: The name of a pool of Dev Boxes. Required. + :type pool_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :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. + "sourceType": "str", # The type of the resource that this schedule belongs + to. Required. "Pool" + "sourceUri": "str", # The URI of the resource that this schedule belongs to. + 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" + "uri": "str" # The unique URI of the schedule. Required. + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_list_schedules_request( + project_name=project_name, + pool_name=pool_name, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, **kwargs: Any) -> JSON: + """Gets a schedule. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param pool_name: The name of a pool of Dev Boxes. Required. + :type pool_name: str + :param schedule_name: The name of a schedule. Required. + :type schedule_name: str + :return: JSON object + :rtype: JSON + :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. + "sourceType": "str", # The type of the resource that this schedule belongs + to. Required. "Pool" + "sourceUri": "str", # The URI of the resource that this schedule belongs to. + 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" + "uri": "str" # The unique URI of the schedule. Required. + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_schedule_request( + project_name=project_name, + pool_name=pool_name, + schedule_name=schedule_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def list_all_dev_boxes( + self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists Dev Boxes that the caller has access to in the DevCenter. + + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "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 {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_list_all_dev_boxes_request( + filter=filter, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_all_dev_boxes_by_user( + self, user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable[JSON]: + """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 + authentication context. Default value is "me". + :type user_id: str + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "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 {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_list_all_dev_boxes_by_user_request( + user_id=user_id, + filter=filter, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_dev_boxes( + self, + project_name: str, + user_id: str = "me", + *, + filter: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable[JSON]: + """Lists Dev Boxes in the project for a particular user. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "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 {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_list_dev_boxes_request( + project_name=project_name, + user_id=user_id, + filter=filter, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: + """Gets a Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "user": "str" # Optional. The AAD object id of the user this Dev Box is + assigned to. + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_get_dev_box_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + def _create_dev_box_initial( + self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any + ) -> JSON: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _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[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_dev_boxes_create_dev_box_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def begin_create_dev_box( + self, + project_name: str, + dev_box_name: str, + body: JSON, + user_id: str = "me", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[JSON]: + """Creates or replaces a Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param body: Represents a environment. Required. + :type body: JSON + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "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 == { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "user": "str" # Optional. The AAD object id of the user this Dev Box is + assigned to. + } + """ + + @overload + def begin_create_dev_box( + self, + project_name: str, + dev_box_name: str, + body: IO, + user_id: str = "me", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[JSON]: + """Creates or replaces a Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param body: Represents a environment. Required. + :type body: IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200, 201 + response == { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "user": "str" # Optional. The AAD object id of the user this Dev Box is + assigned to. + } + """ + + @distributed_trace + def begin_create_dev_box( + self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any + ) -> LROPoller[JSON]: + """Creates or replaces a Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param body: Represents a environment. Is either a JSON type or a IO type. Required. + :type body: JSON or IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "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 == { + "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", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "hardwareProfile": { + "memoryGB": 0, # Optional. The amount of memory available for the + Dev Box. + "skuName": "str", # Optional. The name of the SKU. + "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. + "name": "str", # Optional. Display name for the Dev Box. + "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. + "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). + "uri": "str", # Optional. The unique URI of the dev box. + "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[JSON] = 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) + if cont_token is None: + raw_result = self._create_dev_box_initial( + project_name=project_name, + dev_box_name=dev_box_name, + body=body, + user_id=user_id, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling( + lro_delay, + lro_options={"final-state-via": "original-uri"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _delete_dev_box_initial( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + ) -> Optional[JSON]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_dev_boxes_delete_dev_box_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 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) + + deserialized = None + response_headers = {} + if response.status_code == 202: + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete_dev_box( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + ) -> LROPoller[JSON]: + """Deletes a Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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[JSON] = 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) + if cont_token is None: + raw_result = self._delete_dev_box_initial( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling( + lro_delay, + lro_options={"final-state-via": "operation-location"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_start_dev_box_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + 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) + + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def begin_start_dev_box( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + ) -> LROPoller[JSON]: + """Starts a Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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[JSON] = 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) + if cont_token is None: + raw_result = self._start_dev_box_initial( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling( + lro_delay, + lro_options={"final-state-via": "operation-location"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _stop_dev_box_initial( + self, + project_name: str, + dev_box_name: str, + user_id: str = "me", + *, + hibernate: Optional[bool] = None, + **kwargs: Any + ) -> JSON: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_stop_dev_box_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + hibernate=hibernate, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + 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) + + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + + if response.content: deserialized = response.json() else: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_all_dev_boxes( - self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists Dev Boxes that the caller has access to in the DevCenter. + def begin_stop_dev_box( + self, + project_name: str, + dev_box_name: str, + user_id: str = "me", + *, + hibernate: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[JSON]: + """Stops a Dev Box. - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword hibernate: Optional parameter to hibernate the dev box. Default value is None. + :paramtype hibernate: bool + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 + # response body for status code(s): 202 response == { - "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. + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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[JSON] = 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) + if cont_token is None: + raw_result = self._stop_dev_box_initial( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + hibernate=hibernate, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling( + lro_delay, + lro_options={"final-state-via": "operation-location"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + def _restart_dev_box_initial( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + ) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2085,163 +4993,158 @@ def list_all_dev_boxes( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - request = build_dev_center_list_all_dev_boxes_request( - filter=filter, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + cls: ClsType[JSON] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request = build_dev_boxes_restart_dev_box_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + response = pipeline_response.http_response - def get_next(next_link=None): - request = prepare_request(next_link) + if response.status_code not in [202]: + 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) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - 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) + if response.content: + deserialized = response.json() + else: + deserialized = None - return pipeline_response + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return ItemPaged(get_next, extract_data) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_all_dev_boxes_by_user( - self, user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists Dev Boxes in the Dev Center for a particular user. + def begin_restart_dev_box( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + ) -> LROPoller[JSON]: + """Restarts a Dev Box. + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 + # response body for status code(s): 202 response == { - "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. + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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[JSON] = 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) + if cont_token is None: + raw_result = self._restart_dev_box_initial( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + 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") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling( + lro_delay, + lro_options={"final-state-via": "operation-location"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2250,103 +5153,181 @@ def list_all_dev_boxes_by_user( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - request = build_dev_center_list_all_dev_boxes_by_user_request( - user_id=user_id, - filter=filter, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + cls: ClsType[JSON] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request = build_dev_boxes_repair_dev_box_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + 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) + + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore - return request + @distributed_trace + def begin_repair_dev_box( + self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + ) -> LROPoller[JSON]: + """Attempts automated repair steps to resolve common problems on a Dev Box. The Dev Box may + restart during this operation. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + Example: + .. code-block:: python - def get_next(next_link=None): - request = prepare_request(next_link) + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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 {} - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + cls: ClsType[JSON] = 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) + if cont_token is None: + raw_result = self._repair_dev_box_initial( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + 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") + ) -class DevBoxesOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.DevCenterClient`'s - :attr:`dev_boxes` attribute. - """ + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling( + lro_delay, + lro_options={"final-state-via": "operation-location"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_pools( - self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + def list_customization_groups( + self, + project_name: str, + dev_box_name: str, + user_id: str = "me", + *, + include: Optional[List[str]] = None, + **kwargs: Any ) -> Iterable[JSON]: - """Lists available pools. + """Lists customization groups on the Dev Box. Listed customization groups exclude task information + unless specified via the include parameter. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword include: Optional query parameter to specify what properties should be included in the + response. Default value is None. + :paramtype include: list[str] :return: An iterator like instance of JSON object :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: @@ -2356,51 +5337,34 @@ def list_pools( # 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. - "uri": "str", # The unique URI of the pool. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". } - } + ], + "uri": "str" # Optional. The unique URI of the customization group. } """ _headers = kwargs.pop("headers", {}) or {} @@ -2419,10 +5383,11 @@ def list_pools( def prepare_request(next_link=None): if not next_link: - request = build_dev_boxes_list_pools_request( + _request = build_dev_boxes_list_customization_groups_request( project_name=project_name, - top=top, - filter=filter, + dev_box_name=dev_box_name, + user_id=user_id, + include=include, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2432,7 +5397,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -2444,7 +5409,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -2452,9 +5417,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -2464,86 +5429,76 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: - """Gets a pool. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param pool_name: The name of a pool of Dev Boxes. Required. - :type pool_name: str - :return: JSON object - :rtype: JSON - :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. - "uri": "str", # The unique URI of the pool. Required. - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_customization_group( + self, project_name: str, dev_box_name: str, customization_group_name: str, user_id: str = "me", **kwargs: Any + ) -> JSON: + """Gets a customization group. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". } - } + ], + "uri": "str" # Optional. The unique URI of the customization group. } """ error_map = { @@ -2559,9 +5514,11 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_get_pool_request( + _request = build_dev_boxes_get_customization_group_request( project_name=project_name, - pool_name=pool_name, + dev_box_name=dev_box_name, + customization_group_name=customization_group_name, + user_id=user_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2569,11 +5526,11 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2590,53 +5547,275 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore - @distributed_trace - def list_schedules_by_project( - self, project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists all schedules within a project that are configured by your project administrator. + @overload + def create_customization_group( + self, + project_name: str, + dev_box_name: str, + customization_group_name: str, + body: JSON, + user_id: str = "me", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + """Applies customizations to the Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param body: Represents a customization group. Required. + :type body: JSON + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } + # 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. - "sourceType": "str", # The type of the resource that this schedule belongs - to. Required. "Pool" - "sourceUri": "str", # The URI of the resource that this schedule belongs to. - 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" - "uri": "str" # The unique URI of the schedule. Required. + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + @overload + def create_customization_group( + self, + project_name: str, + dev_box_name: str, + customization_group_name: str, + body: IO, + user_id: str = "me", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + """Applies customizations to the Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param body: Represents a customization group. Required. + :type body: IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } + """ + + @distributed_trace + def create_customization_group( + self, + project_name: str, + dev_box_name: str, + customization_group_name: str, + body: Union[JSON, IO], + user_id: str = "me", + **kwargs: Any + ) -> JSON: + """Applies customizations to the Dev Box. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param body: Represents a customization group. Is either a JSON type or a IO type. Required. + :type body: JSON or IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } + # response body for status code(s): 200 + response == { + "endTime": "2020-02-20 00:00:00", # Optional. End time of the customization + group. + "name": "str", # Optional. Name of the customization group. + "startTime": "2020-02-20 00:00:00", # Optional. Start time of the + customization group. + "status": "str", # Optional. Status of the customization group. Known values + are: "NotStarted", "Running", "Succeeded", "Failed", and "ValidationFailed". + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ], + "uri": "str" # Optional. The unique URI of the customization group. + } + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2645,123 +5824,87 @@ def list_schedules_by_project( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_dev_boxes_list_schedules_by_project_request( - project_name=project_name, - top=top, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[JSON] = kwargs.pop("cls", None) - return request + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _request = build_dev_boxes_create_customization_group_request( + project_name=project_name, + dev_box_name=dev_box_name, + customization_group_name=customization_group_name, + user_id=user_id, + content_type=content_type, + api_version=self._config.api_version, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def get_next(next_link=None): - request = prepare_request(next_link) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + 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) + 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) - return pipeline_response + if response.content: + deserialized = response.json() + else: + deserialized = None - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_schedules_by_pool( + def get_customization_task_log( self, project_name: str, - pool_name: str, - *, - top: Optional[int] = None, - filter: Optional[str] = None, + dev_box_name: str, + customization_group_name: str, + customization_task_id: str, + user_id: str = "me", **kwargs: Any - ) -> Iterable[JSON]: - """Lists all schedules within a pool that are configured by your project administrator. + ) -> Iterator[bytes]: + """Gets the log for a customization task. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param pool_name: The name of a pool of Dev Boxes. Required. - :type pool_name: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param customization_group_name: A customization group name. Required. + :type customization_group_name: str + :param customization_task_id: A customization task ID. Required. + :type customization_task_id: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: Iterator of the response bytes + :rtype: Iterator[bytes] :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. - "sourceType": "str", # The type of the resource that this schedule belongs - to. Required. "Pool" - "sourceUri": "str", # The URI of the resource that this schedule belongs to. - 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" - "uri": "str" # The unique URI of the schedule. Required. - } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2770,83 +5913,57 @@ def list_schedules_by_pool( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_dev_boxes_list_schedules_by_pool_request( - project_name=project_name, - pool_name=pool_name, - top=top, - filter=filter, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - return request + _request = build_dev_boxes_get_customization_task_log_request( + project_name=project_name, + dev_box_name=dev_box_name, + customization_group_name=customization_group_name, + customization_task_id=customization_task_id, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - 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) - 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) + deserialized = response.iter_bytes() - return pipeline_response + if cls: + return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) # type: ignore - return ItemPaged(get_next, extract_data) + return cast(Iterator[bytes], deserialized) # type: ignore @distributed_trace - def get_schedule_by_pool(self, project_name: str, pool_name: str, schedule_name: str, **kwargs: Any) -> JSON: - """Gets a schedule. + def get_remote_connection(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: + """Gets RDP Connection info. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param pool_name: The name of a pool of Dev Boxes. Required. - :type pool_name: str - :param schedule_name: The name of a schedule. Required. - :type schedule_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -2856,20 +5973,9 @@ def get_schedule_by_pool(self, project_name: str, pool_name: str, schedule_name: # 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. - "sourceType": "str", # The type of the resource that this schedule belongs - to. Required. "Pool" - "sourceUri": "str", # The URI of the resource that this schedule belongs to. - 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" - "uri": "str" # The unique URI of the schedule. Required. + "rdpConnectionUrl": "str", # Optional. Link to open a Remote Desktop + session. + "webUrl": "str" # Optional. URL to open a browser based RDP session. } """ error_map = { @@ -2885,10 +5991,10 @@ def get_schedule_by_pool(self, project_name: str, pool_name: str, schedule_name: cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_get_schedule_by_pool_request( + _request = build_dev_boxes_get_remote_connection_request( project_name=project_name, - pool_name=pool_name, - schedule_name=schedule_name, + dev_box_name=dev_box_name, + user_id=user_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2896,11 +6002,11 @@ def get_schedule_by_pool(self, project_name: str, pool_name: str, schedule_name: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2917,103 +6023,45 @@ def get_schedule_by_pool(self, project_name: str, pool_name: str, schedule_name: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_dev_boxes_by_user( - self, - project_name: str, - user_id: str = "me", - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable[JSON]: - """Lists Dev Boxes in the project for a particular user. + def list_actions(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> Iterable[JSON]: + """Lists actions on a Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "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", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :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. + "sourceType": "str", # The type of the resource which triggered this action. + Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this action. + Required. + "uri": "str", # The unique URI for the Dev Box action. Required. + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that + the action could occur (UTC). } """ _headers = kwargs.pop("headers", {}) or {} @@ -3032,11 +6080,10 @@ def list_dev_boxes_by_user( def prepare_request(next_link=None): if not next_link: - request = build_dev_boxes_list_dev_boxes_by_user_request( + _request = build_dev_boxes_list_actions_request( project_name=project_name, + dev_box_name=dev_box_name, user_id=user_id, - filter=filter, - top=top, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3046,7 +6093,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3058,7 +6105,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3066,9 +6113,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3078,11 +6125,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3097,13 +6144,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_dev_box_by_user(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: - """Gets a Dev Box. + def get_action( + self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any + ) -> JSON: + """Gets an action. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str + :param action_name: The name of an action that will take place on a Dev Box. Required. + :type action_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str @@ -3116,68 +6167,21 @@ def get_dev_box_by_user(self, project_name: str, dev_box_name: str, user_id: str # response body for status code(s): 200 response == { - "poolName": "str", # The name of the Dev Box pool this machine belongs to. + "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. - "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", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } + "sourceType": "str", # The type of the resource which triggered this action. + Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this action. + Required. + "uri": "str", # The unique URI for the Dev Box action. Required. + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that + the action could occur (UTC). } """ error_map = { @@ -3193,9 +6197,10 @@ def get_dev_box_by_user(self, project_name: str, dev_box_name: str, user_id: str cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_get_dev_box_by_user_request( + _request = build_dev_boxes_get_action_request( project_name=project_name, dev_box_name=dev_box_name, + action_name=action_name, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -3204,11 +6209,11 @@ def get_dev_box_by_user(self, project_name: str, dev_box_name: str, user_id: str path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3225,13 +6230,29 @@ def get_dev_box_by_user(self, project_name: str, dev_box_name: str, user_id: str deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore - def _create_dev_box_initial( - self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any - ) -> JSON: + @distributed_trace + def skip_action( # pylint: disable=inconsistent-return-statements + self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any + ) -> None: + """Skips an occurrence of an action. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param action_name: The name of an action that will take place on a Dev Box. Required. + :type action_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3240,179 +6261,188 @@ def _create_dev_box_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_dev_boxes_create_dev_box_request( + _request = build_dev_boxes_skip_action_request( project_name=project_name, dev_box_name=dev_box_name, + action_name=action_name, user_id=user_id, - content_type=content_type, api_version=self._config.api_version, - json=_json, - content=_content, headers=_headers, params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: + 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) - if response.status_code == 200: - if response.content: - deserialized = response.json() - else: - deserialized = None + if cls: + return cls(pipeline_response, None, {}) # type: ignore - if response.status_code == 201: - if response.content: - deserialized = response.json() - else: - deserialized = None + @distributed_trace + def delay_action( + self, + project_name: str, + dev_box_name: str, + action_name: str, + user_id: str = "me", + *, + until: datetime.datetime, + **kwargs: Any + ) -> JSON: + """Delays the occurrence of an action. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param dev_box_name: The name of a Dev Box. Required. + :type dev_box_name: str + :param action_name: The name of an action that will take place on a Dev Box. Required. + :type action_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword until: The time to delay the Dev Box action or actions until. Required. + :paramtype until: ~datetime.datetime + :return: JSON object + :rtype: JSON + :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. + "sourceType": "str", # The type of the resource which triggered this action. + Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this action. + Required. + "uri": "str", # The unique URI for the Dev Box 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_dev_boxes_delay_action_request( + project_name=project_name, + dev_box_name=dev_box_name, + action_name=action_name, + user_id=user_id, + until=until, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore return cast(JSON, deserialized) # type: ignore - @overload - def begin_create_dev_box( - self, - project_name: str, - dev_box_name: str, - body: JSON, - user_id: str = "me", - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[JSON]: - """Creates or replaces a Dev Box. + @distributed_trace + def delay_all_actions( + self, project_name: str, dev_box_name: str, user_id: str = "me", *, until: datetime.datetime, **kwargs: Any + ) -> Iterable[JSON]: + """Delays all actions. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :param body: Represents a environment. Required. - :type body: JSON :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] + :keyword until: The time to delay the Dev Box action or actions until. Required. + :paramtype until: ~datetime.datetime + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # JSON input template you can fill out and use as your body input. - body = { - "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", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "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). - "uri": "str", # Optional. The unique URI of the dev box. - "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 body for status code(s): 200 response == { - "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. + "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". + "uri": "str", # The unique URI of the action. Required. + "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. + "sourceType": "str", # The type of the resource which triggered this + action. Required. Known values are: "Pool" and "Schedule". + "sourceUri": "str", # The URI of the resource which triggered this + action. Required. + "uri": "str", # The unique URI for the Dev Box 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", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -3423,102 +6453,135 @@ def begin_create_dev_box( ], "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. - }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "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). - "uri": "str", # Optional. The unique URI of the dev box. - "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 {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_delay_all_actions_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + until=until, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) - @overload - def begin_create_dev_box( + @distributed_trace + def list_operations( self, project_name: str, dev_box_name: str, - body: IO, user_id: str = "me", *, - content_type: str = "application/json", + top: Optional[int] = None, + filter: Optional[str] = None, **kwargs: Any - ) -> LROPoller[JSON]: - """Creates or replaces a Dev Box. + ) -> Iterable[JSON]: + """Lists operations on the Dev Box which have occurred within the past 90 days. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :param body: Represents a environment. Required. - :type body: IO :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": - # response body for status code(s): 200, 201 - response == { - "poolName": "str", # The name of the Dev Box pool this machine belongs to. + # JSON input template for discriminator value "Repair": + dev_box_operation = { + "kind": "Repair", + "operationId": "str", # Unique identifier for the Dev Box operation. 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. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -3530,94 +6593,220 @@ def begin_create_dev_box( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "vCPUs": 0 # Optional. The number of vCPUs available for the Dev - Box. + "result": { + "code": "str", # Optional. The result code associated with the + repair operation. + "message": "str", # Optional. The result message associated with the + repair operation. + "repairOutcome": "str" # Optional. The outcome of the repair + operation. Known values are: "FixApplied", "IssuesDetected", and + "NoIssuesDetected". }, - "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. + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } + + # JSON input template for discriminator value "Restart": + dev_box_operation = { + "kind": "Restart", + "operationId": "str", # Unique identifier for the Dev Box operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. }, - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } + + # JSON input template for discriminator value "Start": + dev_box_operation = { + "kind": "Start", + "operationId": "str", # Unique identifier for the Dev Box operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } + + # JSON input template for discriminator value "Stop": + dev_box_operation = { + "kind": "Stop", + "operationId": "str", # Unique identifier for the Dev Box operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. } + + # response body for status code(s): 200 + response == dev_box_operation """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_dev_boxes_list_operations_request( + project_name=project_name, + dev_box_name=dev_box_name, + user_id=user_id, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_create_dev_box( - self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any - ) -> LROPoller[JSON]: - """Creates or replaces a Dev Box. + def get_operation( + self, project_name: str, dev_box_name: str, operation_id: str, user_id: str = "me", **kwargs: Any + ) -> JSON: + """Gets an operation on a Dev Box. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param dev_box_name: The name of a Dev Box. Required. :type dev_box_name: str - :param body: Represents a environment. Is either a JSON type or a IO type. Required. - :type body: JSON or IO + :param operation_id: The id of the operation on a Dev Box. Required. + :type operation_id: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": - # JSON input template you can fill out and use as your body input. - body = { - "poolName": "str", # The name of the Dev Box pool this machine belongs to. + # JSON input template for discriminator value "Repair": + dev_box_operation = { + "kind": "Repair", + "operationId": "str", # Unique identifier for the Dev Box operation. 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. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -3629,61 +6818,31 @@ def begin_create_dev_box( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "storageProfile": { - "osDisk": { - "diskSizeGB": 0 # Optional. The size of the OS Disk in - gigabytes. - } + "result": { + "code": "str", # Optional. The result code associated with the + repair operation. + "message": "str", # Optional. The result message associated with the + repair operation. + "repairOutcome": "str" # Optional. The outcome of the repair + operation. Known values are: "FixApplied", "IssuesDetected", and + "NoIssuesDetected". }, - "uniqueId": "str", # Optional. A unique identifier for the Dev Box. This is - a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. } - # response body for status code(s): 200, 201 - response == { - "poolName": "str", # The name of the Dev Box pool this machine belongs to. + # JSON input template for discriminator value "Restart": + dev_box_operation = { + "kind": "Restart", + "operationId": "str", # Unique identifier for the Dev Box operation. 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. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -3695,115 +6854,67 @@ def begin_create_dev_box( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, - "hardwareProfile": { - "memoryGB": 0, # Optional. The amount of memory available for the - Dev Box. - "skuName": "str", # Optional. The name of the SKU. - "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. - "name": "str", # Optional. Display name for the Dev Box. - "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. - "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). - "uri": "str", # Optional. The unique URI of the dev box. - "user": "str" # Optional. The AAD object id of the user this Dev Box is - assigned to. + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. } - """ - _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[JSON] = 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) - if cont_token is None: - raw_result = self._create_dev_box_initial( - project_name=project_name, - dev_box_name=dev_box_name, - body=body, - user_id=user_id, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + # JSON input template for discriminator value "Start": + dev_box_operation = { + "kind": "Start", + "operationId": "str", # Unique identifier for the Dev Box operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, - LROBasePolling( - lro_delay, - lro_options={"final-state-via": "original-uri"}, - path_format_arguments=path_format_arguments, - **kwargs - ), - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + # JSON input template for discriminator value "Stop": + dev_box_operation = { + "kind": "Stop", + "operationId": "str", # Unique identifier for the Dev Box operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the Dev Box operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } - def _delete_dev_box_initial( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> Optional[JSON]: + # response body for status code(s): 200 + response == dev_box_operation + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3815,11 +6926,12 @@ 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[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_delete_dev_box_request( + _request = build_dev_boxes_get_operation_request( project_name=project_name, dev_box_name=dev_box_name, + operation_id=operation_id, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -3828,146 +6940,275 @@ def _delete_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202, 204]: + 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) - deserialized = None - response_headers = {} - if response.status_code == 202: - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + - return deserialized +class ProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.DevCenterClient`'s + :attr:`projects` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def begin_delete_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> LROPoller[JSON]: - """Deletes a Dev Box. + def list_customization_task_definitions( + self, project_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists all customization tasks available to the project. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 202 + # response body for status code(s): 200 response == { - "status": "str", # Provisioning state of the resource. Required. - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # Optional. The error code. - "message": "str" # Optional. The error message. + "catalogName": "str", # Name of the catalog that the task belongs to. + Required. + "name": "str", # Full name of the task: {catalogName}/{taskName}. Required. + "description": "str", # Optional. Description of the task. + "parameters": { + "str": { + "type": "str", # Type of the parameter. Required. Known + values are: "string", "number", and "boolean". + "allowed": [ + "str" # Optional. Allowed values for the parameter. + ], + "default": "str", # Optional. Default value for the + parameter. + "description": "str", # Optional. Description of the + parameter. + "required": bool # Optional. Whether or not the parameter is + required. + } }, - "id": "str", # Optional. Fully qualified ID for the operation status. - "name": "str", # Optional. The operation id name. - "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. + "uri": "str" # Optional. The unique URI of the customization task. } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[JSON] = 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) - if cont_token is None: - raw_result = self._delete_dev_box_initial( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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") - ) + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_projects_list_customization_task_definitions_request( + project_name=project_name, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if response.content: - deserialized = response.json() else: - deserialized = None + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_customization_task_definition( + self, + project_name: str, + catalog_name: str, + task_name: str, + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> JSON: + """Gets a customization task. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param catalog_name: The name of the catalog. Required. + :type catalog_name: str + :param task_name: A customization task name. Required. + :type task_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "catalogName": "str", # Name of the catalog that the task belongs to. + Required. + "name": "str", # Full name of the task: {catalogName}/{taskName}. Required. + "description": "str", # Optional. Description of the task. + "parameters": { + "str": { + "type": "str", # Type of the parameter. Required. Known + values are: "string", "number", and "boolean". + "allowed": [ + "str" # Optional. Allowed values for the parameter. + ], + "default": "str", # Optional. Default value for the + parameter. + "description": "str", # Optional. Description of the + parameter. + "required": bool # Optional. Whether or not the parameter is + required. + } + }, + "uri": "str" # Optional. The unique URI of the customization task. + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_projects_get_customization_task_definition_request( + project_name=project_name, + catalog_name=catalog_name, + task_name=task_name, + top=top, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, - LROBasePolling( - lro_delay, - lro_options={"final-state-via": "operation-location"}, - path_format_arguments=path_format_arguments, - **kwargs - ), - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) + 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) + + if response.content: + deserialized = response.json() else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + deserialized = None - def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + def _validate_customization_tasks_initial(self, project_name: str, body: Union[JSON, IO], **kwargs: Any) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3976,27 +7217,37 @@ def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _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[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_start_dev_box_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_projects_validate_customization_tasks_request( project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4007,32 +7258,29 @@ def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: 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")) - if response.content: deserialized = response.json() else: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore - @distributed_trace - def begin_start_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any + @overload + def begin_validate_customization_tasks( + self, project_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[JSON]: - """Starts a Dev Box. + """Validates a list of customization tasks. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str + :param body: Customization tasks to validate. Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal @@ -4047,6 +7295,30 @@ def begin_start_dev_box( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ] + } + # response body for status code(s): 202 response == { "status": "str", # Provisioning state of the resource. Required. @@ -4062,154 +7334,147 @@ def begin_start_dev_box( "properties": {}, # Optional. Custom operation properties, populated only for a successful operation. "resourceId": "str", # Optional. The id of the resource. + "result": { + "validationResult": "str", # Outcome of validation. Required. Known + values are: "Succeeded" and "Failed". + "errors": [ + { + "details": [ + { + "code": "str", # An identifier for + the error. Codes are invariant and are intended to be + consumed programmatically. Required. + "message": "str" # A message + describing the error, intended to be suitable for display in + a user interface. Required. + } + ], + "target": { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display + name to help differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # + Optional. End time of the task. + "id": "str", # Optional. ID of the task + instance. + "logUri": "str", # Optional. The unique URI + for retrieving the task logs. + "parameters": { + "str": "str" # Optional. Parameters + for the task. + }, + "startTime": "2020-02-20 00:00:00", # + Optional. Start time of the task. + "status": "str" # Optional. Status of the + task. Known values are: "NotStarted", "Running", "Succeeded", + "FailedValidation", "Skipped", "TimedOut", and "Failed". + } + } + ] + }, "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[JSON] = 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) - if cont_token is None: - raw_result = self._start_dev_box_initial( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, - LROBasePolling( - lro_delay, - lro_options={"final-state-via": "operation-location"}, - path_format_arguments=path_format_arguments, - **kwargs - ), - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _stop_dev_box_initial( - self, - project_name: str, - dev_box_name: str, - user_id: str = "me", - *, - hibernate: Optional[bool] = None, - **kwargs: Any - ) -> JSON: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - request = build_dev_boxes_stop_dev_box_request( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - hibernate=hibernate, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - if response.status_code not in [202]: - 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) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + @overload + def begin_validate_customization_tasks( + self, project_name: str, body: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[JSON]: + """Validates a list of customization tasks. - if response.content: - deserialized = response.json() - else: - deserialized = None + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param body: Customization tasks to validate. Required. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + Example: + .. code-block:: python - return cast(JSON, deserialized) + # response body for status code(s): 202 + response == { + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "error": { + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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. + "result": { + "validationResult": "str", # Outcome of validation. Required. Known + values are: "Succeeded" and "Failed". + "errors": [ + { + "details": [ + { + "code": "str", # An identifier for + the error. Codes are invariant and are intended to be + consumed programmatically. Required. + "message": "str" # A message + describing the error, intended to be suitable for display in + a user interface. Required. + } + ], + "target": { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display + name to help differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # + Optional. End time of the task. + "id": "str", # Optional. ID of the task + instance. + "logUri": "str", # Optional. The unique URI + for retrieving the task logs. + "parameters": { + "str": "str" # Optional. Parameters + for the task. + }, + "startTime": "2020-02-20 00:00:00", # + Optional. Start time of the task. + "status": "str" # Optional. Status of the + task. Known values are: "NotStarted", "Running", "Succeeded", + "FailedValidation", "Skipped", "TimedOut", and "Failed". + } + } + ] + }, + "startTime": "2020-02-20 00:00:00" # Optional. The start time of the + operation. + } + """ @distributed_trace - def begin_stop_dev_box( - self, - project_name: str, - dev_box_name: str, - user_id: str = "me", - *, - hibernate: Optional[bool] = None, - **kwargs: Any + def begin_validate_customization_tasks( + self, project_name: str, body: Union[JSON, IO], **kwargs: Any ) -> LROPoller[JSON]: - """Stops a Dev Box. + """Validates a list of customization tasks. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword hibernate: Optional parameter to hibernate the dev box. Default value is None. - :paramtype hibernate: bool + :param body: Customization tasks to validate. Is either a JSON type or a IO type. Required. + :type body: JSON or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal @@ -4224,6 +7489,30 @@ def begin_stop_dev_box( Example: .. code-block:: python + # JSON input template you can fill out and use as your body input. + body = { + "tasks": [ + { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display name to help + differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # Optional. End time of + the task. + "id": "str", # Optional. ID of the task instance. + "logUri": "str", # Optional. The unique URI for retrieving + the task logs. + "parameters": { + "str": "str" # Optional. Parameters for the task. + }, + "startTime": "2020-02-20 00:00:00", # Optional. Start time + of the task. + "status": "str" # Optional. Status of the task. Known values + are: "NotStarted", "Running", "Succeeded", "FailedValidation", "Skipped", + "TimedOut", and "Failed". + } + ] + } + # response body for status code(s): 202 response == { "status": "str", # Provisioning state of the resource. Required. @@ -4239,23 +7528,61 @@ def begin_stop_dev_box( "properties": {}, # Optional. Custom operation properties, populated only for a successful operation. "resourceId": "str", # Optional. The id of the resource. + "result": { + "validationResult": "str", # Outcome of validation. Required. Known + values are: "Succeeded" and "Failed". + "errors": [ + { + "details": [ + { + "code": "str", # An identifier for + the error. Codes are invariant and are intended to be + consumed programmatically. Required. + "message": "str" # A message + describing the error, intended to be suitable for display in + a user interface. Required. + } + ], + "target": { + "name": "str", # Name of the task. Required. + "displayName": "str", # Optional. Display + name to help differentiate multiple instances of the same task. + "endTime": "2020-02-20 00:00:00", # + Optional. End time of the task. + "id": "str", # Optional. ID of the task + instance. + "logUri": "str", # Optional. The unique URI + for retrieving the task logs. + "parameters": { + "str": "str" # Optional. Parameters + for the task. + }, + "startTime": "2020-02-20 00:00:00", # + Optional. Start time of the task. + "status": "str" # Optional. Status of the + task. Known values are: "NotStarted", "Running", "Succeeded", + "FailedValidation", "Skipped", "TimedOut", and "Failed". + } + } + ] + }, "startTime": "2020-02-20 00:00:00" # Optional. The start time of the operation. } """ - _headers = kwargs.pop("headers", {}) or {} + _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[JSON] = 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) if cont_token is None: - raw_result = self._stop_dev_box_initial( + raw_result = self._validate_customization_tasks_initial( project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - hibernate=hibernate, + body=body, + content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, @@ -4264,18 +7591,13 @@ def begin_stop_dev_box( 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") - ) - if response.content: deserialized = response.json() else: deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized path_format_arguments = { @@ -4297,17 +7619,87 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[JSON].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + +class DeploymentEnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.DevCenterClient`'s + :attr:`deployment_environments` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_all_environments(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> Iterable[JSON]: + """Lists the environments for a project. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) - def _restart_dev_box_initial( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4316,158 +7708,257 @@ def _restart_dev_box_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployment_environments_list_all_environments_request( + project_name=project_name, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_environments( + self, project_name: str, user_id: str = "me", *, top: Optional[int] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists the environments for a project and user. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_restart_dev_box_request( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - request.url = self._client.format_url(request.url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) + def prepare_request(next_link=None): + if not next_link: - response = pipeline_response.http_response + _request = build_deployment_environments_list_environments_request( + project_name=project_name, + user_id=user_id, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if response.status_code not in [202]: - 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) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + return _request - if response.content: - deserialized = response.json() - else: - deserialized = None + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) + return pipeline_response - return cast(JSON, deserialized) + return ItemPaged(get_next, extract_data) @distributed_trace - def begin_restart_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> LROPoller[JSON]: - """Restarts a Dev Box. + def get_environment(self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any) -> JSON: + """Gets an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 202 + # response body for status code(s): 200 response == { - "status": "str", # Provisioning state of the resource. Required. - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { - "code": "str", # Optional. The error code. - "message": "str" # Optional. The error message. + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. }, - "id": "str", # Optional. Fully qualified ID for the operation status. - "name": "str", # Optional. The operation id name. - "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. + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = 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) - if cont_token is None: - raw_result = self._restart_dev_box_initial( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, - LROBasePolling( - lro_delay, - lro_options={"final-state-via": "operation-location"}, - path_format_arguments=path_format_arguments, - **kwargs - ), - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4481,9 +7972,9 @@ def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_repair_dev_box_request( + _request = build_deployment_environments_get_environment_request( project_name=project_name, - dev_box_name=dev_box_name, + environment_name=environment_name, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -4492,167 +7983,34 @@ def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [202]: + 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) - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) - - return cast(JSON, deserialized) - - @distributed_trace - def begin_repair_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> LROPoller[JSON]: - """Attempts automated repair steps to resolve common problems on a Dev Box. The Dev Box may - restart during this operation. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 202 - response == { - "status": "str", # Provisioning state of the resource. Required. - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. - "error": { - "code": "str", # Optional. The error code. - "message": "str" # Optional. The error message. - }, - "id": "str", # Optional. Fully qualified ID for the operation status. - "name": "str", # Optional. The operation id name. - "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[JSON] = 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) - if cont_token is None: - raw_result = self._repair_dev_box_initial( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, - LROBasePolling( - lro_delay, - lro_options={"final-state-via": "operation-location"}, - path_format_arguments=path_format_arguments, - **kwargs - ), - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_remote_connection(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: - """Gets RDP Connection info. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python + if response.content: + deserialized = response.json() + else: + deserialized = None - # 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. - } - """ + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + def _create_or_update_environment_initial( + self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any + ) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4661,366 +8019,411 @@ def get_remote_connection(self, project_name: str, dev_box_name: str, user_id: s } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _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[JSON] = kwargs.pop("cls", None) - request = build_dev_boxes_get_remote_connection_request( + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body + + _request = build_deployment_environments_create_or_update_environment_request( project_name=project_name, - dev_box_name=dev_box_name, + environment_name=environment_name, user_id=user_id, + content_type=content_type, api_version=self._config.api_version, + json=_json, + content=_content, headers=_headers, params=_params, ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: 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) + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + if response.content: deserialized = response.json() else: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore - @distributed_trace - def list_actions(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> Iterable[JSON]: - """Lists actions on a Dev Box. + @overload + def begin_create_or_update_environment( + self, + project_name: str, + environment_name: str, + body: JSON, + user_id: str = "me", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[JSON]: + """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param body: Represents an environment. Required. + :type body: JSON :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 + # JSON input template you can fill out and use as your body input. + body = { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + + # response body for status code(s): 201 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. - "sourceType": "str", # The type of the resource which triggered this action. - Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this action. - Required. - "uri": "str", # The unique URI for the Dev Box action. Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + @overload + def begin_create_or_update_environment( + self, + project_name: str, + environment_name: str, + body: IO, + user_id: str = "me", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[JSON]: + """Creates or updates an environment. - def prepare_request(next_link=None): - if not next_link: + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param body: Represents an environment. Required. + :type body: IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] + :raises ~azure.core.exceptions.HttpResponseError: - request = build_dev_boxes_list_actions_request( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + Example: + .. code-block:: python - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), + # response body for status code(s): 201 + response == { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) + """ @distributed_trace - def get_action( - self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any - ) -> JSON: - """Gets an action. + def begin_create_or_update_environment( + self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any + ) -> LROPoller[JSON]: + """Creates or updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param action_name: The name of an action that will take place on a Dev Box. Required. - :type action_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param body: Represents an environment. Is either a JSON type or a IO type. Required. + :type body: JSON or IO :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :return: JSON object - :rtype: JSON + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 + # JSON input template you can fill out and use as your body input. + body = { + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + + # response body for status code(s): 201 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. - "sourceType": "str", # The type of the resource which triggered this action. - Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this action. - Required. - "uri": "str", # The unique URI for the Dev Box action. Required. - "next": { - "scheduledTime": "2020-02-20 00:00:00" # The time the action will be - triggered (UTC). Required. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. }, - "suspendedUntil": "2020-02-20 00:00:00" # Optional. The earliest time that - the action could occur (UTC). + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. } """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} + _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[JSON] = 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) + if cont_token is None: + raw_result = self._create_or_update_environment_initial( + project_name=project_name, + environment_name=environment_name, + body=body, + user_id=user_id, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - request = build_dev_boxes_get_action_request( - project_name=project_name, - dev_box_name=dev_box_name, - action_name=action_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - 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) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def skip_action( # pylint: disable=inconsistent-return-statements - self, project_name: str, dev_box_name: str, action_name: str, user_id: str = "me", **kwargs: Any - ) -> None: - """Skips an occurrence of an action. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param action_name: The name of an action that will take place on a Dev Box. Required. - :type action_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + 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") + ) - cls: ClsType[None] = kwargs.pop("cls", None) + if response.content: + deserialized = response.json() + else: + deserialized = None + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized - request = build_dev_boxes_skip_action_request( - project_name=project_name, - dev_box_name=dev_box_name, - action_name=action_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - 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) - - if cls: - return cls(pipeline_response, None, {}) - - @distributed_trace - def delay_action( - self, - project_name: str, - dev_box_name: str, - action_name: str, - user_id: str = "me", - *, - until: datetime.datetime, - **kwargs: Any - ) -> JSON: - """Delays the occurrence of an action. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param action_name: The name of an action that will take place on a Dev Box. Required. - :type action_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword until: The time to delay the Dev Box action or actions until. Required. - :paramtype until: ~datetime.datetime - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - Example: - .. code-block:: python + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling( + lro_delay, + lro_options={"final-state-via": "original-uri"}, + path_format_arguments=path_format_arguments, + **kwargs + ), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - # 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. - "sourceType": "str", # The type of the resource which triggered this action. - Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this action. - Required. - "uri": "str", # The unique URI for the Dev Box 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). - } - """ + def _delete_environment_initial( + self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any + ) -> Optional[JSON]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5032,14 +8435,12 @@ def delay_action( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[JSON] = kwargs.pop("cls", None) + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - request = build_dev_boxes_delay_action_request( + _request = build_deployment_environments_delete_environment_request( project_name=project_name, - dev_box_name=dev_box_name, - action_name=action_name, + environment_name=environment_name, user_id=user_id, - until=until, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5047,341 +8448,160 @@ def delay_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [202, 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) - if response.content: - deserialized = response.json() - else: - deserialized = None + deserialized = None + response_headers = {} + if response.status_code == 202: + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return cast(JSON, deserialized) + return deserialized # type: ignore @distributed_trace - def delay_actions( - self, project_name: str, dev_box_name: str, user_id: str = "me", *, until: datetime.datetime, **kwargs: Any - ) -> Iterable[JSON]: - """Delays all actions. + def begin_delete_environment( + self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any + ) -> LROPoller[JSON]: + """Deletes an environment and all its associated resources. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword until: The time to delay the Dev Box action or actions until. Required. - :paramtype until: ~datetime.datetime - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns JSON object + :rtype: ~azure.core.polling.LROPoller[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 200 + # response body for status code(s): 202 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". - "uri": "str", # The unique URI of the action. Required. - "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. - "sourceType": "str", # The type of the resource which triggered this - action. Required. Known values are: "Pool" and "Schedule". - "sourceUri": "str", # The URI of the resource which triggered this - action. Required. - "uri": "str", # The unique URI for the Dev Box 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). - }, + "status": "str", # Provisioning state of the resource. Required. + "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - } + "code": "str", # Optional. The error code. + "message": "str" # Optional. The error message. + }, + "id": "str", # Optional. Fully qualified ID for the operation status. + "name": "str", # Optional. The operation id name. + "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[JSON] = 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) + if cont_token is None: + raw_result = self._delete_environment_initial( + project_name=project_name, + environment_name=environment_name, + user_id=user_id, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_dev_boxes_delay_actions_request( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - until=until, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + 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") + ) + if response.content: + deserialized = response.json() else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] + deserialized = None if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized - def get_next(next_link=None): - request = prepare_request(next_link) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) ) - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class DevBoxOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.DevCenterClient`'s - :attr:`dev_box_operations` attribute. - """ - - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[JSON].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list( - self, - project_name: str, - dev_box_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable[JSON]: - """Lists operations on the Dev Box which have occurred within the past 90 days. + def list_catalogs(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> Iterable[JSON]: + """Lists all of the catalogs available for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "Repair": - dev_box_operation = { - "kind": "Repair", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "result": { - "code": "str", # Optional. The result code associated with the - repair operation. - "message": "str", # Optional. The result message associated with the - repair operation. - "repairOutcome": "str" # Optional. The outcome of the repair - operation. Known values are: "FixApplied", "IssuesDetected", and - "NoIssuesDetected". - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - - # JSON input template for discriminator value "Restart": - dev_box_operation = { - "kind": "Restart", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - - # JSON input template for discriminator value "Start": - dev_box_operation = { - "kind": "Start", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - - # JSON input template for discriminator value "Stop": - dev_box_operation = { - "kind": "Stop", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } # response body for status code(s): 200 - response == dev_box_operation + response == { + "name": "str", # Name of the catalog. Required. + "uri": "str" # The unique URI of the catalog. Required. + } """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -5399,212 +8619,88 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_dev_box_operations_list_request( + _request = build_deployment_environments_list_catalogs_request( project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, top=top, - filter=filter, api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, project_name: str, dev_box_name: str, operation_id: str, user_id: str = "me", **kwargs: Any) -> JSON: - """Gets an operation on a Dev Box. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param dev_box_name: The name of a Dev Box. Required. - :type dev_box_name: str - :param operation_id: The id of the operation on a Dev Box. Required. - :type operation_id: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "Repair": - dev_box_operation = { - "kind": "Repair", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "result": { - "code": "str", # Optional. The result code associated with the - repair operation. - "message": "str", # Optional. The result message associated with the - repair operation. - "repairOutcome": "str" # Optional. The outcome of the repair - operation. Known values are: "FixApplied", "IssuesDetected", and - "NoIssuesDetected". - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - - # JSON input template for discriminator value "Restart": - dev_box_operation = { - "kind": "Restart", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - # JSON input template for discriminator value "Start": - dev_box_operation = { - "kind": "Start", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - # JSON input template for discriminator value "Stop": - dev_box_operation = { - "kind": "Stop", - "operationId": "str", # Unique identifier for the Dev Box operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the Dev Box operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JSON: + """Gets the specified catalog within the project. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param catalog_name: The name of the catalog. Required. + :type catalog_name: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python # response body for status code(s): 200 - response == dev_box_operation + response == { + "name": "str", # Name of the catalog. Required. + "uri": "str" # The unique URI of the catalog. Required. + } """ error_map = { 401: ClientAuthenticationError, @@ -5619,11 +8715,9 @@ def get(self, project_name: str, dev_box_name: str, operation_id: str, user_id: cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_dev_box_operations_get_request( + _request = build_deployment_environments_get_catalog_request( project_name=project_name, - dev_box_name=dev_box_name, - operation_id=operation_id, - user_id=user_id, + catalog_name=catalog_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5631,11 +8725,11 @@ def get(self, project_name: str, dev_box_name: str, operation_id: str, user_id: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5652,31 +8746,15 @@ def get(self, project_name: str, dev_box_name: str, operation_id: str, user_id: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) - - return cast(JSON, deserialized) - - -class EnvironmentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.DevCenterClient`'s - :attr:`environments` attribute. - """ + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_environments(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> Iterable[JSON]: - """Lists the environments for a project. + def list_environment_definitions( + self, project_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> Iterable[JSON]: + """Lists all environment definitions available for a project. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str @@ -5693,29 +8771,35 @@ def list_environments(self, project_name: str, *, top: Optional[int] = None, **k # 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. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. - "provisioningState": "str", # Optional. The provisioning state of the - environment. - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "uri": "str", # Optional. The unique URI of the environment. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. + "id": "str", # The ID of the environment definition. Required. + "name": "str", # Name of the environment definition. Required. + "uri": "str", # The unique URI 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 {} @@ -5734,7 +8818,7 @@ def list_environments(self, project_name: str, *, top: Optional[int] = None, **k def prepare_request(next_link=None): if not next_link: - request = build_environments_list_environments_request( + _request = build_deployment_environments_list_environment_definitions_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -5746,7 +8830,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5758,7 +8842,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5766,9 +8850,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5778,11 +8862,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5797,16 +8881,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list_environments_by_user( - self, project_name: str, user_id: str = "me", *, top: Optional[int] = None, **kwargs: Any + def list_environment_definitions_by_catalog( + self, project_name: str, catalog_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> Iterable[JSON]: - """Lists the environments for a project and user. + """Lists all environment definitions available within a catalog. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str + :param catalog_name: The name of the catalog. Required. + :type catalog_name: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int @@ -5820,29 +8903,35 @@ def list_environments_by_user( # 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. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. - "provisioningState": "str", # Optional. The provisioning state of the - environment. - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "uri": "str", # Optional. The unique URI of the environment. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. + "id": "str", # The ID of the environment definition. Required. + "name": "str", # Name of the environment definition. Required. + "uri": "str", # The unique URI 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 {} @@ -5861,9 +8950,9 @@ def list_environments_by_user( def prepare_request(next_link=None): if not next_link: - request = build_environments_list_environments_by_user_request( + _request = build_deployment_environments_list_environment_definitions_by_catalog_request( project_name=project_name, - user_id=user_id, + catalog_name=catalog_name, top=top, api_version=self._config.api_version, headers=_headers, @@ -5874,7 +8963,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5886,7 +8975,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5894,9 +8983,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5906,11 +8995,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5925,18 +9014,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_environment_by_user( - self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any + def get_environment_definition( + self, project_name: str, catalog_name: str, definition_name: str, **kwargs: Any ) -> JSON: - """Gets an environment. + """Get an environment definition from a catalog. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param environment_name: The name of the environment. Required. - :type environment_name: str - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str + :param catalog_name: The name of the catalog. Required. + :type catalog_name: str + :param definition_name: The name of the environment definition. Required. + :type definition_name: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -5947,29 +9035,35 @@ def get_environment_by_user( # 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. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. - "provisioningState": "str", # Optional. The provisioning state of the - environment. - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "uri": "str", # Optional. The unique URI of the environment. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. + "id": "str", # The ID of the environment definition. Required. + "name": "str", # Name of the environment definition. Required. + "uri": "str", # The unique URI 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 = { @@ -5985,10 +9079,10 @@ def get_environment_by_user( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environments_get_environment_by_user_request( + _request = build_deployment_environments_get_environment_definition_request( project_name=project_name, - environment_name=environment_name, - user_id=user_id, + catalog_name=catalog_name, + definition_name=definition_name, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5996,11 +9090,11 @@ def get_environment_by_user( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6017,13 +9111,43 @@ def get_environment_by_user( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + + return cast(JSON, deserialized) # type: ignore - return cast(JSON, deserialized) + @distributed_trace + def list_environment_types(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> Iterable[JSON]: + """Lists all environment types configured for a project. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. + Default value is None. + :paramtype top: int + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[JSON] + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "deploymentTargetId": "str", # The 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". + "uri": "str", # The unique URI of the environment type. Required. + "displayName": "str" # Optional. Display name of the environment type. + } + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) - def _create_or_replace_environment_initial( - self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any - ) -> JSON: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6032,253 +9156,116 @@ def _create_or_replace_environment_initial( } error_map.update(kwargs.pop("error_map", {}) or {}) - _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[JSON] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - request = build_environments_create_or_replace_environment_request( - project_name=project_name, - environment_name=environment_name, - user_id=user_id, - content_type=content_type, - api_version=self._config.api_version, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - 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) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) - - return cast(JSON, deserialized) - - @overload - def begin_create_or_replace_environment( - self, - project_name: str, - environment_name: str, - body: JSON, - user_id: str = "me", - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[JSON]: - """Creates or updates an environment. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param environment_name: The name of the environment. Required. - :type environment_name: str - :param body: Represents an environment. Required. - :type body: JSON - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python + def prepare_request(next_link=None): + if not next_link: - # 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. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. - "provisioningState": "str", # Optional. The provisioning state of the - environment. - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "uri": "str", # Optional. The unique URI of the environment. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. + _request = build_deployment_environments_list_environment_types_request( + project_name=project_name, + top=top, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - # 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. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. - "provisioningState": "str", # Optional. The provisioning state of the - environment. - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "uri": "str", # Optional. The unique URI of the environment. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), } - """ + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + 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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class EnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.developer.devcenter.DevCenterClient`'s + :attr:`environments` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload - def begin_create_or_replace_environment( + def patch_environment( self, project_name: str, environment_name: str, - body: IO, + body: JSON, user_id: str = "me", *, - content_type: str = "application/json", + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> LROPoller[JSON]: - """Creates or updates an environment. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param environment_name: The name of the environment. Required. - :type environment_name: str - :param body: Represents an environment. Required. - :type body: IO - :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the - authentication context. Default value is "me". - :type user_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] - :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. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. - "provisioningState": "str", # Optional. The provisioning state of the - environment. - "resourceGroupId": "str", # Optional. The identifier of the resource group - containing the environment's resources. - "uri": "str", # Optional. The unique URI of the environment. - "user": "str" # Optional. The AAD object id of the owner of this - Environment. - } - """ - - @distributed_trace - def begin_create_or_replace_environment( - self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any - ) -> LROPoller[JSON]: - """Creates or updates an environment. + ) -> JSON: + """Partially updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :param body: Represents an environment. Is either a JSON type or a IO type. Required. - :type body: JSON or IO + :param body: Updatable environment properties. Required. + :type body: JSON :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". :paramtype content_type: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: @@ -6286,10 +9273,12 @@ def begin_create_or_replace_environment( # 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -6301,8 +9290,12 @@ def begin_create_or_replace_environment( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group @@ -6312,12 +9305,14 @@ def begin_create_or_replace_environment( Environment. } - # response body for status code(s): 201 + # 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. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { "code": "str", # An identifier for the error. Codes are invariant and are intended to be consumed programmatically. Required. @@ -6329,270 +9324,182 @@ def begin_create_or_replace_environment( "target": "str" # Optional. The target of the particular error. For example, the name of the property in error. }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. "name": "str", # Optional. Environment name. - "parameters": {}, # Optional. Parameters object for the environment. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. "provisioningState": "str", # Optional. The provisioning state of the environment. "resourceGroupId": "str", # Optional. The identifier of the resource group containing the environment's resources. "uri": "str", # Optional. The unique URI of the environment. "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[JSON] = 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) - if cont_token is None: - raw_result = self._create_or_replace_environment_initial( - project_name=project_name, - environment_name=environment_name, - body=body, - user_id=user_id, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, - LROBasePolling( - lro_delay, - lro_options={"final-state-via": "original-uri"}, - path_format_arguments=path_format_arguments, - **kwargs - ), - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _delete_environment_initial( - self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any - ) -> Optional[JSON]: - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - - request = build_environments_delete_environment_request( - project_name=project_name, - environment_name=environment_name, - user_id=user_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 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) - - deserialized = None - response_headers = {} - if response.status_code == 202: - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - - @distributed_trace - def begin_delete_environment( - self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any - ) -> LROPoller[JSON]: - """Deletes an environment and all its associated resources. + Environment. + } + """ + + @overload + def patch_environment( + self, + project_name: str, + environment_name: str, + body: IO, + user_id: str = "me", + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> JSON: + """Partially updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param environment_name: The name of the environment. Required. :type environment_name: str + :param body: Updatable environment properties. Required. + :type body: IO :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns JSON object - :rtype: ~azure.core.polling.LROPoller[JSON] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # response body for status code(s): 202 + # response body for status code(s): 200 response == { - "status": "str", # Provisioning state of the resource. Required. - "endTime": "2020-02-20 00:00:00", # Optional. The end time of the operation. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. "error": { - "code": "str", # Optional. The error code. - "message": "str" # Optional. The error message. + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. }, - "id": "str", # Optional. Fully qualified ID for the operation status. - "name": "str", # Optional. The operation id name. - "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. + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = 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) - if cont_token is None: - raw_result = self._delete_environment_initial( - project_name=project_name, - environment_name=environment_name, - user_id=user_id, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - 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") - ) - - if response.content: - deserialized = response.json() - else: - deserialized = None - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_catalogs_by_project( - self, project_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists all of the catalogs available for a project. + def patch_environment( + self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any + ) -> JSON: + """Partially updates an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param body: Updatable environment properties. Is either a JSON type or a IO type. Required. + :type body: JSON or IO + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword content_type: Body Parameter content-type. Known values are: + 'application/merge-patch+json'. Default value is None. + :paramtype content_type: str + :return: JSON object + :rtype: JSON :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", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. + } + # response body for status code(s): 200 response == { - "name": "str", # Name of the catalog. Required. - "uri": "str" # The unique URI of the catalog. Required. + "catalogName": "str", # The name of the catalog. Cannot be updated after + creation. Required. + "environmentDefinitionName": "str", # The name of the environment + definition. Cannot be updated after creation. Required. + "environmentType": "str", # The name of the environment type. Cannot be + updated after creation. Required. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "expirationDate": "2020-02-20 00:00:00", # Optional. The time the expiration + date will be triggered (UTC), after which the environment and associated + resources will be deleted. + "name": "str", # Optional. Environment name. + "parameters": {}, # Optional. Parameters object for the environment. Can + only be updated via create or replace. + "provisioningState": "str", # Optional. The provisioning state of the + environment. + "resourceGroupId": "str", # Optional. The identifier of the resource group + containing the environment's resources. + "uri": "str", # Optional. The unique URI of the environment. + "user": "str" # Optional. The AAD object id of the owner of this + Environment. } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6601,79 +9508,69 @@ def list_catalogs_by_project( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - request = build_environments_list_catalogs_by_project_request( - project_name=project_name, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[JSON] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) + content_type = content_type or "application/merge-patch+json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _json = body - return request + _request = build_environments_patch_environment_request( + project_name=project_name, + environment_name=environment_name, + user_id=user_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - 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) - 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) + if response.content: + deserialized = response.json() + else: + deserialized = None - return pipeline_response + if cls: + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return ItemPaged(get_next, extract_data) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JSON: - """Gets the specified catalog within the project. + def get_outputs(self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any) -> JSON: + """Gets Outputs from the environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param catalog_name: The name of the catalog. Required. - :type catalog_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -6683,8 +9580,15 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JS # response body for status code(s): 200 response == { - "name": "str", # Name of the catalog. Required. - "uri": "str" # The unique URI of the catalog. Required. + "outputs": { + "str": { + "sensitive": bool, # Optional. Indicates if the value is + sensitive. + "type": "str", # Optional. Type of the output value. Known + values are: "array", "boolean", "number", "object", and "string". + "value": {} # Optional. The output value. + } + } } """ error_map = { @@ -6700,9 +9604,10 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JS cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environments_get_catalog_request( + _request = build_environments_get_outputs_request( project_name=project_name, - catalog_name=catalog_name, + environment_name=environment_name, + user_id=user_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6710,11 +9615,11 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JS path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6731,193 +9636,104 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JS deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_environment_definitions_by_project( - self, project_name: str, *, top: Optional[int] = None, **kwargs: Any + def list_operations( + self, + project_name: str, + environment_name: str, + user_id: str = "me", + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any ) -> Iterable[JSON]: - """Lists all environment definitions available for a project. + """Lists operations on the environment which have occurred within the past 90 days. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. Default value is None. :paramtype top: int + :keyword filter: An OData filter clause to apply to the operation. Default value is None. + :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": - # 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. - "uri": "str", # The unique URI 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 {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_environments_list_environment_definitions_by_project_request( - project_name=project_name, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), + # JSON input template for discriminator value "Delete": + environment_operation = { + "kind": "Delete", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. } - request.url = self._client.format_url(request.url, **path_format_arguments) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), + # JSON input template for discriminator value "Deploy": + environment_operation = { + "kind": "Deploy", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - 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) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_environment_definitions_by_catalog( - self, project_name: str, catalog_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> Iterable[JSON]: - """Lists all environment definitions available within a catalog. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param catalog_name: The name of the catalog. Required. - :type catalog_name: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] - :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. - "uri": "str", # The unique URI 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. - } + response == environment_operation """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -6935,10 +9751,12 @@ def list_environment_definitions_by_catalog( def prepare_request(next_link=None): if not next_link: - request = build_environments_list_environment_definitions_by_catalog_request( + _request = build_environments_list_operations_request( project_name=project_name, - catalog_name=catalog_name, + environment_name=environment_name, + user_id=user_id, top=top, + filter=filter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6948,7 +9766,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6960,7 +9778,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6968,9 +9786,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6980,11 +9798,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6999,57 +9817,89 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_environment_definition( - self, project_name: str, catalog_name: str, definition_name: str, **kwargs: Any + def get_operation( + self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any ) -> JSON: - """Get an environment definition from a catalog. + """Gets an environment action result. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :param catalog_name: The name of the catalog. Required. - :type catalog_name: str - :param definition_name: The name of the environment definition. Required. - :type definition_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param operation_id: The id of the operation on an environment. Required. + :type operation_id: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python + # The response is polymorphic. The following are possible polymorphic responses based + off discriminator "kind": - # 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. - "uri": "str", # The unique URI 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. + # JSON input template for discriminator value "Delete": + environment_operation = { + "kind": "Delete", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. + } + + # JSON input template for discriminator value "Deploy": + environment_operation = { + "kind": "Deploy", + "operationId": "str", # Unique identifier for the environment operation. + Required. + "status": "str", # The operation status. Required. Known values are: + "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". + "uri": "str", # The unique URI for the environment operation. Required. + "createdByObjectId": "str", # Optional. The object ID of the actor which + initiated the operation. + "endTime": "2020-02-20 00:00:00", # Optional. The time the operation + finished. + "environmentParameters": {}, # Optional. Parameters object for the + environment at the time of the operation. + "error": { + "code": "str", # An identifier for the error. Codes are invariant + and are intended to be consumed programmatically. Required. + "message": "str", # A message describing the error, intended to be + suitable for display in a user interface. Required. + "details": [ + ... + ], + "target": "str" # Optional. The target of the particular error. For + example, the name of the property in error. + }, + "startTime": "2020-02-20 00:00:00" # Optional. The time the operation + started. } + + # response body for status code(s): 200 + response == environment_operation """ error_map = { 401: ClientAuthenticationError, @@ -7064,10 +9914,11 @@ def get_environment_definition( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environments_get_environment_definition_request( + _request = build_environments_get_operation_request( project_name=project_name, - catalog_name=catalog_name, - definition_name=definition_name, + environment_name=environment_name, + operation_id=operation_id, + user_id=user_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7075,11 +9926,11 @@ def get_environment_definition( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7096,42 +9947,29 @@ def get_environment_definition( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def list_environment_types(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> Iterable[JSON]: - """Lists all environment types configured for a project. + def get_logs_by_operation( + self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any + ) -> Iterator[bytes]: + """Gets the logs for an operation on an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :return: An iterator like instance of JSON object - :rtype: ~azure.core.paging.ItemPaged[JSON] + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param operation_id: The id of the operation on an environment. Required. + :type operation_id: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :return: Iterator of the response bytes + :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "deploymentTargetId": "str", # The 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". - "uri": "str" # The unique URI of the environment type. Required. - } """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[JSON] = kwargs.pop("cls", None) - error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7140,101 +9978,50 @@ def list_environment_types(self, project_name: str, *, top: Optional[int] = None } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_environments_list_environment_types_request( - project_name=project_name, - top=top, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - request.url = self._client.format_url(request.url, **path_format_arguments) - - return request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = deserialized["value"] - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - 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) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - return pipeline_response + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - return ItemPaged(get_next, extract_data) + _request = build_environments_get_logs_by_operation_request( + project_name=project_name, + environment_name=environment_name, + operation_id=operation_id, + user_id=user_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) -class EnvironmentOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + response = pipeline_response.http_response - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.DevCenterClient`'s - :attr:`environment_operations` attribute. - """ + 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) - def __init__(self, *args, **kwargs): - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + deserialized = response.iter_bytes() - @distributed_trace - def list_by_environment( - self, - project_name: str, - environment_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any + if cls: + return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) # type: ignore + + return cast(Iterator[bytes], deserialized) # type: ignore + + @distributed_trace + def list_actions( + self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> Iterable[JSON]: - """Lists operations on the environment which have occurred within the past 90 days. + """Get all scheduled actions for a user within an environment. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str @@ -7243,80 +10030,27 @@ def list_by_environment( :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :keyword top: The maximum number of resources to return from the operation. Example: 'top=10'. - Default value is None. - :paramtype top: int - :keyword filter: An OData filter clause to apply to the operation. Default value is None. - :paramtype filter: str :return: An iterator like instance of JSON object :rtype: ~azure.core.paging.ItemPaged[JSON] :raises ~azure.core.exceptions.HttpResponseError: Example: .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "Delete": - environment_operation = { - "kind": "Delete", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - # JSON input template for discriminator value "Deploy": - environment_operation = { - "kind": "Deploy", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. + # response body for status code(s): 200 + response == { + "actionType": "str", # The action that will be taken. Required. "Delete" + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. time the object was + last modified. + "lastModifiedBy": "str", # Optional. Object Id of the user who last modified + the action. + "name": "str", # Optional. Uniquely identifies the action. + "uri": "str" # Optional. Uri of the action resource. } - - # response body for status code(s): 200 - response == environment_operation """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -7334,12 +10068,10 @@ def list_by_environment( def prepare_request(next_link=None): if not next_link: - request = build_environment_operations_list_by_environment_request( + _request = build_environments_list_actions_request( project_name=project_name, environment_name=environment_name, user_id=user_id, - top=top, - filter=filter, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7349,7 +10081,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -7361,7 +10093,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -7369,9 +10101,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -7381,11 +10113,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7400,17 +10132,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_by_environment( - self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any + def get_action( + self, project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any ) -> JSON: - """Gets an environment action result. + """Retrieve a specific environment action. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :param operation_id: The id of the operation on an environment. Required. - :type operation_id: str + :param action_name: The name of an action that will take place on an Environment. Required. + :type action_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str @@ -7420,69 +10152,21 @@ def get_by_environment( Example: .. code-block:: python - # The response is polymorphic. The following are possible polymorphic responses based - off discriminator "kind": - - # JSON input template for discriminator value "Delete": - environment_operation = { - "kind": "Delete", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. - }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. - } - # JSON input template for discriminator value "Deploy": - environment_operation = { - "kind": "Deploy", - "operationId": "str", # Unique identifier for the environment operation. - Required. - "status": "str", # The operation status. Required. Known values are: - "NotStarted", "Running", "Succeeded", "Canceled", and "Failed". - "uri": "str", # The unique URI for the environment operation. Required. - "createdByObjectId": "str", # Optional. The object ID of the actor which - initiated the operation. - "endTime": "2020-02-20 00:00:00", # Optional. The time the operation - finished. - "environmentParameters": {}, # Optional. Parameters object for the - environment at the time of the operation. - "error": { - "code": "str", # An identifier for the error. Codes are invariant - and are intended to be consumed programmatically. Required. - "message": "str", # A message describing the error, intended to be - suitable for display in a user interface. Required. - "details": [ - ... - ], - "target": "str" # Optional. The target of the particular error. For - example, the name of the property in error. + # response body for status code(s): 200 + response == { + "actionType": "str", # The action that will be taken. Required. "Delete" + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. }, - "startTime": "2020-02-20 00:00:00" # Optional. The time the operation - started. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. time the object was + last modified. + "lastModifiedBy": "str", # Optional. Object Id of the user who last modified + the action. + "name": "str", # Optional. Uniquely identifies the action. + "uri": "str" # Optional. Uri of the action resource. } - - # response body for status code(s): 200 - response == environment_operation """ error_map = { 401: ClientAuthenticationError, @@ -7497,10 +10181,10 @@ def get_by_environment( cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_environment_operations_get_by_environment_request( + _request = build_environments_get_action_request( project_name=project_name, environment_name=environment_name, - operation_id=operation_id, + action_name=action_name, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -7509,11 +10193,11 @@ def get_by_environment( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7530,27 +10214,27 @@ def get_by_environment( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace - def get_logs( - self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any - ) -> Iterator[bytes]: - """Gets the logs for an operation on an environment. + def skip_action( # pylint: disable=inconsistent-return-statements + self, project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any + ) -> None: + """Skips an occurrence of an action. :param project_name: The DevCenter Project upon which to execute operations. Required. :type project_name: str :param environment_name: The name of the environment. Required. :type environment_name: str - :param operation_id: The id of the operation on an environment. Required. - :type operation_id: str + :param action_name: The name of an action that will take place on an Environment. Required. + :type action_name: str :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the authentication context. Default value is "me". :type user_id: str - :return: Iterator of the response bytes - :rtype: Iterator[bytes] + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -7564,12 +10248,12 @@ def get_logs( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_environment_operations_get_logs_request( + _request = build_environments_skip_action_request( project_name=project_name, environment_name=environment_name, - operation_id=operation_id, + action_name=action_name, user_id=user_id, api_version=self._config.api_version, headers=_headers, @@ -7578,11 +10262,101 @@ def get_logs( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = True + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + 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) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def delay_action( + self, + project_name: str, + environment_name: str, + action_name: str, + user_id: str = "me", + *, + until: datetime.datetime, + **kwargs: Any + ) -> JSON: + """Delays the occurrence of an action. + + :param project_name: The DevCenter Project upon which to execute operations. Required. + :type project_name: str + :param environment_name: The name of the environment. Required. + :type environment_name: str + :param action_name: The name of an action that will take place on an Environment. Required. + :type action_name: str + :param user_id: The AAD object id of the user. If value is 'me', the identity is taken from the + authentication context. Default value is "me". + :type user_id: str + :keyword until: The time to delay the Environment action until. Required. + :paramtype until: ~datetime.datetime + :return: JSON object + :rtype: JSON + :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. "Delete" + "next": { + "scheduledTime": "2020-02-20 00:00:00" # The time the action will be + triggered (UTC). Required. + }, + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. time the object was + last modified. + "lastModifiedBy": "str", # Optional. Object Id of the user who last modified + the action. + "name": "str", # Optional. Uniquely identifies the action. + "uri": "str" # Optional. Uri of the action resource. + } + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_environments_delay_action_request( + project_name=project_name, + environment_name=environment_name, + action_name=action_name, + user_id=user_id, + until=until, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7593,9 +10367,12 @@ def get_logs( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - deserialized = response.iter_bytes() + if response.content: + deserialized = response.json() + else: + deserialized = None if cls: - return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(Iterator[bytes], deserialized) + return cast(JSON, deserialized) # type: ignore From 1efbccebf8ae17cdf1e6e90126dc261d20421bc2 Mon Sep 17 00:00:00 2001 From: Amanda Lim Date: Sat, 4 Nov 2023 23:05:21 -0700 Subject: [PATCH 3/3] Update commands --- src/devcenter/azext_devcenter/_help.py | 158 ++++ src/devcenter/azext_devcenter/_params.py | 46 +- src/devcenter/azext_devcenter/_validators.py | 32 +- .../latest/devcenter/admin/pool/_create.py | 2 +- .../latest/devcenter/admin/pool/_update.py | 2 +- src/devcenter/azext_devcenter/commands.py | 2 +- src/devcenter/azext_devcenter/custom.py | 185 +++-- .../devcenter_dataplane/_client.py | 24 +- .../devcenter_dataplane/_configuration.py | 7 +- .../devcenter_dataplane/_serialization.py | 49 +- .../devcenter_dataplane/aio/_client.py | 26 +- .../devcenter_dataplane/aio/_configuration.py | 7 +- .../aio/operations/_operations.py | 628 ++++++++-------- .../operations/_operations.py | 682 +++++++++--------- 14 files changed, 1049 insertions(+), 801 deletions(-) diff --git a/src/devcenter/azext_devcenter/_help.py b/src/devcenter/azext_devcenter/_help.py index f8526287b93..6228245ebc2 100644 --- a/src/devcenter/azext_devcenter/_help.py +++ b/src/devcenter/azext_devcenter/_help.py @@ -650,3 +650,161 @@ az devcenter dev environment-definition show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ --project-name "DevProject" --catalog-name "myCatalog" --definition-name "foo" """ + +helps[ + "devcenter dev environment list-operation" +] = """ + type: command + short-summary: "Lists operations on the environment which have occurred within the past 90 days." + examples: + - name: List using dev center + text: |- + az devcenter dev environment list-operation --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + examples: + - name: List using endpoint + text: |- + az devcenter dev environment list-operation --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +""" + +helps[ + "devcenter dev environment show-operation" +] = """ + type: command + short-summary: "Gets an environment action result." + examples: + - name: Get using dev center + text: |- + az devcenter dev environment show-operation --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --operation-id \ +"f5dbdfab-fa0e-4831-8d13-25359aa5e680" + examples: + - name: Get using endpoint + text: |- + az devcenter dev environment show-operation --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --operation-id "f5dbdfab-fa0e-4831-8d13-25359aa5e680" +""" + +helps[ + "devcenter dev environment show-logs-by-operation" +] = """ + type: command + short-summary: "Gets the logs for an operation on an environment." + examples: + - name: Get using dev center + text: |- + az devcenter dev environment show-logs-by-operation --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --operation-id \ +"f5dbdfab-fa0e-4831-8d13-25359aa5e680" + examples: + - name: Get using endpoint + text: |- + az devcenter dev environment show-logs-by-operation --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --operation-id "f5dbdfab-fa0e-4831-8d13-25359aa5e680" +""" + +helps[ + "devcenter dev environment show-action" +] = """ + type: command + short-summary: "Retrieve a specific environment action." + examples: + - name: Get using dev center + text: |- + az devcenter dev environment show-action --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --action-name \ +"myEnv-Delete" + examples: + - name: Get using endpoint + text: |- + az devcenter dev environment show-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --action-name "myEnv-Delete" +""" + +helps[ + "devcenter dev environment list-action" +] = """ + type: command + short-summary: "List specific environment actions." + examples: + - name: List using dev center + text: |- + az devcenter dev environment list-action --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + examples: + - name: List using endpoint + text: |- + az devcenter dev environment list-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +""" + +helps[ + "devcenter dev environment delay-action" +] = """ + type: command + short-summary: "Delay an environment action." + examples: + - name: Delay using dev center + text: |- + az devcenter dev environment delay-action --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --action-name \ +"myEnv-Delete" --delay-time "04:30" + examples: + - name: Delay using endpoint + text: |- + az devcenter dev environment delay-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --action-name "myEnv-Delete" --delay-time "04:30" +""" + +helps[ + "devcenter dev environment skip-action" +] = """ + type: command + short-summary: "Skip a specific environment action." + examples: + - name: Skip using dev center + text: |- + az devcenter dev environment skip-action --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --action-name \ +"myEnv-Delete" + examples: + - name: Skip using endpoint + text: |- + az devcenter dev environment skip-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --action-name "myEnv-Delete" +""" + +helps[ + "devcenter dev environment show-outputs" +] = """ + type: command + short-summary: "Gets outputs from the environment." + examples: + - name: Get using dev center + text: |- + az devcenter dev environment show-outputs --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + examples: + - name: Get using endpoint + text: |- + az devcenter dev environment show-outputs --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +""" + +helps[ + "devcenter dev environment update-expiration-date" +] = """ + type: command + short-summary: "Update the environment expiration" + examples: + - name: Get using dev center + text: |- + az devcenter dev environment update-expiration-date --dev-center-name "ContosoDevCenter" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --expiration "2025-11-30T22:35:00+00:00" + examples: + - name: Get using endpoint + text: |- + az devcenter dev environment update-expiration-date --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --expiration "2025-11-30T22:35:00+00:00" +""" diff --git a/src/devcenter/azext_devcenter/_params.py b/src/devcenter/azext_devcenter/_params.py index 807ec9ff3af..b77c64bef9e 100644 --- a/src/devcenter/azext_devcenter/_params.py +++ b/src/devcenter/azext_devcenter/_params.py @@ -15,7 +15,7 @@ validate_file_or_dict, ) -from ._validators import validate_dev_box_list, validate_time +from ._validators import validate_dev_box_list, validate_time, is_iso8601 dev_center_type = CLIArgumentType( @@ -640,7 +640,7 @@ def load_arguments(self, _): help="The name " "of the environment.", ) - with self.argument_context("devcenter dev environment create") as c: + with self.argument_context("devcenter dev environment create", validator=is_iso8601) as c: c.argument( "dev_center", arg_type=dev_center_type, @@ -681,12 +681,13 @@ def load_arguments(self, _): ) c.argument( "expiration_date", - options_list=["--expiration_date", "--expiration"], + options_list=["--expiration-date", "--expiration"], type=str, - help="The date of environment expiration. Must be an ISO string", + help="The time the expiration date will be triggered (UTC), after which the environment" + " and associated resources will be deleted. The string format is ISO format.", ) - with self.argument_context("devcenter dev environment update") as c: + with self.argument_context("devcenter dev environment update", validator=is_iso8601) as c: c.argument( "dev_center", arg_type=dev_center_type, @@ -719,12 +720,12 @@ def load_arguments(self, _): ) c.argument( "expiration_date", - options_list=["--expiration_date", "--expiration"], + options_list=["--expiration-date", "--expiration"], type=str, help="The date of environment expiration. Must be an ISO string", ) - with self.argument_context("devcenter dev environment deploy") as c: + with self.argument_context("devcenter dev environment deploy", validator=is_iso8601) as c: c.argument( "dev_center", arg_type=dev_center_type, @@ -757,7 +758,7 @@ def load_arguments(self, _): ) c.argument( "expiration_date", - options_list=["--expiration_date", "--expiration"], + options_list=["--expiration-date", "--expiration"], type=str, help="The date of environment expiration. Must be an ISO string", ) @@ -873,7 +874,7 @@ def load_arguments(self, _): "endpoint", arg_type=endpoint, ) - + with self.argument_context("devcenter dev environment list-operation") as c: c.argument( "dev_center", @@ -927,7 +928,7 @@ def load_arguments(self, _): ) c.argument( "operation_id", - options_list=["--operation-id", "-o"], + options_list=["--operation-id"], type=str, help="The ID " "of the operation.", ) @@ -959,7 +960,7 @@ def load_arguments(self, _): ) c.argument( "operation_id", - options_list=["--operation-id", "-o"], + options_list=["--operation-id"], type=str, help="The ID " "of the operation.", ) @@ -995,7 +996,7 @@ def load_arguments(self, _): type=str, help="The name of an action that will take place on an environment.", ) - + with self.argument_context("devcenter dev environment skip-action") as c: c.argument( "dev_center", @@ -1027,7 +1028,7 @@ def load_arguments(self, _): type=str, help="The name of an action that will take place on an environment.", ) - + with self.argument_context("devcenter dev environment list-action") as c: c.argument( "dev_center", @@ -1054,7 +1055,9 @@ def load_arguments(self, _): help="The name " "of the environment.", ) - with self.argument_context("devcenter dev environment delay-action") as c: + with self.argument_context( + "devcenter dev environment delay-action", validator=validate_time + ) as c: c.argument( "dev_center", arg_type=dev_center_type, @@ -1086,12 +1089,10 @@ def load_arguments(self, _): help="The name of an action that will take place on an environment.", ) c.argument( - "until", - options_list=["--until"], - type=str, - help="The time to delay the environment action until. Must be an ISO string", + "delay_time", + help="The delayed timespan from the scheduled action time. Format HH:MM", ) - + with self.argument_context("devcenter dev environment show-outputs") as c: c.argument( "dev_center", @@ -1118,7 +1119,7 @@ def load_arguments(self, _): help="The name " "of the environment.", ) - with self.argument_context("devcenter dev environment update-environment-expiration-date") as c: + with self.argument_context("devcenter dev environment update-expiration-date", validator=is_iso8601) as c: c.argument( "dev_center", arg_type=dev_center_type, @@ -1145,7 +1146,8 @@ def load_arguments(self, _): ) c.argument( "expiration_date", - options_list=["--expiration_date", "--expiration"], + options_list=["--expiration-date", "--expiration"], type=str, - help="The date of environment expiration. Must be an ISO string", + help="The time the expiration date will be triggered (UTC), after which the environment " + "and associated resources will be deleted. The string format is ISO format.", ) diff --git a/src/devcenter/azext_devcenter/_validators.py b/src/devcenter/azext_devcenter/_validators.py index a07dcfa8684..94fc79b863f 100644 --- a/src/devcenter/azext_devcenter/_validators.py +++ b/src/devcenter/azext_devcenter/_validators.py @@ -2,6 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +from datetime import datetime import locale import re from azure.cli.core.azclierror import ( @@ -33,22 +34,35 @@ def validate_repo_git(ado_git, git_hub): or GitHub source control definition (--git-hub) should be set.""" raise RequiredArgumentMissingError(error_message) -def validate_pool_create(virtual_network_type, network_connection_name, managed_virtual_network_regions): - if not has_value(managed_virtual_network_regions) and virtual_network_type == "Managed": + +def validate_pool_create( + virtual_network_type, network_connection_name, managed_virtual_network_regions +): + if ( + not has_value(managed_virtual_network_regions) + and virtual_network_type == "Managed" + ): error_message = """When virtual-network-type is set to "Managed", \ managed virtual network regions (--managed-virtual-network-regions) should be set.""" raise RequiredArgumentMissingError(error_message) - if not has_value(network_connection_name) and (virtual_network_type == "Unmanaged" or not has_value(virtual_network_type)): + if not has_value(network_connection_name) and ( + virtual_network_type == "Unmanaged" or not has_value(virtual_network_type) + ): error_message = """When virtual-network-type is not used or set to "Unmanaged", \ a network connection name (--network-connection) should be set.""" raise RequiredArgumentMissingError(error_message) - if has_value(managed_virtual_network_regions) and (virtual_network_type == "Unmanaged" or not has_value(virtual_network_type)): + if has_value(managed_virtual_network_regions) and ( + virtual_network_type == "Unmanaged" or not has_value(virtual_network_type) + ): print(managed_virtual_network_regions[0]) error_message = """When virtual-network-type is not used or set to "Unmanaged", \ managed virtual network regions (--managed-virtual-network-regions) should not be set.""" raise RequiredArgumentMissingError(error_message) + # Data plane + + def validate_dev_box_list(namespace): if namespace.project_name is not None and namespace.user_id is None: raise RequiredArgumentMissingError( @@ -96,3 +110,13 @@ def validate_env_name_already_exists(env_iterator, name, user_id, project): error_message = f"""An environment with the name '{name}' \ already exists for the user-id '{user_id}' in this project '{project}'.""" raise InvalidArgumentValueError(error_message) + + +def is_iso8601(namespace): + try: + datetime.fromisoformat(namespace.expiration_date) + return True + except ValueError as exception: + error_message = f"""The expiration date is invalid '{namespace.expiration_date}' \ +it must be in ISO 8601 format. For example: 2023-12-30T22:35:00+00:00""" + raise InvalidArgumentValueError(error_message) from exception diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_create.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_create.py index f37b4ea7bee..fb2ed72ddbc 100644 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_create.py +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_create.py @@ -116,7 +116,7 @@ def _build_arguments_schema(cls, *args, **kwargs): enum={"Disabled": "Disabled", "Enabled": "Enabled"}, ) _args_schema.managed_virtual_network_regions = AAZListArg( - options=["--managed-virtual-network-regions"], + options=["--managed-virtual-network-regions", "-m"], arg_group="Properties", help="The regions of the managed virtual network (required when managedNetworkType is Managed).", ) diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_update.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_update.py index 173d1c3d603..3ad1576db9a 100644 --- a/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_update.py +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/admin/pool/_update.py @@ -109,7 +109,7 @@ def _build_arguments_schema(cls, *args, **kwargs): enum={"Disabled": "Disabled", "Enabled": "Enabled"}, ) _args_schema.managed_virtual_network_regions = AAZListArg( - options=["--managed-virtual-network-regions"], + options=["--managed-virtual-network-regions", "-m"], arg_group="Properties", help="The regions of the managed virtual network (required when managedNetworkType is Managed).", nullable=True, diff --git a/src/devcenter/azext_devcenter/commands.py b/src/devcenter/azext_devcenter/commands.py index d8d7accfcc7..259e2183695 100644 --- a/src/devcenter/azext_devcenter/commands.py +++ b/src/devcenter/azext_devcenter/commands.py @@ -280,7 +280,7 @@ def load_command_table(self, _): g.custom_command("delay-action", "devcenter_environment_operation_delay_action") g.custom_command("skip-action", "devcenter_environment_operation_skip_action") g.custom_command("show-outputs", "devcenter_environment_operation_show_outputs") - g.custom_command("update-environment-expiration-date", "devcenter_environment_operation_update_environment") + g.custom_command("update-expiration-date", "devcenter_environment_operation_update_environment") with self.command_group("devcenter dev catalog", environments_dp) as g: g.custom_command("list", "devcenter_catalog_list_dp") diff --git a/src/devcenter/azext_devcenter/custom.py b/src/devcenter/azext_devcenter/custom.py index 82a20c50cae..e1d85b778ff 100644 --- a/src/devcenter/azext_devcenter/custom.py +++ b/src/devcenter/azext_devcenter/custom.py @@ -95,7 +95,7 @@ validate_attached_network_or_dev_box_def, validate_env_name_already_exists, validate_repo_git, - validate_pool_create + validate_pool_create, ) # Control plane @@ -381,9 +381,15 @@ def _build_arguments_schema(cls, *args, **kwargs): def pre_operations(self): args = self.ctx.args args.license_type = "Windows_Client" - if args.virtual_network_type == "Managed" and not has_value(args.network_connection_name): + if args.virtual_network_type == "Managed" and not has_value( + args.network_connection_name + ): args.network_connection_name = "managedNetwork" - validate_pool_create(args.virtual_network_type, args.network_connection_name, args.managed_virtual_network_regions) + validate_pool_create( + args.virtual_network_type, + args.network_connection_name, + args.managed_virtual_network_regions, + ) def _cli_arguments_loader(self): args = super()._cli_arguments_loader() @@ -612,7 +618,9 @@ def devcenter_pool_show_dp( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.dev_boxes.get_pool(project_name=project_name, pool_name=pool_name) + return cf_dataplane.dev_boxes.get_pool( + project_name=project_name, pool_name=pool_name + ) def devcenter_schedule_list_dp( @@ -622,8 +630,12 @@ def devcenter_schedule_list_dp( cmd.cli_ctx, endpoint, dev_center, project_name ) if pool_name is None: - return cf_dataplane.dev_boxes.list_schedules_by_project(project_name=project_name) - return cf_dataplane.dev_boxes.list_schedules(project_name=project_name, pool_name=pool_name) + return cf_dataplane.dev_boxes.list_schedules_by_project( + project_name=project_name + ) + return cf_dataplane.dev_boxes.list_schedules( + project_name=project_name, pool_name=pool_name + ) def devcenter_schedule_show_dp( @@ -633,9 +645,8 @@ def devcenter_schedule_show_dp( cmd.cli_ctx, endpoint, dev_center, project_name ) return cf_dataplane.dev_boxes.get_schedule( - project_name=project_name, - pool_name=pool_name, - schedule_name="default") + project_name=project_name, pool_name=pool_name, schedule_name="default" + ) def devcenter_dev_box_list( @@ -645,7 +656,9 @@ def devcenter_dev_box_list( cmd.cli_ctx, endpoint, dev_center, project_name ) if project_name is not None and user_id is not None: - return cf_dataplane.dev_boxes.list_dev_boxes(project_name=project_name, user_id=user_id) + return cf_dataplane.dev_boxes.list_dev_boxes( + project_name=project_name, user_id=user_id + ) if user_id is not None: return cf_dataplane.dev_boxes.list_all_dev_boxes_by_user(user_id=user_id) return cf_dataplane.dev_boxes.list_all_dev_boxes() @@ -658,9 +671,8 @@ def devcenter_dev_box_show( cmd.cli_ctx, endpoint, dev_center, project_name ) return cf_dataplane.dev_boxes.get_dev_box( - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name) + project_name=project_name, user_id=user_id, dev_box_name=dev_box_name + ) def devcenter_dev_box_create( @@ -812,7 +824,9 @@ def devcenter_dev_box_list_action( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.dev_boxes.list_actions(project_name=project_name, user_id=user_id, dev_box_name=dev_box_name) + return cf_dataplane.dev_boxes.list_actions( + project_name=project_name, user_id=user_id, dev_box_name=dev_box_name + ) def devcenter_dev_box_show_action( @@ -926,7 +940,9 @@ def devcenter_dev_box_list_operation( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.dev_boxes.list_operations(project_name=project_name, user_id=user_id, dev_box_name=dev_box_name) + return cf_dataplane.dev_boxes.list_operations( + project_name=project_name, user_id=user_id, dev_box_name=dev_box_name + ) def devcenter_dev_box_show_operation( @@ -957,8 +973,12 @@ def devcenter_environment_list( ) if user_id is not None: - return cf_dataplane.deployment_environments.list_all_environments(project_name=project_name, user_id=user_id) - return cf_dataplane.deployment_environments.list_environments(project_name=project_name) + return cf_dataplane.deployment_environments.list_all_environments( + project_name=project_name, user_id=user_id + ) + return cf_dataplane.deployment_environments.list_environments( + project_name=project_name + ) def devcenter_environment_show( @@ -972,6 +992,7 @@ def devcenter_environment_show( project_name=project_name, user_id=user_id, environment_name=environment_name ) + def devcenter_environment_create( cmd, environment_name, @@ -1001,7 +1022,7 @@ def devcenter_environment_create( body["environmentType"] = environment_type body["catalogName"] = catalog_name body["environmentDefinitionName"] = environment_definition_name - body["expirationDate"] = datetime.strptime(expiration_date, "%Y-%m-%dT%H:%M:%S.%fZ") + body["expirationDate"] = datetime.fromisoformat(expiration_date) return sdk_no_wait( no_wait, cf_dataplane.deployment_environments.begin_create_or_update_environment, @@ -1021,7 +1042,7 @@ def devcenter_environment_update( user_id="me", dev_center=None, endpoint=None, - expiration_date=None + expiration_date=None, ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name @@ -1035,7 +1056,7 @@ def devcenter_environment_update( body["environmentType"] = environment["environmentType"] body["catalogName"] = environment["catalogName"] body["environmentDefinitionName"] = environment["environmentDefinitionName"] - body["expirationDate"] = datetime.strptime(expiration_date, "%Y-%m-%dT%H:%M:%S.%fZ") + body["expirationDate"] = datetime.fromisoformat(expiration_date) return sdk_no_wait( no_wait, cf_dataplane.deployment_environments.begin_create_or_update_environment, @@ -1080,7 +1101,9 @@ def devcenter_catalog_show_dp( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.deployment_environments.get_catalog(project_name=project_name, catalog_name=catalog_name) + return cf_dataplane.deployment_environments.get_catalog( + project_name=project_name, catalog_name=catalog_name + ) def devcenter_environment_definition_list_dp( @@ -1093,7 +1116,9 @@ def devcenter_environment_definition_list_dp( return cf_dataplane.deployment_environments.list_environment_definitions_by_catalog( project_name=project_name, catalog_name=catalog_name ) - return cf_dataplane.deployment_environments.list_environment_definitions(project_name=project_name) + return cf_dataplane.deployment_environments.list_environment_definitions( + project_name=project_name + ) def devcenter_environment_definition_show_dp( @@ -1103,7 +1128,9 @@ def devcenter_environment_definition_show_dp( cmd.cli_ctx, endpoint, dev_center, project_name ) return cf_dataplane.deployment_environments.get_environment_definition( - project_name=project_name, catalog_name=catalog_name, definition_name=definition_name + project_name=project_name, + catalog_name=catalog_name, + definition_name=definition_name, ) @@ -1113,7 +1140,9 @@ def devcenter_environment_type_list_dp( cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.deployment_environments.list_environment_types(project_name=project_name) + return cf_dataplane.deployment_environments.list_environment_types( + project_name=project_name + ) def devcenter_environment_operation_list( @@ -1123,43 +1152,74 @@ def devcenter_environment_operation_list( cmd.cli_ctx, endpoint, dev_center, project_name ) - return cf_dataplane.environments.list_operations(project_name=project_name, - environment_name=environment_name, user_id=user_id) + return cf_dataplane.environments.list_operations( + project_name=project_name, environment_name=environment_name, user_id=user_id + ) def devcenter_environment_operation_show( - cmd, project_name, environment_name, operation_id, user_id="me", dev_center=None, endpoint=None + cmd, + project_name, + environment_name, + operation_id, + user_id="me", + dev_center=None, + endpoint=None, ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) return cf_dataplane.environments.get_operation( - project_name=project_name, operation_id=operation_id, user_id=user_id, environment_name=environment_name + project_name=project_name, + operation_id=operation_id, + user_id=user_id, + environment_name=environment_name, ) + def devcenter_environment_operation_show_logs_by_operation( - cmd, project_name, environment_name, operation_id, user_id="me", dev_center=None, endpoint=None + cmd, + project_name, + environment_name, + operation_id, + user_id="me", + dev_center=None, + endpoint=None, ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) return cf_dataplane.environments.get_logs_by_operation( - project_name=project_name, operation_id=operation_id, user_id=user_id, environment_name=environment_name + project_name=project_name, + operation_id=operation_id, + user_id=user_id, + environment_name=environment_name, ) + def devcenter_environment_operation_show_action( - cmd, project_name, environment_name, action_name, user_id="me", dev_center=None, endpoint=None + cmd, + project_name, + environment_name, + action_name, + user_id="me", + dev_center=None, + endpoint=None, ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) return cf_dataplane.environments.get_action( - project_name=project_name, user_id=user_id, action_name=action_name, environment_name=environment_name + project_name=project_name, + user_id=user_id, + action_name=action_name, + environment_name=environment_name, ) + def devcenter_environment_operation_list_action( cmd, project_name, environment_name, user_id="me", dev_center=None, endpoint=None ): @@ -1171,26 +1231,60 @@ def devcenter_environment_operation_list_action( project_name=project_name, user_id=user_id, environment_name=environment_name ) + def devcenter_environment_operation_delay_action( - cmd, project_name, environment_name, action_name, until, user_id="me", dev_center=None, endpoint=None + cmd, + project_name, + environment_name, + action_name, + delay_time, + user_id="me", + dev_center=None, + endpoint=None, ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) + upcoming_action = cf_dataplane.environments.get_action( + project_name=project_name, + user_id=user_id, + action_name=action_name, + environment_name=environment_name, + ) + + upcoming_action_time = upcoming_action["next"]["scheduledTime"] + action_time = datetime.strptime(upcoming_action_time, "%Y-%m-%dT%H:%M:%S.%fZ") + + delayed_time = get_delayed_time(delay_time, action_time) + return cf_dataplane.environments.delay_action( - project_name=project_name, action_name=action_name, user_id=user_id, until=until, environment_name=environment_name + project_name=project_name, + action_name=action_name, + user_id=user_id, + until=delayed_time, + environment_name=environment_name, ) + def devcenter_environment_operation_skip_action( - cmd, project_name, environment_name, action_name, user_id="me", dev_center=None, endpoint=None + cmd, + project_name, + environment_name, + action_name, + user_id="me", + dev_center=None, + endpoint=None, ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) return cf_dataplane.environments.skip_action( - project_name=project_name, action_name=action_name, user_id=user_id, environment_name=environment_name + project_name=project_name, + action_name=action_name, + user_id=user_id, + environment_name=environment_name, ) @@ -1205,16 +1299,25 @@ def devcenter_environment_operation_show_outputs( project_name=project_name, user_id=user_id, environment_name=environment_name ) + def devcenter_environment_operation_update_environment( - cmd, project_name, environment_name, user_id="me", dev_center=None, endpoint=None, expiration_date=None, + cmd, + project_name, + environment_name, + user_id="me", + dev_center=None, + endpoint=None, + expiration_date=None, ): cf_dataplane = cf_devcenter_dataplane( cmd.cli_ctx, endpoint, dev_center, project_name ) - body={} - body["expirationDate"] = datetime.strptime(expiration_date, "%Y-%m-%dT%H:%M:%S.%fZ") + body = {} + body["expirationDate"] = datetime.fromisoformat(expiration_date) return cf_dataplane.environments.patch_environment( - project_name=project_name, user_id=user_id, environment_name=environment_name, body=body + project_name=project_name, + user_id=user_id, + environment_name=environment_name, + body=body, ) - diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py index 3c13bbd4a52..a64e0ce692f 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py @@ -10,7 +10,6 @@ from typing import Any, TYPE_CHECKING from azure.core import PipelineClient -from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from ._configuration import DevCenterClientConfiguration @@ -56,24 +55,7 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword 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._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -86,7 +68,7 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) ) self.environments = EnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) - def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -110,7 +92,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: } 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 + return self._client.send_request(request_copy, **kwargs) def close(self) -> None: self._client.close() diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py index ad2614568f0..ac735812b97 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py @@ -8,6 +8,7 @@ from typing import Any, TYPE_CHECKING +from azure.core.configuration import Configuration from azure.core.pipeline import policies from ._version import VERSION @@ -17,7 +18,7 @@ from azure.core.credentials import TokenCredential -class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DevCenterClient. Note that all parameters used to create this instance are saved as instance @@ -33,6 +34,7 @@ class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attribu """ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: + super(DevCenterClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2023-10-01-preview") if endpoint is None: @@ -45,7 +47,6 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) 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: @@ -54,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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( diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py index 1247eb71a98..4bae2292227 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py @@ -63,7 +63,7 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: + except ET.ParseError: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,7 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err + raise_with_traceback(DeserializationError, "XML is invalid") raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -295,7 +295,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Optional[Dict[str, Any]] = {} + self.additional_properties: Dict[str, Any] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +340,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. + """Return the JSON that would be sent to azure from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +351,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) def as_dict( self, @@ -390,7 +390,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) @classmethod def _infer_class_models(cls): @@ -415,7 +415,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + return deserializer(cls.__name__, data, content_type=content_type) @classmethod def from_dict( @@ -445,7 +445,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + return deserializer(cls.__name__, data, content_type=content_type) @classmethod def _flatten_subtype(cls, key, objects): @@ -668,7 +668,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err + raise_with_traceback(SerializationError, msg, err) else: return serialized @@ -710,7 +710,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) return self._serialize(data, data_type, **kwargs) @@ -730,8 +730,6 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) - # https://github.com/Azure/autorest.python/issues/2063 - output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -755,7 +753,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -826,7 +824,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err + raise_with_traceback(SerializationError, msg.format(data, data_type), err) else: return self._serialize(data, **kwargs) @@ -1172,10 +1170,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err + raise_with_traceback(SerializationError, msg, err) except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err + raise_with_traceback(TypeError, msg, err) @staticmethod def serialize_unix(attr, **kwargs): @@ -1483,7 +1481,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err + raise_with_traceback(DeserializationError, msg, err) else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1654,7 +1652,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err + raise_with_traceback(DeserializationError, msg, err) else: return self._deserialize(obj_type, data) @@ -1810,6 +1808,7 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1866,7 +1865,7 @@ def deserialize_decimal(attr): return decimal.Decimal(attr) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err + raise_with_traceback(DeserializationError, msg, err) @staticmethod def deserialize_long(attr): @@ -1894,7 +1893,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err + raise_with_traceback(DeserializationError, msg, err) else: return duration @@ -1911,7 +1910,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) @staticmethod def deserialize_time(attr): @@ -1946,7 +1945,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err + raise_with_traceback(DeserializationError, msg, err) else: return date_obj @@ -1983,7 +1982,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err + raise_with_traceback(DeserializationError, msg, err) else: return date_obj @@ -2002,6 +2001,6 @@ def deserialize_unix(attr): date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err + raise_with_traceback(DeserializationError, msg, err) else: return date_obj diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py index fa779eb7b9b..b470d2566cf 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py @@ -10,7 +10,6 @@ from typing import Any, Awaitable, TYPE_CHECKING from azure.core import AsyncPipelineClient -from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from .._serialization import Deserializer, Serializer @@ -56,24 +55,7 @@ class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword 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._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -86,9 +68,7 @@ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: ) self.environments = EnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) - def send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -112,7 +92,7 @@ def send_request( } 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 + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py index 25673cef107..4c2d03f43d0 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py @@ -8,6 +8,7 @@ from typing import Any, TYPE_CHECKING +from azure.core.configuration import Configuration from azure.core.pipeline import policies from .._version import VERSION @@ -17,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long +class DevCenterClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for DevCenterClient. Note that all parameters used to create this instance are saved as instance @@ -33,6 +34,7 @@ class DevCenterClientConfiguration: # pylint: disable=too-many-instance-attribu """ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + super(DevCenterClientConfiguration, self).__init__(**kwargs) api_version: str = kwargs.pop("api_version", "2023-10-01-preview") if endpoint is None: @@ -45,7 +47,6 @@ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: 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: @@ -54,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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( diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py index 5817167d654..a22f3f0d7ae 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py @@ -154,7 +154,7 @@ def list_projects( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_projects_request( + request = build_dev_center_list_projects_request( filter=filter, top=top, api_version=self._config.api_version, @@ -166,7 +166,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -178,7 +178,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -186,9 +186,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -198,11 +198,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -252,7 +252,7 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_center_get_project_request( + request = build_dev_center_get_project_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -261,11 +261,11 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -282,9 +282,9 @@ async def get_project(self, project_name: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) class DevBoxesOperations: # pylint: disable=too-many-public-methods @@ -390,7 +390,7 @@ def list_pools( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_pools_request( + request = build_dev_boxes_list_pools_request( project_name=project_name, top=top, filter=filter, @@ -403,7 +403,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -415,7 +415,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -423,9 +423,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -435,11 +435,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,7 +531,7 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JS cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_pool_request( + request = build_dev_boxes_get_pool_request( project_name=project_name, pool_name=pool_name, api_version=self._config.api_version, @@ -541,11 +541,11 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JS path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -562,9 +562,9 @@ async def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JS deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_schedules_by_project( @@ -620,7 +620,7 @@ def list_schedules_by_project( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_schedules_by_project_request( + request = build_dev_boxes_list_schedules_by_project_request( project_name=project_name, top=top, filter=filter, @@ -633,7 +633,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -645,7 +645,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -653,9 +653,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -665,11 +665,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -745,7 +745,7 @@ def list_schedules( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_schedules_request( + request = build_dev_boxes_list_schedules_request( project_name=project_name, pool_name=pool_name, top=top, @@ -759,7 +759,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -771,7 +771,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -779,9 +779,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -791,11 +791,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -857,7 +857,7 @@ async def get_schedule(self, project_name: str, pool_name: str, schedule_name: s cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_schedule_request( + request = build_dev_boxes_get_schedule_request( project_name=project_name, pool_name=pool_name, schedule_name=schedule_name, @@ -868,11 +868,11 @@ async def get_schedule(self, project_name: str, pool_name: str, schedule_name: s path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -889,9 +889,9 @@ async def get_schedule(self, project_name: str, pool_name: str, schedule_name: s deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_all_dev_boxes( @@ -993,7 +993,7 @@ def list_all_dev_boxes( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_all_dev_boxes_request( + request = build_dev_boxes_list_all_dev_boxes_request( filter=filter, top=top, api_version=self._config.api_version, @@ -1005,7 +1005,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -1017,7 +1017,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -1025,9 +1025,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -1037,11 +1037,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1158,7 +1158,7 @@ def list_all_dev_boxes_by_user( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_all_dev_boxes_by_user_request( + request = build_dev_boxes_list_all_dev_boxes_by_user_request( user_id=user_id, filter=filter, top=top, @@ -1171,7 +1171,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -1183,7 +1183,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -1191,9 +1191,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -1203,11 +1203,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1332,7 +1332,7 @@ def list_dev_boxes( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_dev_boxes_request( + request = build_dev_boxes_list_dev_boxes_request( project_name=project_name, user_id=user_id, filter=filter, @@ -1346,7 +1346,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -1358,7 +1358,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -1366,9 +1366,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -1378,11 +1378,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1493,7 +1493,7 @@ async def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_dev_box_request( + request = build_dev_boxes_get_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -1504,11 +1504,11 @@ async def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1525,9 +1525,9 @@ async def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) async def _create_dev_box_initial( self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any @@ -1554,7 +1554,7 @@ async def _create_dev_box_initial( else: _json = body - _request = build_dev_boxes_create_dev_box_request( + request = build_dev_boxes_create_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -1568,11 +1568,11 @@ async def _create_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2093,13 +2093,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _delete_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2117,7 +2117,7 @@ async def _delete_dev_box_initial( cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_dev_boxes_delete_dev_box_request( + request = build_dev_boxes_delete_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2128,11 +2128,11 @@ async def _delete_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2156,9 +2156,9 @@ async def _delete_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) - return deserialized # type: ignore + return deserialized @distributed_trace_async async def begin_delete_dev_box( @@ -2259,13 +2259,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _start_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2283,7 +2283,7 @@ async def _start_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_start_dev_box_request( + request = build_dev_boxes_start_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2294,11 +2294,11 @@ async def _start_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2318,9 +2318,9 @@ async def _start_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def begin_start_dev_box( @@ -2421,13 +2421,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _stop_dev_box_initial( self, @@ -2451,7 +2451,7 @@ async def _stop_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_stop_dev_box_request( + request = build_dev_boxes_stop_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2463,11 +2463,11 @@ async def _stop_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2487,9 +2487,9 @@ async def _stop_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def begin_stop_dev_box( @@ -2599,13 +2599,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _restart_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2623,7 +2623,7 @@ async def _restart_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_restart_dev_box_request( + request = build_dev_boxes_restart_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2634,11 +2634,11 @@ async def _restart_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2658,9 +2658,9 @@ async def _restart_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def begin_restart_dev_box( @@ -2761,13 +2761,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _repair_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -2785,7 +2785,7 @@ async def _repair_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_repair_dev_box_request( + request = build_dev_boxes_repair_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -2796,11 +2796,11 @@ async def _repair_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2820,9 +2820,9 @@ async def _repair_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def begin_repair_dev_box( @@ -2924,13 +2924,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_customization_groups( @@ -3010,7 +3010,7 @@ def list_customization_groups( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_customization_groups_request( + request = build_dev_boxes_list_customization_groups_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -3024,7 +3024,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3036,7 +3036,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3044,9 +3044,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3056,11 +3056,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3141,7 +3141,7 @@ async def get_customization_group( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_customization_group_request( + request = build_dev_boxes_get_customization_group_request( project_name=project_name, dev_box_name=dev_box_name, customization_group_name=customization_group_name, @@ -3153,11 +3153,11 @@ async def get_customization_group( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3174,9 +3174,9 @@ async def get_customization_group( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @overload async def create_customization_group( @@ -3465,7 +3465,7 @@ async def create_customization_group( else: _json = body - _request = build_dev_boxes_create_customization_group_request( + request = build_dev_boxes_create_customization_group_request( project_name=project_name, dev_box_name=dev_box_name, customization_group_name=customization_group_name, @@ -3480,11 +3480,11 @@ async def create_customization_group( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3501,9 +3501,9 @@ async def create_customization_group( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def get_customization_task_log( @@ -3545,7 +3545,7 @@ async def get_customization_task_log( cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_customization_task_log_request( + request = build_dev_boxes_get_customization_task_log_request( project_name=project_name, dev_box_name=dev_box_name, customization_group_name=customization_group_name, @@ -3558,11 +3558,11 @@ async def get_customization_task_log( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3576,9 +3576,9 @@ async def get_customization_task_log( deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, cast(AsyncIterator[bytes], deserialized), {}) # type: ignore + return cls(pipeline_response, cast(AsyncIterator[bytes], deserialized), {}) - return cast(AsyncIterator[bytes], deserialized) # type: ignore + return cast(AsyncIterator[bytes], deserialized) @distributed_trace_async async def get_remote_connection( @@ -3620,7 +3620,7 @@ async def get_remote_connection( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_remote_connection_request( + request = build_dev_boxes_get_remote_connection_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -3631,11 +3631,11 @@ async def get_remote_connection( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3652,9 +3652,9 @@ async def get_remote_connection( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_actions( @@ -3711,7 +3711,7 @@ def list_actions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_actions_request( + request = build_dev_boxes_list_actions_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -3724,7 +3724,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3736,7 +3736,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3744,9 +3744,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3756,11 +3756,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3828,7 +3828,7 @@ async def get_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_action_request( + request = build_dev_boxes_get_action_request( project_name=project_name, dev_box_name=dev_box_name, action_name=action_name, @@ -3840,11 +3840,11 @@ async def get_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3861,9 +3861,9 @@ async def get_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def skip_action( # pylint: disable=inconsistent-return-statements @@ -3897,7 +3897,7 @@ async def skip_action( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_dev_boxes_skip_action_request( + request = build_dev_boxes_skip_action_request( project_name=project_name, dev_box_name=dev_box_name, action_name=action_name, @@ -3909,11 +3909,11 @@ async def skip_action( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3925,7 +3925,7 @@ async def skip_action( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, None, {}) @distributed_trace_async async def delay_action( @@ -3990,7 +3990,7 @@ async def delay_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_delay_action_request( + request = build_dev_boxes_delay_action_request( project_name=project_name, dev_box_name=dev_box_name, action_name=action_name, @@ -4003,11 +4003,11 @@ async def delay_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4024,9 +4024,9 @@ async def delay_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def delay_all_actions( @@ -4103,7 +4103,7 @@ def delay_all_actions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_delay_all_actions_request( + request = build_dev_boxes_delay_all_actions_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -4117,7 +4117,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -4129,7 +4129,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -4137,9 +4137,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -4149,11 +4149,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4337,7 +4337,7 @@ def list_operations( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_operations_request( + request = build_dev_boxes_list_operations_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -4352,7 +4352,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -4364,7 +4364,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -4372,9 +4372,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -4384,11 +4384,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4559,7 +4559,7 @@ async def get_operation( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_operation_request( + request = build_dev_boxes_get_operation_request( project_name=project_name, dev_box_name=dev_box_name, operation_id=operation_id, @@ -4571,11 +4571,11 @@ async def get_operation( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4592,9 +4592,9 @@ async def get_operation( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) class ProjectsOperations: @@ -4671,7 +4671,7 @@ def list_customization_task_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_projects_list_customization_task_definitions_request( + request = build_projects_list_customization_task_definitions_request( project_name=project_name, filter=filter, api_version=self._config.api_version, @@ -4683,7 +4683,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -4695,7 +4695,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -4703,9 +4703,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -4715,11 +4715,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4801,7 +4801,7 @@ async def get_customization_task_definition( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_projects_get_customization_task_definition_request( + request = build_projects_get_customization_task_definition_request( project_name=project_name, catalog_name=catalog_name, task_name=task_name, @@ -4814,11 +4814,11 @@ async def get_customization_task_definition( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4835,9 +4835,9 @@ async def get_customization_task_definition( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) async def _validate_customization_tasks_initial( self, project_name: str, body: Union[JSON, IO], **kwargs: Any @@ -4864,7 +4864,7 @@ async def _validate_customization_tasks_initial( else: _json = body - _request = build_projects_validate_customization_tasks_request( + request = build_projects_validate_customization_tasks_request( project_name=project_name, content_type=content_type, api_version=self._config.api_version, @@ -4876,11 +4876,11 @@ async def _validate_customization_tasks_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4897,9 +4897,9 @@ async def _validate_customization_tasks_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @overload async def begin_validate_customization_tasks( @@ -5252,13 +5252,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore class DeploymentEnvironmentsOperations: @@ -5346,7 +5346,7 @@ def list_all_environments( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_all_environments_request( + request = build_deployment_environments_list_all_environments_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -5358,7 +5358,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5370,7 +5370,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5378,9 +5378,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5390,11 +5390,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5479,7 +5479,7 @@ def list_environments( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environments_request( + request = build_deployment_environments_list_environments_request( project_name=project_name, user_id=user_id, top=top, @@ -5492,7 +5492,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5504,7 +5504,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5512,9 +5512,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5524,11 +5524,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5609,7 +5609,7 @@ async def get_environment( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_deployment_environments_get_environment_request( + request = build_deployment_environments_get_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -5620,11 +5620,11 @@ async def get_environment( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5641,9 +5641,9 @@ async def get_environment( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) async def _create_or_update_environment_initial( self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any @@ -5670,7 +5670,7 @@ async def _create_or_update_environment_initial( else: _json = body - _request = build_deployment_environments_create_or_update_environment_request( + request = build_deployment_environments_create_or_update_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -5684,11 +5684,11 @@ async def _create_or_update_environment_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5708,9 +5708,9 @@ async def _create_or_update_environment_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @overload async def begin_create_or_update_environment( @@ -6050,13 +6050,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _delete_environment_initial( self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any @@ -6074,7 +6074,7 @@ async def _delete_environment_initial( cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_deployment_environments_delete_environment_request( + request = build_deployment_environments_delete_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -6085,11 +6085,11 @@ async def _delete_environment_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6113,9 +6113,9 @@ async def _delete_environment_initial( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) - return deserialized # type: ignore + return deserialized @distributed_trace_async async def begin_delete_environment( @@ -6211,13 +6211,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller[JSON].from_continuation_token( + return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_catalogs(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable[JSON]: @@ -6257,7 +6257,7 @@ def list_catalogs(self, project_name: str, *, top: Optional[int] = None, **kwarg def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_catalogs_request( + request = build_deployment_environments_list_catalogs_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -6269,7 +6269,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6281,7 +6281,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6289,9 +6289,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6301,11 +6301,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6353,7 +6353,7 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_deployment_environments_get_catalog_request( + request = build_deployment_environments_get_catalog_request( project_name=project_name, catalog_name=catalog_name, api_version=self._config.api_version, @@ -6363,11 +6363,11 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6384,9 +6384,9 @@ async def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_environment_definitions( @@ -6456,7 +6456,7 @@ def list_environment_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environment_definitions_request( + request = build_deployment_environments_list_environment_definitions_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -6468,7 +6468,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6480,7 +6480,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6488,9 +6488,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6500,11 +6500,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6588,7 +6588,7 @@ def list_environment_definitions_by_catalog( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environment_definitions_by_catalog_request( + request = build_deployment_environments_list_environment_definitions_by_catalog_request( project_name=project_name, catalog_name=catalog_name, top=top, @@ -6601,7 +6601,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6613,7 +6613,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6621,9 +6621,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6633,11 +6633,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6717,7 +6717,7 @@ async def get_environment_definition( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_deployment_environments_get_environment_definition_request( + request = build_deployment_environments_get_environment_definition_request( project_name=project_name, catalog_name=catalog_name, definition_name=definition_name, @@ -6728,11 +6728,11 @@ async def get_environment_definition( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6749,9 +6749,9 @@ async def get_environment_definition( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_environment_types( @@ -6799,7 +6799,7 @@ def list_environment_types( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environment_types_request( + request = build_deployment_environments_list_environment_types_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -6811,7 +6811,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6823,7 +6823,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6831,9 +6831,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6843,11 +6843,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7162,7 +7162,7 @@ async def patch_environment( else: _json = body - _request = build_environments_patch_environment_request( + request = build_environments_patch_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -7175,11 +7175,11 @@ async def patch_environment( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7196,9 +7196,9 @@ async def patch_environment( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def get_outputs(self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any) -> JSON: @@ -7244,7 +7244,7 @@ async def get_outputs(self, project_name: str, environment_name: str, user_id: s cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_get_outputs_request( + request = build_environments_get_outputs_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -7255,11 +7255,11 @@ async def get_outputs(self, project_name: str, environment_name: str, user_id: s path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7276,9 +7276,9 @@ async def get_outputs(self, project_name: str, environment_name: str, user_id: s deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_operations( @@ -7391,7 +7391,7 @@ def list_operations( def prepare_request(next_link=None): if not next_link: - _request = build_environments_list_operations_request( + request = build_environments_list_operations_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -7406,7 +7406,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -7418,7 +7418,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -7426,9 +7426,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -7438,11 +7438,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7554,7 +7554,7 @@ async def get_operation( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_get_operation_request( + request = build_environments_get_operation_request( project_name=project_name, environment_name=environment_name, operation_id=operation_id, @@ -7566,11 +7566,11 @@ async def get_operation( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7587,9 +7587,9 @@ async def get_operation( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def get_logs_by_operation( @@ -7623,7 +7623,7 @@ async def get_logs_by_operation( cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_environments_get_logs_by_operation_request( + request = build_environments_get_logs_by_operation_request( project_name=project_name, environment_name=environment_name, operation_id=operation_id, @@ -7635,11 +7635,11 @@ async def get_logs_by_operation( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7653,9 +7653,9 @@ async def get_logs_by_operation( deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, cast(AsyncIterator[bytes], deserialized), {}) # type: ignore + return cls(pipeline_response, cast(AsyncIterator[bytes], deserialized), {}) - return cast(AsyncIterator[bytes], deserialized) # type: ignore + return cast(AsyncIterator[bytes], deserialized) @distributed_trace def list_actions( @@ -7708,7 +7708,7 @@ def list_actions( def prepare_request(next_link=None): if not next_link: - _request = build_environments_list_actions_request( + request = build_environments_list_actions_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -7721,7 +7721,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -7733,7 +7733,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -7741,9 +7741,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -7753,11 +7753,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7821,7 +7821,7 @@ async def get_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_get_action_request( + request = build_environments_get_action_request( project_name=project_name, environment_name=environment_name, action_name=action_name, @@ -7833,11 +7833,11 @@ async def get_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7854,9 +7854,9 @@ async def get_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace_async async def skip_action( # pylint: disable=inconsistent-return-statements @@ -7890,7 +7890,7 @@ async def skip_action( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_environments_skip_action_request( + request = build_environments_skip_action_request( project_name=project_name, environment_name=environment_name, action_name=action_name, @@ -7902,11 +7902,11 @@ async def skip_action( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7918,7 +7918,7 @@ async def skip_action( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, None, {}) @distributed_trace_async async def delay_action( @@ -7979,7 +7979,7 @@ async def delay_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_delay_action_request( + request = build_environments_delay_action_request( project_name=project_name, environment_name=environment_name, action_name=action_name, @@ -7992,11 +7992,11 @@ async def delay_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8013,6 +8013,6 @@ async def delay_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py index 3ea2bac7681..e484ffe29e5 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py +++ b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py @@ -164,7 +164,7 @@ def build_dev_boxes_get_pool_request(project_name: str, pool_name: str, **kwargs return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_schedules_by_project_request( # pylint: disable=name-too-long +def build_dev_boxes_list_schedules_by_project_request( project_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -278,7 +278,7 @@ def build_dev_boxes_get_schedule_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_all_dev_boxes_request( # pylint: disable=name-too-long +def build_dev_boxes_list_all_dev_boxes_request( *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -303,7 +303,7 @@ def build_dev_boxes_list_all_dev_boxes_request( # pylint: disable=name-too-long return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_all_dev_boxes_by_user_request( # pylint: disable=name-too-long +def build_dev_boxes_list_all_dev_boxes_by_user_request( user_id: str = "me", *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -733,7 +733,7 @@ def build_dev_boxes_repair_dev_box_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_list_customization_groups_request( # pylint: disable=name-too-long +def build_dev_boxes_list_customization_groups_request( project_name: str, dev_box_name: str, user_id: str = "me", *, include: Optional[List[str]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -784,7 +784,7 @@ def build_dev_boxes_list_customization_groups_request( # pylint: disable=name-t return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_get_customization_group_request( # pylint: disable=name-too-long +def build_dev_boxes_get_customization_group_request( project_name: str, dev_box_name: str, customization_group_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -841,7 +841,7 @@ def build_dev_boxes_get_customization_group_request( # pylint: disable=name-too return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_create_customization_group_request( # pylint: disable=name-too-long +def build_dev_boxes_create_customization_group_request( project_name: str, dev_box_name: str, customization_group_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -901,7 +901,7 @@ def build_dev_boxes_create_customization_group_request( # pylint: disable=name- return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_get_customization_task_log_request( # pylint: disable=name-too-long +def build_dev_boxes_get_customization_task_log_request( project_name: str, dev_box_name: str, customization_group_name: str, @@ -971,7 +971,7 @@ def build_dev_boxes_get_customization_task_log_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_get_remote_connection_request( # pylint: disable=name-too-long +def build_dev_boxes_get_remote_connection_request( project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1232,7 +1232,7 @@ def build_dev_boxes_delay_action_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_dev_boxes_delay_all_actions_request( # pylint: disable=name-too-long +def build_dev_boxes_delay_all_actions_request( project_name: str, dev_box_name: str, user_id: str = "me", *, until: datetime.datetime, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1398,7 +1398,7 @@ def build_dev_boxes_get_operation_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_projects_list_customization_task_definitions_request( # pylint: disable=name-too-long +def build_projects_list_customization_task_definitions_request( project_name: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1433,7 +1433,7 @@ def build_projects_list_customization_task_definitions_request( # pylint: disab return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_projects_get_customization_task_definition_request( # pylint: disable=name-too-long +def build_projects_get_customization_task_definition_request( project_name: str, catalog_name: str, task_name: str, @@ -1487,9 +1487,7 @@ def build_projects_get_customization_task_definition_request( # pylint: disable return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_projects_validate_customization_tasks_request( # pylint: disable=name-too-long - project_name: str, **kwargs: Any -) -> HttpRequest: +def build_projects_validate_customization_tasks_request(project_name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1523,7 +1521,7 @@ def build_projects_validate_customization_tasks_request( # pylint: disable=name return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_list_all_environments_request( # pylint: disable=name-too-long +def build_deployment_environments_list_all_environments_request( project_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1558,7 +1556,7 @@ def build_deployment_environments_list_all_environments_request( # pylint: disa return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_list_environments_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environments_request( project_name: str, user_id: str = "me", *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1601,7 +1599,7 @@ def build_deployment_environments_list_environments_request( # pylint: disable= return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_get_environment_request( # pylint: disable=name-too-long +def build_deployment_environments_get_environment_request( project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1650,7 +1648,7 @@ def build_deployment_environments_get_environment_request( # pylint: disable=na return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_create_or_update_environment_request( # pylint: disable=name-too-long +def build_deployment_environments_create_or_update_environment_request( project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1702,7 +1700,7 @@ def build_deployment_environments_create_or_update_environment_request( # pylin return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_delete_environment_request( # pylint: disable=name-too-long +def build_deployment_environments_delete_environment_request( project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1751,7 +1749,7 @@ def build_deployment_environments_delete_environment_request( # pylint: disable return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_list_catalogs_request( # pylint: disable=name-too-long +def build_deployment_environments_list_catalogs_request( project_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1786,7 +1784,7 @@ def build_deployment_environments_list_catalogs_request( # pylint: disable=name return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_get_catalog_request( # pylint: disable=name-too-long +def build_deployment_environments_get_catalog_request( project_name: str, catalog_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1827,7 +1825,7 @@ def build_deployment_environments_get_catalog_request( # pylint: disable=name-t return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_list_environment_definitions_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environment_definitions_request( project_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1862,7 +1860,7 @@ def build_deployment_environments_list_environment_definitions_request( # pylin return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_list_environment_definitions_by_catalog_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environment_definitions_by_catalog_request( project_name: str, catalog_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1905,7 +1903,7 @@ def build_deployment_environments_list_environment_definitions_by_catalog_reques return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_get_environment_definition_request( # pylint: disable=name-too-long +def build_deployment_environments_get_environment_definition_request( project_name: str, catalog_name: str, definition_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1954,7 +1952,7 @@ def build_deployment_environments_get_environment_definition_request( # pylint: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployment_environments_list_environment_types_request( # pylint: disable=name-too-long +def build_deployment_environments_list_environment_types_request( project_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1989,7 +1987,7 @@ def build_deployment_environments_list_environment_types_request( # pylint: dis return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_patch_environment_request( # pylint: disable=name-too-long +def build_environments_patch_environment_request( project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2085,7 +2083,7 @@ def build_environments_get_outputs_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_list_operations_request( # pylint: disable=name-too-long +def build_environments_list_operations_request( project_name: str, environment_name: str, user_id: str = "me", @@ -2201,7 +2199,7 @@ def build_environments_get_operation_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_environments_get_logs_by_operation_request( # pylint: disable=name-too-long +def build_environments_get_logs_by_operation_request( project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2531,7 +2529,7 @@ def list_projects( def prepare_request(next_link=None): if not next_link: - _request = build_dev_center_list_projects_request( + request = build_dev_center_list_projects_request( filter=filter, top=top, api_version=self._config.api_version, @@ -2543,7 +2541,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -2555,7 +2553,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -2563,9 +2561,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -2575,11 +2573,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2629,7 +2627,7 @@ def get_project(self, project_name: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_center_get_project_request( + request = build_dev_center_get_project_request( project_name=project_name, api_version=self._config.api_version, headers=_headers, @@ -2638,11 +2636,11 @@ def get_project(self, project_name: str, **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2659,9 +2657,9 @@ def get_project(self, project_name: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) class DevBoxesOperations: # pylint: disable=too-many-public-methods @@ -2767,7 +2765,7 @@ def list_pools( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_pools_request( + request = build_dev_boxes_list_pools_request( project_name=project_name, top=top, filter=filter, @@ -2780,7 +2778,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -2792,7 +2790,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -2800,9 +2798,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -2812,11 +2810,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2908,7 +2906,7 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_pool_request( + request = build_dev_boxes_get_pool_request( project_name=project_name, pool_name=pool_name, api_version=self._config.api_version, @@ -2918,11 +2916,11 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2939,9 +2937,9 @@ def get_pool(self, project_name: str, pool_name: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_schedules_by_project( @@ -2997,7 +2995,7 @@ def list_schedules_by_project( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_schedules_by_project_request( + request = build_dev_boxes_list_schedules_by_project_request( project_name=project_name, top=top, filter=filter, @@ -3010,7 +3008,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3022,7 +3020,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3030,9 +3028,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3042,11 +3040,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3122,7 +3120,7 @@ def list_schedules( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_schedules_request( + request = build_dev_boxes_list_schedules_request( project_name=project_name, pool_name=pool_name, top=top, @@ -3136,7 +3134,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3148,7 +3146,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3156,9 +3154,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3168,11 +3166,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3234,7 +3232,7 @@ def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, ** cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_schedule_request( + request = build_dev_boxes_get_schedule_request( project_name=project_name, pool_name=pool_name, schedule_name=schedule_name, @@ -3245,11 +3243,11 @@ def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, ** path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3266,9 +3264,9 @@ def get_schedule(self, project_name: str, pool_name: str, schedule_name: str, ** deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_all_dev_boxes( @@ -3370,7 +3368,7 @@ def list_all_dev_boxes( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_all_dev_boxes_request( + request = build_dev_boxes_list_all_dev_boxes_request( filter=filter, top=top, api_version=self._config.api_version, @@ -3382,7 +3380,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3394,7 +3392,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3402,9 +3400,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3414,11 +3412,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3535,7 +3533,7 @@ def list_all_dev_boxes_by_user( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_all_dev_boxes_by_user_request( + request = build_dev_boxes_list_all_dev_boxes_by_user_request( user_id=user_id, filter=filter, top=top, @@ -3548,7 +3546,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3560,7 +3558,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3568,9 +3566,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3580,11 +3578,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3709,7 +3707,7 @@ def list_dev_boxes( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_dev_boxes_request( + request = build_dev_boxes_list_dev_boxes_request( project_name=project_name, user_id=user_id, filter=filter, @@ -3723,7 +3721,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -3735,7 +3733,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -3743,9 +3741,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -3755,11 +3753,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3870,7 +3868,7 @@ def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = "me", cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_dev_box_request( + request = build_dev_boxes_get_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -3881,11 +3879,11 @@ def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = "me", path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3902,9 +3900,9 @@ def get_dev_box(self, project_name: str, dev_box_name: str, user_id: str = "me", deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) def _create_dev_box_initial( self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any @@ -3931,7 +3929,7 @@ def _create_dev_box_initial( else: _json = body - _request = build_dev_boxes_create_dev_box_request( + request = build_dev_boxes_create_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -3945,11 +3943,11 @@ def _create_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4470,13 +4468,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _delete_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -4494,7 +4492,7 @@ def _delete_dev_box_initial( cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_dev_boxes_delete_dev_box_request( + request = build_dev_boxes_delete_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -4505,11 +4503,11 @@ def _delete_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4533,9 +4531,9 @@ def _delete_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) - return deserialized # type: ignore + return deserialized @distributed_trace def begin_delete_dev_box( @@ -4636,13 +4634,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: error_map = { @@ -4658,7 +4656,7 @@ def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_start_dev_box_request( + request = build_dev_boxes_start_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -4669,11 +4667,11 @@ def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4693,9 +4691,9 @@ def _start_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def begin_start_dev_box( @@ -4796,13 +4794,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _stop_dev_box_initial( self, @@ -4826,7 +4824,7 @@ def _stop_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_stop_dev_box_request( + request = build_dev_boxes_stop_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -4838,11 +4836,11 @@ def _stop_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -4862,9 +4860,9 @@ def _stop_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def begin_stop_dev_box( @@ -4974,13 +4972,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _restart_dev_box_initial( self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any @@ -4998,7 +4996,7 @@ def _restart_dev_box_initial( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_restart_dev_box_request( + request = build_dev_boxes_restart_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -5009,11 +5007,11 @@ def _restart_dev_box_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5033,9 +5031,9 @@ def _restart_dev_box_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def begin_restart_dev_box( @@ -5136,13 +5134,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: error_map = { @@ -5158,7 +5156,7 @@ def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_repair_dev_box_request( + request = build_dev_boxes_repair_dev_box_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -5169,11 +5167,11 @@ def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5193,9 +5191,9 @@ def _repair_dev_box_initial(self, project_name: str, dev_box_name: str, user_id: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def begin_repair_dev_box( @@ -5297,13 +5295,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_customization_groups( @@ -5383,7 +5381,7 @@ def list_customization_groups( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_customization_groups_request( + request = build_dev_boxes_list_customization_groups_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -5397,7 +5395,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -5409,7 +5407,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -5417,9 +5415,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -5429,11 +5427,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5514,7 +5512,7 @@ def get_customization_group( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_customization_group_request( + request = build_dev_boxes_get_customization_group_request( project_name=project_name, dev_box_name=dev_box_name, customization_group_name=customization_group_name, @@ -5526,11 +5524,11 @@ def get_customization_group( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5547,9 +5545,9 @@ def get_customization_group( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @overload def create_customization_group( @@ -5838,7 +5836,7 @@ def create_customization_group( else: _json = body - _request = build_dev_boxes_create_customization_group_request( + request = build_dev_boxes_create_customization_group_request( project_name=project_name, dev_box_name=dev_box_name, customization_group_name=customization_group_name, @@ -5853,11 +5851,11 @@ def create_customization_group( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5874,9 +5872,9 @@ def create_customization_group( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def get_customization_task_log( @@ -5918,7 +5916,7 @@ def get_customization_task_log( cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_customization_task_log_request( + request = build_dev_boxes_get_customization_task_log_request( project_name=project_name, dev_box_name=dev_box_name, customization_group_name=customization_group_name, @@ -5931,11 +5929,11 @@ def get_customization_task_log( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -5949,9 +5947,9 @@ def get_customization_task_log( deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) # type: ignore + return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) - return cast(Iterator[bytes], deserialized) # type: ignore + return cast(Iterator[bytes], deserialized) @distributed_trace def get_remote_connection(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> JSON: @@ -5991,7 +5989,7 @@ def get_remote_connection(self, project_name: str, dev_box_name: str, user_id: s cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_remote_connection_request( + request = build_dev_boxes_get_remote_connection_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -6002,11 +6000,11 @@ def get_remote_connection(self, project_name: str, dev_box_name: str, user_id: s path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6023,9 +6021,9 @@ def get_remote_connection(self, project_name: str, dev_box_name: str, user_id: s deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_actions(self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any) -> Iterable[JSON]: @@ -6080,7 +6078,7 @@ def list_actions(self, project_name: str, dev_box_name: str, user_id: str = "me" def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_actions_request( + request = build_dev_boxes_list_actions_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -6093,7 +6091,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6105,7 +6103,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6113,9 +6111,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6125,11 +6123,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6197,7 +6195,7 @@ def get_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_action_request( + request = build_dev_boxes_get_action_request( project_name=project_name, dev_box_name=dev_box_name, action_name=action_name, @@ -6209,11 +6207,11 @@ def get_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6230,9 +6228,9 @@ def get_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def skip_action( # pylint: disable=inconsistent-return-statements @@ -6266,7 +6264,7 @@ def skip_action( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_dev_boxes_skip_action_request( + request = build_dev_boxes_skip_action_request( project_name=project_name, dev_box_name=dev_box_name, action_name=action_name, @@ -6278,11 +6276,11 @@ def skip_action( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6294,7 +6292,7 @@ def skip_action( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, None, {}) @distributed_trace def delay_action( @@ -6359,7 +6357,7 @@ def delay_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_delay_action_request( + request = build_dev_boxes_delay_action_request( project_name=project_name, dev_box_name=dev_box_name, action_name=action_name, @@ -6372,11 +6370,11 @@ def delay_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6393,9 +6391,9 @@ def delay_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def delay_all_actions( @@ -6472,7 +6470,7 @@ def delay_all_actions( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_delay_all_actions_request( + request = build_dev_boxes_delay_all_actions_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -6486,7 +6484,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6498,7 +6496,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6506,9 +6504,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6518,11 +6516,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6706,7 +6704,7 @@ def list_operations( def prepare_request(next_link=None): if not next_link: - _request = build_dev_boxes_list_operations_request( + request = build_dev_boxes_list_operations_request( project_name=project_name, dev_box_name=dev_box_name, user_id=user_id, @@ -6721,7 +6719,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -6733,7 +6731,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -6741,9 +6739,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -6753,11 +6751,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6928,7 +6926,7 @@ def get_operation( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_dev_boxes_get_operation_request( + request = build_dev_boxes_get_operation_request( project_name=project_name, dev_box_name=dev_box_name, operation_id=operation_id, @@ -6940,11 +6938,11 @@ def get_operation( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -6961,9 +6959,9 @@ def get_operation( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) class ProjectsOperations: @@ -7040,7 +7038,7 @@ def list_customization_task_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_projects_list_customization_task_definitions_request( + request = build_projects_list_customization_task_definitions_request( project_name=project_name, filter=filter, api_version=self._config.api_version, @@ -7052,7 +7050,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -7064,7 +7062,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -7072,9 +7070,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -7084,11 +7082,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7170,7 +7168,7 @@ def get_customization_task_definition( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_projects_get_customization_task_definition_request( + request = build_projects_get_customization_task_definition_request( project_name=project_name, catalog_name=catalog_name, task_name=task_name, @@ -7183,11 +7181,11 @@ def get_customization_task_definition( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7204,9 +7202,9 @@ def get_customization_task_definition( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) def _validate_customization_tasks_initial(self, project_name: str, body: Union[JSON, IO], **kwargs: Any) -> JSON: error_map = { @@ -7231,7 +7229,7 @@ def _validate_customization_tasks_initial(self, project_name: str, body: Union[J else: _json = body - _request = build_projects_validate_customization_tasks_request( + request = build_projects_validate_customization_tasks_request( project_name=project_name, content_type=content_type, api_version=self._config.api_version, @@ -7243,11 +7241,11 @@ def _validate_customization_tasks_initial(self, project_name: str, body: Union[J path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7264,9 +7262,9 @@ def _validate_customization_tasks_initial(self, project_name: str, body: Union[J deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @overload def begin_validate_customization_tasks( @@ -7619,13 +7617,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore class DeploymentEnvironmentsOperations: @@ -7711,7 +7709,7 @@ def list_all_environments(self, project_name: str, *, top: Optional[int] = None, def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_all_environments_request( + request = build_deployment_environments_list_all_environments_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -7723,7 +7721,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -7735,7 +7733,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -7743,9 +7741,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -7755,11 +7753,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7844,7 +7842,7 @@ def list_environments( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environments_request( + request = build_deployment_environments_list_environments_request( project_name=project_name, user_id=user_id, top=top, @@ -7857,7 +7855,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -7869,7 +7867,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -7877,9 +7875,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -7889,11 +7887,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -7972,7 +7970,7 @@ def get_environment(self, project_name: str, environment_name: str, user_id: str cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_deployment_environments_get_environment_request( + request = build_deployment_environments_get_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -7983,11 +7981,11 @@ def get_environment(self, project_name: str, environment_name: str, user_id: str path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8004,9 +8002,9 @@ def get_environment(self, project_name: str, environment_name: str, user_id: str deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) def _create_or_update_environment_initial( self, project_name: str, environment_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any @@ -8033,7 +8031,7 @@ def _create_or_update_environment_initial( else: _json = body - _request = build_deployment_environments_create_or_update_environment_request( + request = build_deployment_environments_create_or_update_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -8047,11 +8045,11 @@ def _create_or_update_environment_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8071,9 +8069,9 @@ def _create_or_update_environment_initial( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), response_headers) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @overload def begin_create_or_update_environment( @@ -8413,13 +8411,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _delete_environment_initial( self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any @@ -8437,7 +8435,7 @@ def _delete_environment_initial( cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) - _request = build_deployment_environments_delete_environment_request( + request = build_deployment_environments_delete_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -8448,11 +8446,11 @@ def _delete_environment_initial( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8476,9 +8474,9 @@ def _delete_environment_initial( deserialized = None if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) - return deserialized # type: ignore + return deserialized @distributed_trace def begin_delete_environment( @@ -8573,13 +8571,13 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller[JSON].from_continuation_token( + return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_catalogs(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> Iterable[JSON]: @@ -8619,7 +8617,7 @@ def list_catalogs(self, project_name: str, *, top: Optional[int] = None, **kwarg def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_catalogs_request( + request = build_deployment_environments_list_catalogs_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -8631,7 +8629,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -8643,7 +8641,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -8651,9 +8649,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -8663,11 +8661,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8715,7 +8713,7 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JS cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_deployment_environments_get_catalog_request( + request = build_deployment_environments_get_catalog_request( project_name=project_name, catalog_name=catalog_name, api_version=self._config.api_version, @@ -8725,11 +8723,11 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JS path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8746,9 +8744,9 @@ def get_catalog(self, project_name: str, catalog_name: str, **kwargs: Any) -> JS deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_environment_definitions( @@ -8818,7 +8816,7 @@ def list_environment_definitions( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environment_definitions_request( + request = build_deployment_environments_list_environment_definitions_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -8830,7 +8828,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -8842,7 +8840,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -8850,9 +8848,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -8862,11 +8860,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -8950,7 +8948,7 @@ def list_environment_definitions_by_catalog( def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environment_definitions_by_catalog_request( + request = build_deployment_environments_list_environment_definitions_by_catalog_request( project_name=project_name, catalog_name=catalog_name, top=top, @@ -8963,7 +8961,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -8975,7 +8973,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -8983,9 +8981,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -8995,11 +8993,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -9079,7 +9077,7 @@ def get_environment_definition( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_deployment_environments_get_environment_definition_request( + request = build_deployment_environments_get_environment_definition_request( project_name=project_name, catalog_name=catalog_name, definition_name=definition_name, @@ -9090,11 +9088,11 @@ def get_environment_definition( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -9111,9 +9109,9 @@ def get_environment_definition( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_environment_types(self, project_name: str, *, top: Optional[int] = None, **kwargs: Any) -> Iterable[JSON]: @@ -9159,7 +9157,7 @@ def list_environment_types(self, project_name: str, *, top: Optional[int] = None def prepare_request(next_link=None): if not next_link: - _request = build_deployment_environments_list_environment_types_request( + request = build_deployment_environments_list_environment_types_request( project_name=project_name, top=top, api_version=self._config.api_version, @@ -9171,7 +9169,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -9183,7 +9181,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -9191,9 +9189,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -9203,11 +9201,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -9522,7 +9520,7 @@ def patch_environment( else: _json = body - _request = build_environments_patch_environment_request( + request = build_environments_patch_environment_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -9535,11 +9533,11 @@ def patch_environment( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -9556,9 +9554,9 @@ def patch_environment( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def get_outputs(self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any) -> JSON: @@ -9604,7 +9602,7 @@ def get_outputs(self, project_name: str, environment_name: str, user_id: str = " cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_get_outputs_request( + request = build_environments_get_outputs_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -9615,11 +9613,11 @@ def get_outputs(self, project_name: str, environment_name: str, user_id: str = " path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -9636,9 +9634,9 @@ def get_outputs(self, project_name: str, environment_name: str, user_id: str = " deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def list_operations( @@ -9751,7 +9749,7 @@ def list_operations( def prepare_request(next_link=None): if not next_link: - _request = build_environments_list_operations_request( + request = build_environments_list_operations_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -9766,7 +9764,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -9778,7 +9776,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -9786,9 +9784,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -9798,11 +9796,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -9914,7 +9912,7 @@ def get_operation( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_get_operation_request( + request = build_environments_get_operation_request( project_name=project_name, environment_name=environment_name, operation_id=operation_id, @@ -9926,11 +9924,11 @@ def get_operation( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -9947,9 +9945,9 @@ def get_operation( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def get_logs_by_operation( @@ -9983,7 +9981,7 @@ def get_logs_by_operation( cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_environments_get_logs_by_operation_request( + request = build_environments_get_logs_by_operation_request( project_name=project_name, environment_name=environment_name, operation_id=operation_id, @@ -9995,11 +9993,11 @@ def get_logs_by_operation( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -10013,9 +10011,9 @@ def get_logs_by_operation( deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) # type: ignore + return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) - return cast(Iterator[bytes], deserialized) # type: ignore + return cast(Iterator[bytes], deserialized) @distributed_trace def list_actions( @@ -10068,7 +10066,7 @@ def list_actions( def prepare_request(next_link=None): if not next_link: - _request = build_environments_list_actions_request( + request = build_environments_list_actions_request( project_name=project_name, environment_name=environment_name, user_id=user_id, @@ -10081,7 +10079,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -10093,7 +10091,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( + request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -10101,9 +10099,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) - return _request + return request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -10113,11 +10111,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - _request = prepare_request(next_link) + request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -10181,7 +10179,7 @@ def get_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_get_action_request( + request = build_environments_get_action_request( project_name=project_name, environment_name=environment_name, action_name=action_name, @@ -10193,11 +10191,11 @@ def get_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -10214,9 +10212,9 @@ def get_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized) @distributed_trace def skip_action( # pylint: disable=inconsistent-return-statements @@ -10250,7 +10248,7 @@ def skip_action( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_environments_skip_action_request( + request = build_environments_skip_action_request( project_name=project_name, environment_name=environment_name, action_name=action_name, @@ -10262,11 +10260,11 @@ def skip_action( # pylint: disable=inconsistent-return-statements path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -10278,7 +10276,7 @@ def skip_action( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, None, {}) @distributed_trace def delay_action( @@ -10339,7 +10337,7 @@ def delay_action( cls: ClsType[JSON] = kwargs.pop("cls", None) - _request = build_environments_delay_action_request( + request = build_environments_delay_action_request( project_name=project_name, environment_name=environment_name, action_name=action_name, @@ -10352,11 +10350,11 @@ def delay_action( path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + request.url = self._client.format_url(request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -10373,6 +10371,6 @@ def delay_action( deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore + return cls(pipeline_response, cast(JSON, deserialized), {}) - return cast(JSON, deserialized) # type: ignore + return cast(JSON, deserialized)