diff --git a/src/devcenter/HISTORY.rst b/src/devcenter/HISTORY.rst index 1bd085e71bc..7aaa3f15021 100644 --- a/src/devcenter/HISTORY.rst +++ b/src/devcenter/HISTORY.rst @@ -2,6 +2,10 @@ Release History =============== +6.2.0 +++++++ +* Update data plane API to v2024-10-01-preview + 6.1.0 ++++++ * Update control plane API to v2024-10-01-preview diff --git a/src/devcenter/azext_devcenter/__init__.py b/src/devcenter/azext_devcenter/__init__.py index e0b8ab5ea07..28d1d645ded 100644 --- a/src/devcenter/azext_devcenter/__init__.py +++ b/src/devcenter/azext_devcenter/__init__.py @@ -17,10 +17,9 @@ class DevCenterCommandsLoader(AzCommandsLoader): def __init__(self, cli_ctx=None): from azure.cli.core.commands import CliCommandType - from azext_devcenter._client_factory import cf_devcenter_cl devcenter_custom = CliCommandType( - operations_tmpl="azext_devcenter.custom#{}", client_factory=cf_devcenter_cl + operations_tmpl="azext_devcenter.custom#{}" ) parent = super(DevCenterCommandsLoader, self) parent.__init__(cli_ctx=cli_ctx, custom_command_type=devcenter_custom) @@ -44,7 +43,6 @@ def load_command_table(self, args): def load_arguments(self, command): from azext_devcenter._params import load_arguments - load_arguments(self, command) diff --git a/src/devcenter/azext_devcenter/_client_factory.py b/src/devcenter/azext_devcenter/_client_factory.py deleted file mode 100644 index 06ec9abead7..00000000000 --- a/src/devcenter/azext_devcenter/_client_factory.py +++ /dev/null @@ -1,61 +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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -from .utils import get_project_data -from ._validators import validate_endpoint - -# Data plane - - -def cf_devcenter_dataplane(cli_ctx, endpoint=None, dev_center=None, project_name=None): - from azure.cli.core._profile import Profile - from azext_devcenter.vendored_sdks.devcenter_dataplane import ( - DevCenterClient, - ) - - validate_endpoint(endpoint, dev_center) - - if endpoint is None and dev_center is not None: - project = get_project_data(cli_ctx, dev_center, project_name) - endpoint = project["devCenterUri"] - - profile = Profile(cli_ctx=cli_ctx) - - credential = profile.get_login_credentials(resource="https://devcenter.azure.com") - - return DevCenterClient(endpoint, credential[0]) - - -def cf_dev_center_dp(cli_ctx, dev_center, *_): - return cf_devcenter_dataplane(cli_ctx, dev_center).dev_center - - -def cf_dev_boxes_dp(cli_ctx, dev_center, *_): - return cf_devcenter_dataplane(cli_ctx, dev_center).dev_boxes - - -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_deployment_environment_operations_dp(cli_ctx, dev_center, *_): - return cf_devcenter_dataplane(cli_ctx, dev_center).deployment_environments - -# Control plane - - -def cf_devcenter_cl(cli_ctx, *_): - from azure.cli.core.commands.client_factory import get_mgmt_service_client - from azext_devcenter.vendored_sdks.devcenter import DevCenter - - return get_mgmt_service_client(cli_ctx, DevCenter) diff --git a/src/devcenter/azext_devcenter/_help.py b/src/devcenter/azext_devcenter/_help.py index 2a3e0b75ec3..358103919c6 100644 --- a/src/devcenter/azext_devcenter/_help.py +++ b/src/devcenter/azext_devcenter/_help.py @@ -49,6 +49,38 @@ --name "DevProject" """ +helps[ + "devcenter dev project list-abilities" +] = """ + type: command + short-summary: "List the signed-in user's permitted abilities in a project." + examples: + - name: List using dev center + text: |- + az devcenter dev project list-abilities --dev-center-name "ContosoDevCenter" --user-id "00000000-0000-0000-0000-000000000000" \ +--name "DevProject" + - name: List using endpoint + text: |- + az devcenter dev project list-abilities --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --user-id "00000000-0000-0000-0000-000000000000" \ +--name "DevProject" +""" + +helps[ + "devcenter dev project show-operation" +] = """ + type: command + short-summary: "Get the status of an operation." + examples: + - name: Get using dev center + text: |- + az devcenter dev project show-operation --dev-center-name "ContosoDevCenter" \ +--name "DevProject" --operation-id "f5dbdfab-fa0e-4831-8d13-25359aa5e680" + - name: Get using endpoint + text: |- + az devcenter dev project show-operation --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--name "DevProject" --operation-id "f5dbdfab-fa0e-4831-8d13-25359aa5e680" +""" + helps[ "devcenter dev pool" ] = """ @@ -182,13 +214,14 @@ - name: Get using dev center text: |- az devcenter dev dev-box show --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ - --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" - name: Get using endpoint text: |- az devcenter dev dev-box show --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" """ + helps[ "devcenter dev dev-box create" ] = """ @@ -214,7 +247,7 @@ - name: Delete using dev center text: |- az devcenter dev dev-box delete --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ - --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" - name: Delete using endpoint text: |- az devcenter dev dev-box delete --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ @@ -246,7 +279,7 @@ - name: Start using dev center text: |- az devcenter dev dev-box start --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ - --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" - name: Start using endpoint text: |- az devcenter dev dev-box start --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ @@ -262,7 +295,7 @@ - name: Restart using dev center text: |- az devcenter dev dev-box restart --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ - --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" - name: Restart using endpoint text: |- az devcenter dev dev-box restart --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ @@ -278,7 +311,7 @@ - name: Repair using dev center text: |- az devcenter dev dev-box repair --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ - --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" - name: Repair using endpoint text: |- az devcenter dev dev-box repair --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ @@ -294,7 +327,7 @@ - name: Stop using dev center text: |- az devcenter dev dev-box stop --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ - --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" - name: Stop using endpoint text: |- az devcenter dev dev-box stop --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ @@ -423,6 +456,70 @@ "schedule-default" --user-id "00000000-0000-0000-0000-000000000000" """ +helps[ + "devcenter dev dev-box capture-snapshot" +] = """ + type: command + short-summary: "Captures a manual snapshot of the dev box." + examples: + - name: Capture snapshot using dev center + text: |- + az devcenter dev dev-box capture-snapshot --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + - name: Capture snapshot using endpoint + text: |- + az devcenter dev dev-box capture-snapshot --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +""" + +helps[ + "devcenter dev dev-box restore-snapshot" +] = """ + type: command + short-summary: "Restores a dev box to a specified snapshot." + examples: + - name: Restore snapshot using dev center + text: |- + az devcenter dev dev-box restore-snapshot --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --snapshot-id "CPC_f5dbdfab-fa0e-4831-8d13-25359aa5e680" + - name: Restore snapshot using endpoint + text: |- + az devcenter dev dev-box restore-snapshot --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --snapshot-id "CPC_f5dbdfab-fa0e-4831-8d13-25359aa5e680" +""" + +helps[ + "devcenter dev dev-box show-snapshot" +] = """ + type: command + short-summary: "Get a snapshot by snapshot id." + examples: + - name: Get snapshot using dev center + text: |- + az devcenter dev dev-box show-snapshot --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --snapshot-id "CPC_f5dbdfab-fa0e-4831-8d13-25359aa5e680" + - name: Get snapshot using endpoint + text: |- + az devcenter dev dev-box show-snapshot --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --snapshot-id "CPC_f5dbdfab-fa0e-4831-8d13-25359aa5e680" +""" + +helps[ + "devcenter dev dev-box list-snapshot" +] = """ + type: command + short-summary: "List snapshots for a dev box" + examples: + - name: List snapshots using dev center + text: |- + az devcenter dev dev-box list-snapshot --name "MyDevBox" --dev-center-name "ContosoDevCenter" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + - name: List snapshots using endpoint + text: |- + az devcenter dev dev-box list-snapshot --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" +""" + helps[ "devcenter dev environment" ] = """ @@ -471,6 +568,7 @@ --name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" """ + helps[ "devcenter dev environment create" ] = """ @@ -603,6 +701,61 @@ --project-name "DevProject" """ +helps[ + "devcenter dev environment-type show" +] = """ + type: command + short-summary: "Get an environment type configured for a project." + examples: + - name: Get using dev center + text: |- + az devcenter dev environment-type show --dev-center-name "ContosoDevCenter" \ +--project-name "DevProject" --environment-type-name "foo" + - name: Get using endpoint + text: |- + az devcenter dev environment-type show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--project-name "DevProject" --environment-type-name "foo" +""" + +helps[ + "devcenter dev environment-type list-abilities" +] = """ + type: command + short-summary: "List the signed-in user's permitted abilities in an environment type." + examples: + - name: List using dev center + text: |- + az devcenter dev environment-type list-abilities --dev-center-name "ContosoDevCenter" \ +--project-name "DevProject" --environment-type-name "foo" --user-id "00000000-0000-0000-0000-000000000000" + - name: List using endpoint + text: |- + az devcenter dev environment-type list-abilities --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--project-name "DevProject" --environment-type-name "foo" --user-id "00000000-0000-0000-0000-000000000000" +""" + +helps[ + "devcenter dev image-build" +] = """ + type: group + short-summary: Manage image builds. +""" + +helps[ + "devcenter dev image-build show-log" +] = """ + type: command + short-summary: "Get the log for an imaging build task." + examples: + - name: Get using dev center + text: |- + az devcenter dev image-build show-log --dev-center-name "ContosoDevCenter" \ +--project-name "DevProject" --image-build-log-id "f5dbdfab-fa0e-4831-8d13-25359aa5e680" + - name: Get using endpoint + text: |- + az devcenter dev image-build show-log --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" \ +--project-name "DevProject" --image-build-log-id "f5dbdfab-fa0e-4831-8d13-25359aa5e680" +""" + helps[ "devcenter dev environment-definition" ] = """ diff --git a/src/devcenter/azext_devcenter/_params.py b/src/devcenter/azext_devcenter/_params.py index 097d892e9de..bdc5f4df0c7 100644 --- a/src/devcenter/azext_devcenter/_params.py +++ b/src/devcenter/azext_devcenter/_params.py @@ -65,6 +65,49 @@ def load_arguments(self, _): help="The dev center " "project upon which to execute operations.", ) + with self.argument_context("devcenter dev project show-operation") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "project_name", + options_list=["--name", "-n"], + type=str, + help="The dev center " "project upon which to execute operations.", + ) + c.argument( + "operation_id", + type=str, + help="The id of the operation on a project.", + ) + + with self.argument_context("devcenter dev project list-abilities") as c: + c.argument( + "dev_center", + arg_type=dev_center_type, + ) + c.argument( + "endpoint", + arg_type=endpoint, + ) + c.argument( + "project_name", + options_list=["--name", "-n"], + type=str, + help="The dev center " "project upon which to execute operations.", + ) + 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.", + ) + with self.argument_context("devcenter dev pool list") as c: c.argument( "dev_center", @@ -218,6 +261,12 @@ def load_arguments(self, _): type=str, help="The name of the dev box pool this machine belongs to.", ) + c.argument( + "local_administrator", + arg_type=get_enum_type(["Enabled", "Disabled"]), + help="Indicates whether the " + "owner of the Dev Box is a local administrator.", + ) with self.argument_context("devcenter dev dev-box delete") as c: c.argument( @@ -595,6 +644,122 @@ def load_arguments(self, _): help="The id of the operation on a dev box.", ) + with self.argument_context("devcenter dev dev-box capture-snapshot") 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( + "dev_box_name", + options_list=["--name", "-n", "--dev-box-name"], + type=str, + help="The name of a dev " "box.", + ) + + with self.argument_context("devcenter dev dev-box restore-snapshot") 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( + "dev_box_name", + options_list=["--name", "-n", "--dev-box-name"], + type=str, + help="The name of a dev " "box.", + ) + c.argument( + "snapshot_id", + options_list=["--snapshot-id", "-s"], + type=str, + help="Required parameter that specifies the snapshot id to use for the restore operation.", + ) + + with self.argument_context("devcenter dev dev-box show-snapshot") 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( + "dev_box_name", + options_list=["--name", "-n", "--dev-box-name"], + type=str, + help="The name of a dev " "box.", + ) + c.argument( + "snapshot_id", + options_list=["--snapshot-id", "-s"], + type=str, + help="Required parameter that specifies the snapshot id to use for the restore operation.", + ) + + with self.argument_context("devcenter dev dev-box list-snapshot") 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( + "dev_box_name", + options_list=["--name", "-n", "--dev-box-name"], + type=str, + help="The name of a dev " "box.", + ) + with self.argument_context("devcenter dev environment list") as c: c.argument( "dev_center", @@ -888,6 +1053,60 @@ def load_arguments(self, _): arg_type=endpoint, ) + with self.argument_context("devcenter dev environment-type show") 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("environment_type_name", options_list=[ + "-n", "--name", "--environment-type-name"], type=str, help="Environment type.") + + with self.argument_context("devcenter dev environment-type list-abilities") 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("environment_type_name", options_list=[ + "-n", "--name", "--environment-type-name"], type=str, help="Environment type.") + 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.", + ) + + with self.argument_context("devcenter dev image-build show-log") 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("image_build_log_id", options_list=[ + "-i", "--image-build-log-id"], type=str, help="An imaging build log id.") + with self.argument_context("devcenter dev environment list-operation") as c: c.argument( "dev_center", diff --git a/src/devcenter/azext_devcenter/aaz/latest/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/__init__.py index 5757aea3175..6439dd20eb7 100644 --- a/src/devcenter/azext_devcenter/aaz/latest/__init__.py +++ b/src/devcenter/azext_devcenter/aaz/latest/__init__.py @@ -4,3 +4,8 @@ # # Code generated by aaz-dev-tools # -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from ._clients import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/_clients.py b/src/devcenter/azext_devcenter/aaz/latest/_clients.py new file mode 100644 index 00000000000..fb602377da0 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/_clients.py @@ -0,0 +1,46 @@ +# -------------------------------------------------------------------------------------------- +# 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_client("AAZMicrosoftDevcenterDataPlaneClient_devcenter") +class AAZMicrosoftDevcenterDataPlaneClient(AAZBaseClient): + _CLOUD_HOST_TEMPLATES = { + CloudNameEnum.AzureCloud: "https://{endpoint}", + } + + _AAD_CREDENTIAL_SCOPES = [ + "https://devcenter.azure.com/.default", + ] + + @classmethod + def _build_base_url(cls, ctx, **kwargs): + endpoint = None + if not endpoint: + endpoint = cls._CLOUD_HOST_TEMPLATES.get(ctx.cli_ctx.cloud.name, None) + return endpoint + + @classmethod + def _build_configuration(cls, ctx, credential, **kwargs): + return AAZClientConfiguration( + credential=credential, + credential_scopes=cls._AAD_CREDENTIAL_SCOPES, + **kwargs + ) + + +class _AAZMicrosoftDevcenterDataPlaneClientHelper: + """Helper class for AAZMicrosoftDevcenterDataPlaneClient""" + + +__all__ = [ + "AAZMicrosoftDevcenterDataPlaneClient", +] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/__cmd_group.py new file mode 100644 index 00000000000..6095dd715eb --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev", +) +class __CMDGroup(AAZCommandGroup): + """Manage devcenter developer resources. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_version.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/__init__.py similarity index 58% rename from src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_version.py rename to src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/__init__.py index c47f66669f1..5a9d61963d6 100644 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_version.py +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/__init__.py @@ -1,9 +1,11 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- +# -------------------------------------------------------------------------------------------- # 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- -VERSION = "1.0.0" +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/__cmd_group.py new file mode 100644 index 00000000000..7334af6db28 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev catalog", +) +class __CMDGroup(AAZCommandGroup): + """Manage catalogs. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/__init__.py new file mode 100644 index 00000000000..2df85698253 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * +from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/_list.py new file mode 100644 index 00000000000..ab449b3ab0c --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/_list.py @@ -0,0 +1,192 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev catalog list", +) +class List(AAZCommand): + """List all of the catalogs available for a project. + + :example: List + az devcenter dev catalog list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/catalogs", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsListCatalogsByProject(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 EnvironmentsListCatalogsByProject(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/catalogs", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/_show.py new file mode 100644 index 00000000000..ec8f46f924e --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/catalog/_show.py @@ -0,0 +1,197 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev catalog show", +) +class Show(AAZCommand): + """Get the specified catalog within the project. + + :example: Get + az devcenter dev catalog show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --catalog-name "foo" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/catalogs/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.catalog_name = AAZStrArg( + options=["-n", "--name", "--catalog-name"], + help="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, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetCatalog(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 EnvironmentsGetCatalog(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/catalogs/{catalogName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "catalogName", self.ctx.args.catalog_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/__cmd_group.py new file mode 100644 index 00000000000..7c031aa5ab0 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-group", +) +class __CMDGroup(AAZCommandGroup): + """Manage customization groups. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/__init__.py new file mode 100644 index 00000000000..aa2addc0fe6 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/__init__.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._create import * +from ._list import * +from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_create.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_create.py new file mode 100644 index 00000000000..f0cc5dbba6e --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_create.py @@ -0,0 +1,341 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-group create", +) +class Create(AAZCommand): + """Create customizations to the Dev Box. + + :example: Applies customizations to the dev box + az devcenter dev customization-group create --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --dev-box-name "myDevBox" --tasks "[{\\"name\\": \\"catalogName/choco\\", \\"displayName\\": \\"Install VS Code\\", \\"parameters\\": {\\"packageName\\": \\"vscode\\", \\"packageVersion\\": \\"1.0.0\\"}}, {\\"name\\": \\"catalogName/write-to-file\\", \\"runAs\\": \\"User\\"}]" --name "Provisioning" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/customizationgroups/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.customization_group_name = AAZStrArg( + options=["-n", "--name", "--customization-group-name"], + help="A customization group name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.dev_box_name = AAZStrArg( + options=["--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.tasks = AAZListArg( + options=["--tasks"], + arg_group="Body", + help="Tasks to apply. Note by default tasks are excluded from the response when listing customization groups. To include them, use the `include=tasks` query parameter.", + ) + + tasks = cls._args_schema.tasks + tasks.Element = AAZObjectArg() + + _element = cls._args_schema.tasks.Element + _element.display_name = AAZStrArg( + options=["display-name"], + help="Display name to help differentiate multiple instances of the same task.", + ) + _element.name = AAZStrArg( + options=["name"], + help="Name of the task.", + required=True, + ) + _element.parameters = AAZDictArg( + options=["parameters"], + help="Parameters for the task.", + ) + _element.run_as = AAZStrArg( + options=["run-as"], + help="What account to run the task as.", + enum={"System": "System", "User": "User"}, + ) + _element.timeout_in_seconds = AAZIntArg( + options=["timeout-in-seconds"], + help="Timeout, in seconds. Overrides any timeout provided on the task definition.", + ) + + parameters = cls._args_schema.tasks.Element.parameters + parameters.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DevBoxesCreateCustomizationGroup(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 DevBoxesCreateCustomizationGroup(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "customizationGroupName", self.ctx.args.customization_group_name, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("tasks", AAZListType, ".tasks") + + tasks = _builder.get(".tasks") + if tasks is not None: + tasks.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".tasks[]") + if _elements is not None: + _elements.set_prop("displayName", AAZStrType, ".display_name") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("parameters", AAZDictType, ".parameters") + _elements.set_prop("runAs", AAZStrType, ".run_as") + _elements.set_prop("timeoutInSeconds", AAZIntType, ".timeout_in_seconds") + + parameters = _builder.get(".tasks[].parameters") + if parameters is not None: + parameters.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + 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.end_time = AAZStrType( + serialized_name="endTime", + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + _schema_on_200.status = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.tasks = AAZListType() + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + + tasks = cls._schema_on_200.tasks + tasks.Element = AAZObjectType() + + _element = cls._schema_on_200.tasks.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + ) + _element.end_time = AAZStrType( + serialized_name="endTime", + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.log_uri = AAZStrType( + serialized_name="logUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.parameters = AAZDictType() + _element.run_as = AAZStrType( + serialized_name="runAs", + ) + _element.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + _element.status = AAZStrType( + flags={"read_only": True}, + ) + _element.timeout_in_seconds = AAZIntType( + serialized_name="timeoutInSeconds", + ) + + parameters = cls._schema_on_200.tasks.Element.parameters + parameters.Element = AAZStrType() + + return cls._schema_on_200 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_list.py new file mode 100644 index 00000000000..1065fb45038 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_list.py @@ -0,0 +1,285 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-group list", +) +class List(AAZCommand): + """List Lists customization groups on the Dev Box. Listed customization groups exclude + task information unless specified via the include parameter. + + :example: List + az devcenter dev customization-group list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --dev-box-name "myDevBox" --user-id "00000000-0000-0000-0000-000000000000" --include-tasks + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/customizationgroups", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + _args_schema.include = AAZStrArg( + options=["--include"], + help="Optional query parameter to specify what properties should be included in the response.", + enum={"tasks": "tasks"}, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesListCustomizationGroups(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 DevBoxesListCustomizationGroups(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "include", self.ctx.args.include, + ), + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.end_time = AAZStrType( + serialized_name="endTime", + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + _element.status = AAZStrType( + flags={"read_only": True}, + ) + _element.tasks = AAZListType() + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + + tasks = cls._schema_on_200.value.Element.tasks + tasks.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.tasks.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + ) + _element.end_time = AAZStrType( + serialized_name="endTime", + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.log_uri = AAZStrType( + serialized_name="logUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.parameters = AAZDictType() + _element.run_as = AAZStrType( + serialized_name="runAs", + ) + _element.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + _element.status = AAZStrType( + flags={"read_only": True}, + ) + _element.timeout_in_seconds = AAZIntType( + serialized_name="timeoutInSeconds", + ) + + parameters = cls._schema_on_200.value.Element.tasks.Element.parameters + parameters.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_show.py new file mode 100644 index 00000000000..65cb29eb6aa --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_group/_show.py @@ -0,0 +1,272 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-group show", +) +class Show(AAZCommand): + """Get Gets a customization group. + + :example: Get + az devcenter dev customization-group show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --dev-box-name "myDevBox" --name "Provisioning" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/customizationgroups/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.customization_group_name = AAZStrArg( + options=["-n", "--name", "--customization-group-name"], + help="A customization group name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.dev_box_name = AAZStrArg( + options=["--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DevBoxesGetCustomizationGroup(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 DevBoxesGetCustomizationGroup(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "customizationGroupName", self.ctx.args.customization_group_name, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.end_time = AAZStrType( + serialized_name="endTime", + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + _schema_on_200.status = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.tasks = AAZListType() + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + + tasks = cls._schema_on_200.tasks + tasks.Element = AAZObjectType() + + _element = cls._schema_on_200.tasks.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + ) + _element.end_time = AAZStrType( + serialized_name="endTime", + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.log_uri = AAZStrType( + serialized_name="logUri", + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.parameters = AAZDictType() + _element.run_as = AAZStrType( + serialized_name="runAs", + ) + _element.start_time = AAZStrType( + serialized_name="startTime", + flags={"read_only": True}, + ) + _element.status = AAZStrType( + flags={"read_only": True}, + ) + _element.timeout_in_seconds = AAZIntType( + serialized_name="timeoutInSeconds", + ) + + parameters = cls._schema_on_200.tasks.Element.parameters + parameters.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/__cmd_group.py new file mode 100644 index 00000000000..597aeee6c67 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-task", +) +class __CMDGroup(AAZCommandGroup): + """Manage customization tasks. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/__init__.py new file mode 100644 index 00000000000..ee74ea731d1 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * +from ._show import * +from ._show_logs import * +from ._validate import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_list.py new file mode 100644 index 00000000000..afe5e56e782 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_list.py @@ -0,0 +1,215 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-task list", +) +class List(AAZCommand): + """List all customization tasks available to the project. + + :example: List + az devcenter dev customization-task list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/customizationtasks", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesListCustomizationTaskDefinitionsByProject(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 DevBoxesListCustomizationTaskDefinitionsByProject(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/customizationTasks", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"read_only": True}, + ) + _element.description = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.parameters = AAZDictType() + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + + parameters = cls._schema_on_200.value.Element.parameters + parameters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.parameters.Element + _element.allowed = AAZListType() + _element.default = AAZStrType() + _element.description = AAZStrType() + _element.required = AAZBoolType( + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + allowed = cls._schema_on_200.value.Element.parameters.Element.allowed + allowed.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_show.py new file mode 100644 index 00000000000..7649e205f09 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_show.py @@ -0,0 +1,229 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-task show", +) +class Show(AAZCommand): + """Get a customization task. + + :example: Get + az devcenter dev customization-task show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --task-name "choco" --catalog-name "myCatalog" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/catalogs/{}/customizationtasks/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.catalog_name = AAZStrArg( + options=["--catalog-name"], + help="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.task_name = AAZStrArg( + options=["-n", "--name", "--task-name"], + help="Full name of the task: {catalogName}/{taskName}.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetCustomizationTaskDefinitions(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 DevBoxesGetCustomizationTaskDefinitions(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/catalogs/{catalogName}/customizationTasks/{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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "catalogName", self.ctx.args.catalog_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + 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", "2024-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.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"read_only": True}, + ) + _schema_on_200.description = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.parameters = AAZDictType() + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + + parameters = cls._schema_on_200.parameters + parameters.Element = AAZObjectType() + + _element = cls._schema_on_200.parameters.Element + _element.allowed = AAZListType() + _element.default = AAZStrType() + _element.description = AAZStrType() + _element.required = AAZBoolType( + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + allowed = cls._schema_on_200.parameters.Element.allowed + allowed.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_show_logs.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_show_logs.py new file mode 100644 index 00000000000..589f5b8015d --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_show_logs.py @@ -0,0 +1,232 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev customization-task show-logs", +) +class ShowLogs(AAZCommand): + """Get the log for a customization task. + + :example: Show logs + az devcenter dev customization-task show-logs --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --dev-box-name "myDevBox" --customization-group-name "Provisioning" --customization-task-id "91835dc0-ef5a-4f58-9e3a-099aea8481f4" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/customizationgroups/{}/logs/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.customization_group_name = AAZStrArg( + options=["-c", "--customization-group-name"], + help="A customization group name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.customization_task_id = AAZStrArg( + options=["-i", "--customization-task-id"], + help="A customization task ID.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$", + max_length=36, + min_length=36, + ), + ) + _args_schema.dev_box_name = AAZStrArg( + options=["--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetCustomizationTaskLog(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=False) + return result + + class DevBoxesGetCustomizationTaskLog(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}/logs/{customizationTaskId}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "customizationGroupName", self.ctx.args.customization_group_name, + required=True, + ), + **self.serialize_url_param( + "customizationTaskId", self.ctx.args.customization_task_id, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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 = AAZStrType() + + return cls._schema_on_200 + + +class _ShowLogsHelper: + """Helper class for ShowLogs""" + + +__all__ = ["ShowLogs"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_validate.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_validate.py new file mode 100644 index 00000000000..4fb01036e6b --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/customization_task/_validate.py @@ -0,0 +1,243 @@ +# -------------------------------------------------------------------------------------------- +# 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 * +import json + +@register_command( + "devcenter dev customization-task validate", +) +class Validate(AAZCommand): + """Validates a list of customization tasks. + + :example: Validate + az devcenter dev customization-task validate --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --tasks "[{\\"name\\": \\"catalogName/choco\\", \\"displayName\\": \\"Install VS Code\\", \\"parameters\\": {\\"packageName\\": \\"vscode\\", \\"packageVersion\\": \\"1.0.0\\"}}, {\\"name\\": \\"catalogName/write-to-file\\", \\"runAs\\": \\"User\\"}]" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/customizationtasks:validategroup", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.tasks = AAZListArg( + options=["--tasks"], + arg_group="Body", + help="Tasks to apply.", + ) + + tasks = cls._args_schema.tasks + tasks.Element = AAZObjectArg() + + _element = cls._args_schema.tasks.Element + _element.display_name = AAZStrArg( + options=["display-name"], + help="Display name to help differentiate multiple instances of the same task.", + ) + _element.name = AAZStrArg( + options=["name"], + help="Name of the task.", + required=True, + ) + _element.parameters = AAZDictArg( + options=["parameters"], + help="Parameters for the task.", + ) + _element.run_as = AAZStrArg( + options=["run-as"], + help="What account to run the task as.", + enum={"System": "System", "User": "User"}, + ) + _element.timeout_in_seconds = AAZIntArg( + options=["timeout-in-seconds"], + help="Timeout, in seconds. Overrides any timeout provided on the task definition.", + ) + + parameters = cls._args_schema.tasks.Element.parameters + parameters.Element = AAZStrArg() + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.DevBoxesValidateCustomizationTasksAction(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): + print(self.ctx.vars.instance) + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + + + class DevBoxesValidateCustomizationTasksAction(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/customizationTasks:validateGroup", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + print(json.dumps(data, indent=2)) + + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("tasks", AAZListType, ".tasks") + + tasks = _builder.get(".tasks") + if tasks is not None: + tasks.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".tasks[]") + if _elements is not None: + _elements.set_prop("displayName", AAZStrType, ".display_name") + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("parameters", AAZDictType, ".parameters") + _elements.set_prop("runAs", AAZStrType, ".run_as") + _elements.set_prop("timeoutInSeconds", AAZIntType, ".timeout_in_seconds") + + parameters = _builder.get(".tasks[].parameters") + if parameters is not None: + parameters.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + +class _ValidateHelper: + """Helper class for Validate""" + + +__all__ = ["Validate"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/__cmd_group.py new file mode 100644 index 00000000000..9687a49a8da --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box", +) +class __CMDGroup(AAZCommandGroup): + """Manage dev boxes. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/__init__.py new file mode 100644 index 00000000000..6f35f22e588 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/__init__.py @@ -0,0 +1,33 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._capture_snapshot import * +from ._create import * +from ._delay_action import * +from ._delay_all_actions import * +from ._delete import * +from ._list import * +from ._list_action import * +from ._list_all import * +from ._list_operation import * +from ._list_snapshot import * +from ._repair import * +from ._restart import * +from ._restore_snapshot import * +from ._show import * +from ._show_action import * +from ._show_operation import * +from ._show_remote_connection import * +from ._show_snapshot import * +from ._skip_action import * +from ._start import * +from ._stop import * +from ._wait import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_capture_snapshot.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_capture_snapshot.py new file mode 100644 index 00000000000..3aace49d1d3 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_capture_snapshot.py @@ -0,0 +1,192 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box capture-snapshot", +) +class CaptureSnapshot(AAZCommand): + """Captures a manual snapshot of the dev box. + + :example: Create snapshot + az devcenter dev dev-box capture-snapshot --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --name "myDevBox" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}:capturesnapshot", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.DevBoxesCaptureSnapshot(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DevBoxesCaptureSnapshot(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:captureSnapshot", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _CaptureSnapshotHelper: + """Helper class for CaptureSnapshot""" + + +__all__ = ["CaptureSnapshot"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_create.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_create.py new file mode 100644 index 00000000000..6c8b79e9b5a --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_create.py @@ -0,0 +1,427 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box create", +) +class Create(AAZCommand): + """Create a Dev Box. + + :example: Create + az devcenter dev dev-box create --pool-name "LargeDevWorkStationPool" --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.local_administrator = AAZStrArg( + options=["--local-administrator"], + arg_group="Body", + help="Indicates whether the owner of the Dev Box is a local administrator.", + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + _args_schema.pool_name = AAZStrArg( + options=["--pool-name"], + arg_group="Body", + help="The name of the Dev Box pool this machine belongs to.", + required=True, + 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() + yield self.DevBoxesCreateDevBox(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 DevBoxesCreateDevBox(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("localAdministrator", AAZStrType, ".local_administrator") + _builder.set_prop("poolName", AAZStrType, ".pool_name", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.action_state = AAZStrType( + serialized_name="actionState", + flags={"read_only": True}, + ) + _schema_on_200_201.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _schema_on_200_201.error = AAZObjectType( + flags={"read_only": True}, + ) + _CreateHelper._build_schema_azure_core_foundations_error_read(_schema_on_200_201.error) + _schema_on_200_201.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + flags={"read_only": True}, + ) + _schema_on_200_201.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + flags={"read_only": True}, + ) + _schema_on_200_201.image_reference = AAZObjectType( + serialized_name="imageReference", + flags={"read_only": True}, + ) + _schema_on_200_201.last_connected_time = AAZStrType( + serialized_name="lastConnectedTime", + flags={"read_only": True}, + ) + _schema_on_200_201.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _schema_on_200_201.location = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.os_type = AAZStrType( + serialized_name="osType", + flags={"read_only": True}, + ) + _schema_on_200_201.pool_name = AAZStrType( + serialized_name="poolName", + flags={"required": True}, + ) + _schema_on_200_201.power_state = AAZStrType( + serialized_name="powerState", + flags={"read_only": True}, + ) + _schema_on_200_201.project_name = AAZStrType( + serialized_name="projectName", + flags={"read_only": True}, + ) + _schema_on_200_201.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _schema_on_200_201.storage_profile = AAZObjectType( + serialized_name="storageProfile", + flags={"read_only": True}, + ) + _schema_on_200_201.unique_id = AAZStrType( + serialized_name="uniqueId", + flags={"read_only": True}, + ) + _schema_on_200_201.uri = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.user = AAZStrType( + flags={"read_only": True}, + ) + + hardware_profile = cls._schema_on_200_201.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200_201.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + storage_profile = cls._schema_on_200_201.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200_201.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["Create"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delay_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delay_action.py new file mode 100644 index 00000000000..e92d1c405e0 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delay_action.py @@ -0,0 +1,261 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box delay-action", +) +class DelayAction(AAZCommand): + """Delays the occurrence of an action. + + :example: Delay an action + az devcenter dev dev-box delay-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --delay-time "04:30" --name "myDevBox" --action-name "schedule-default" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/actions/{}:delay", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.action_name = AAZStrArg( + options=["--action-name"], + help="The name of the action.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + _args_schema.until = AAZDateTimeArg( + options=["--until"], + help="The time to delay the Dev Box action or actions until, in RFC3339 format.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesDelayAction(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 DevBoxesDelayAction(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:delay", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "actionName", self.ctx.args.action_name, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "until", self.ctx.args.until, + required=True, + ), + **self.serialize_query_param( + "api-version", "2024-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.action_type = AAZStrType( + serialized_name="actionType", + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.next = AAZObjectType() + _schema_on_200.source_id = AAZStrType( + serialized_name="sourceId", + flags={"required": True}, + ) + _schema_on_200.source_type = AAZStrType( + serialized_name="sourceType", + flags={"required": True}, + ) + _schema_on_200.source_uri = AAZStrType( + serialized_name="sourceUri", + flags={"required": True}, + ) + _schema_on_200.suspended_until = AAZStrType( + serialized_name="suspendedUntil", + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + next = cls._schema_on_200.next + next.scheduled_time = AAZStrType( + serialized_name="scheduledTime", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _DelayActionHelper: + """Helper class for DelayAction""" + + +__all__ = ["DelayAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delay_all_actions.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delay_all_actions.py new file mode 100644 index 00000000000..9a43d9a90f6 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delay_all_actions.py @@ -0,0 +1,329 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box delay-all-actions", +) +class DelayAllActions(AAZCommand): + """Delays all actions. + + :example: Delay all actions + az devcenter dev dev-box delay-all-actions --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --delay-time "04:30" --name "myDevBox" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/actions:delay", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + _args_schema.until = AAZDateTimeArg( + options=["--until"], + help="The time to delay the Dev Box action or actions until, in RFC3339 format.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesDelayActions(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 DevBoxesDelayActions(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions:delay", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "until", self.ctx.args.until, + required=True, + ), + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.action = AAZObjectType() + _element.error = AAZObjectType() + _DelayAllActionsHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.result = AAZStrType( + flags={"required": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + action = cls._schema_on_200.value.Element.action + action.action_type = AAZStrType( + serialized_name="actionType", + flags={"required": True}, + ) + action.name = AAZStrType( + flags={"read_only": True}, + ) + action.next = AAZObjectType() + action.source_id = AAZStrType( + serialized_name="sourceId", + flags={"required": True}, + ) + action.source_type = AAZStrType( + serialized_name="sourceType", + flags={"required": True}, + ) + action.source_uri = AAZStrType( + serialized_name="sourceUri", + flags={"required": True}, + ) + action.suspended_until = AAZStrType( + serialized_name="suspendedUntil", + ) + action.uri = AAZStrType( + flags={"required": True}, + ) + + next = cls._schema_on_200.value.Element.action.next + next.scheduled_time = AAZStrType( + serialized_name="scheduledTime", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _DelayAllActionsHelper: + """Helper class for DelayAllActions""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType() + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["DelayAllActions"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delete.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delete.py new file mode 100644 index 00000000000..3e68755308e --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_delete.py @@ -0,0 +1,200 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a Dev Box. + + :example: Delete + az devcenter dev dev-box delete --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.DevBoxesDeleteDevBox(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DevBoxesDeleteDevBox(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list.py new file mode 100644 index 00000000000..67e8fb12776 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list.py @@ -0,0 +1,593 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box list", +) +class List(AAZCommand): + """List dev boxes for a user or list all dev boxes for a user in a specific project. + + :example: List by user + az devcenter dev dev-box list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --user-id "00000000-0000-0000-0000-000000000000" + + :example: List by user and project + az devcenter dev dev-box list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes", "2024-10-01-preview"], + ["data-plane:microsoft.devcenter", "/users/{}/devboxes", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + 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() + condition_0 = has_value(self.ctx.args.project_name) and has_value(self.ctx.args.user_id) + condition_1 = has_value(self.ctx.args.user_id) and has_value(self.ctx.args.project_name) is not True + if condition_0: + self.DevBoxesListDevBoxesByUser(ctx=self.ctx)() + if condition_1: + self.DevBoxesListAllDevBoxesByUser(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 DevBoxesListDevBoxesByUser(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.action_state = AAZStrType( + serialized_name="actionState", + flags={"read_only": True}, + ) + _element.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _element.error = AAZObjectType( + flags={"read_only": True}, + ) + _ListHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + flags={"read_only": True}, + ) + _element.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + flags={"read_only": True}, + ) + _element.image_reference = AAZObjectType( + serialized_name="imageReference", + flags={"read_only": True}, + ) + _element.last_connected_time = AAZStrType( + serialized_name="lastConnectedTime", + flags={"read_only": True}, + ) + _element.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.os_type = AAZStrType( + serialized_name="osType", + flags={"read_only": True}, + ) + _element.pool_name = AAZStrType( + serialized_name="poolName", + flags={"required": True}, + ) + _element.power_state = AAZStrType( + serialized_name="powerState", + flags={"read_only": True}, + ) + _element.project_name = AAZStrType( + serialized_name="projectName", + flags={"read_only": True}, + ) + _element.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _element.storage_profile = AAZObjectType( + serialized_name="storageProfile", + flags={"read_only": True}, + ) + _element.unique_id = AAZStrType( + serialized_name="uniqueId", + flags={"read_only": True}, + ) + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + _element.user = AAZStrType( + flags={"read_only": True}, + ) + + hardware_profile = cls._schema_on_200.value.Element.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200.value.Element.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + storage_profile = cls._schema_on_200.value.Element.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200.value.Element.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + class DevBoxesListAllDevBoxesByUser(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/users/{userId}/devboxes", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.action_state = AAZStrType( + serialized_name="actionState", + flags={"read_only": True}, + ) + _element.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _element.error = AAZObjectType( + flags={"read_only": True}, + ) + _ListHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + flags={"read_only": True}, + ) + _element.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + flags={"read_only": True}, + ) + _element.image_reference = AAZObjectType( + serialized_name="imageReference", + flags={"read_only": True}, + ) + _element.last_connected_time = AAZStrType( + serialized_name="lastConnectedTime", + flags={"read_only": True}, + ) + _element.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.os_type = AAZStrType( + serialized_name="osType", + flags={"read_only": True}, + ) + _element.pool_name = AAZStrType( + serialized_name="poolName", + flags={"required": True}, + ) + _element.power_state = AAZStrType( + serialized_name="powerState", + flags={"read_only": True}, + ) + _element.project_name = AAZStrType( + serialized_name="projectName", + flags={"read_only": True}, + ) + _element.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _element.storage_profile = AAZObjectType( + serialized_name="storageProfile", + flags={"read_only": True}, + ) + _element.unique_id = AAZStrType( + serialized_name="uniqueId", + flags={"read_only": True}, + ) + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + _element.user = AAZStrType( + flags={"read_only": True}, + ) + + hardware_profile = cls._schema_on_200.value.Element.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200.value.Element.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + storage_profile = cls._schema_on_200.value.Element.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200.value.Element.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_action.py new file mode 100644 index 00000000000..96399a83f07 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_action.py @@ -0,0 +1,251 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box list-action", +) +class ListAction(AAZCommand): + """List actions on a Dev Box. + + :example: List + az devcenter dev dev-box list-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --name "myDevBox" --user-id "00000000-0000-0000-0000-000000000000"v + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/actions", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesListActions(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 DevBoxesListActions(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.action_type = AAZStrType( + serialized_name="actionType", + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.next = AAZObjectType() + _element.source_id = AAZStrType( + serialized_name="sourceId", + flags={"required": True}, + ) + _element.source_type = AAZStrType( + serialized_name="sourceType", + flags={"required": True}, + ) + _element.source_uri = AAZStrType( + serialized_name="sourceUri", + flags={"required": True}, + ) + _element.suspended_until = AAZStrType( + serialized_name="suspendedUntil", + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + next = cls._schema_on_200.value.Element.next + next.scheduled_time = AAZStrType( + serialized_name="scheduledTime", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListActionHelper: + """Helper class for ListAction""" + + +__all__ = ["ListAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_all.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_all.py new file mode 100644 index 00000000000..a713f26626c --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_all.py @@ -0,0 +1,337 @@ +# -------------------------------------------------------------------------------------------- +# 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 * + + +class ListAll(AAZCommand): + """List Dev Boxes that the caller has access to in the DevCenter. + + :example: List all dev boxes + az devcenter dev dev-box list-all --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/devboxes", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DevBoxesListAllDevBoxes(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 DevBoxesListAllDevBoxes(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/devboxes", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.action_state = AAZStrType( + serialized_name="actionState", + flags={"read_only": True}, + ) + _element.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _element.error = AAZObjectType( + flags={"read_only": True}, + ) + _ListAllHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + flags={"read_only": True}, + ) + _element.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + flags={"read_only": True}, + ) + _element.image_reference = AAZObjectType( + serialized_name="imageReference", + flags={"read_only": True}, + ) + _element.last_connected_time = AAZStrType( + serialized_name="lastConnectedTime", + flags={"read_only": True}, + ) + _element.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _element.location = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.os_type = AAZStrType( + serialized_name="osType", + flags={"read_only": True}, + ) + _element.pool_name = AAZStrType( + serialized_name="poolName", + flags={"required": True}, + ) + _element.power_state = AAZStrType( + serialized_name="powerState", + flags={"read_only": True}, + ) + _element.project_name = AAZStrType( + serialized_name="projectName", + flags={"read_only": True}, + ) + _element.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _element.storage_profile = AAZObjectType( + serialized_name="storageProfile", + flags={"read_only": True}, + ) + _element.unique_id = AAZStrType( + serialized_name="uniqueId", + flags={"read_only": True}, + ) + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + _element.user = AAZStrType( + flags={"read_only": True}, + ) + + hardware_profile = cls._schema_on_200.value.Element.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200.value.Element.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + storage_profile = cls._schema_on_200.value.Element.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200.value.Element.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListAllHelper: + """Helper class for ListAll""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["ListAll"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_operation.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_operation.py new file mode 100644 index 00000000000..2871803e49f --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_operation.py @@ -0,0 +1,314 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box list-operation", +) +class ListOperation(AAZCommand): + """List operations on the Dev Box which have occurred within the past 90 days. + + :example: List + az devcenter dev dev-box list-operation --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --name "myDevBox" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/operations", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesListOperations(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 DevBoxesListOperations(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/operations", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.created_by_object_id = AAZStrType( + serialized_name="createdByObjectId", + ) + _element.end_time = AAZStrType( + serialized_name="endTime", + ) + _element.error = AAZObjectType() + _ListOperationHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.kind = AAZStrType( + flags={"required": True}, + ) + _element.operation_id = AAZStrType( + serialized_name="operationId", + flags={"required": True}, + ) + _element.start_time = AAZStrType( + serialized_name="startTime", + ) + _element.status = AAZStrType( + flags={"required": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + disc_repair = cls._schema_on_200.value.Element.discriminate_by("kind", "Repair") + disc_repair.result = AAZObjectType() + + result = cls._schema_on_200.value.Element.discriminate_by("kind", "Repair").result + result.code = AAZStrType() + result.message = AAZStrType() + result.repair_outcome = AAZStrType( + serialized_name="repairOutcome", + ) + + disc_restore_snapshot = cls._schema_on_200.value.Element.discriminate_by("kind", "RestoreSnapshot") + disc_restore_snapshot.snapshot_id = AAZStrType( + serialized_name="snapshotId", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListOperationHelper: + """Helper class for ListOperation""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType() + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["ListOperation"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_snapshot.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_snapshot.py new file mode 100644 index 00000000000..7332ec6d40d --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_list_snapshot.py @@ -0,0 +1,235 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box list-snapshot", +) +class ListSnapshot(AAZCommand): + """List snapshots for this Dev Box. + + :example: List + az devcenter dev dev-box list-snapshot--endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --name "myDevBox" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/snapshots", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesListSnapshots(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 DevBoxesListSnapshots(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/snapshots", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _element.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + _element.snapshot_id = AAZStrType( + serialized_name="snapshotId", + flags={"read_only": True}, + ) + _element.snapshot_type = AAZStrType( + serialized_name="snapshotType", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListSnapshotHelper: + """Helper class for ListSnapshot""" + + +__all__ = ["ListSnapshot"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_repair.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_repair.py new file mode 100644 index 00000000000..0330e661526 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_repair.py @@ -0,0 +1,193 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box repair", +) +class Repair(AAZCommand): + """Attempts automated repair steps to resolve common problems on a dev box. The dev box may restart during this operation. + + :example: Repair + az devcenter dev dev-box repair --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}:repair", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.DevBoxesRepairDevBox(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + + class DevBoxesRepairDevBox(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:repair", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _RepairHelper: + """Helper class for Repair""" + + +__all__ = ["Repair"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_restart.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_restart.py new file mode 100644 index 00000000000..f5d92db68cd --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_restart.py @@ -0,0 +1,194 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box restart", +) +class Restart(AAZCommand): + """Restarts a dev box. + + :example: Restart + az devcenter dev dev-box restart --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}:restart", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.DevBoxesRestartDevBox(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + + class DevBoxesRestartDevBox(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:restart", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + + +class _RestartHelper: + """Helper class for Restart""" + + +__all__ = ["Restart"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_restore_snapshot.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_restore_snapshot.py new file mode 100644 index 00000000000..2c37a693908 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_restore_snapshot.py @@ -0,0 +1,202 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box restore-snapshot", +) +class RestoreSnapshot(AAZCommand): + """Restores a dev box to a specified snapshot. + + :example: Restore snapshot + az devcenter dev dev-box restore-snapshot --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --snapshot-id "CPC_974f0852-a0f4-4a9f-8ce7-d0d0d7a604cf_9b656834-3563-4bca-93c6-f90cfa3c6797" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}:restoresnapshot", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + _args_schema.snapshot_id = AAZStrArg( + options=["--snapshot-id"], + help="Required parameter that specifies the snapshot id to use for the restore operation.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.DevBoxesRestoreSnapshot(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + + class DevBoxesRestoreSnapshot(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:restoreSnapshot", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "snapshotId", self.ctx.args.snapshot_id, + required=True, + ), + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _RestoreSnapshotHelper: + """Helper class for RestoreSnapshot""" + + +__all__ = ["RestoreSnapshot"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show.py new file mode 100644 index 00000000000..be694d6be18 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show.py @@ -0,0 +1,374 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box show", +) +class Show(AAZCommand): + """Get a Dev Box. + + :example: Get + az devcenter dev dev-box show --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DevBoxesGetDevBoxByUser(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 DevBoxesGetDevBoxByUser(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.action_state = AAZStrType( + serialized_name="actionState", + flags={"read_only": True}, + ) + _schema_on_200.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _schema_on_200.error = AAZObjectType( + flags={"read_only": True}, + ) + _ShowHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + flags={"read_only": True}, + ) + _schema_on_200.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + flags={"read_only": True}, + ) + _schema_on_200.image_reference = AAZObjectType( + serialized_name="imageReference", + flags={"read_only": True}, + ) + _schema_on_200.last_connected_time = AAZStrType( + serialized_name="lastConnectedTime", + flags={"read_only": True}, + ) + _schema_on_200.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _schema_on_200.location = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.os_type = AAZStrType( + serialized_name="osType", + flags={"read_only": True}, + ) + _schema_on_200.pool_name = AAZStrType( + serialized_name="poolName", + flags={"required": True}, + ) + _schema_on_200.power_state = AAZStrType( + serialized_name="powerState", + flags={"read_only": True}, + ) + _schema_on_200.project_name = AAZStrType( + serialized_name="projectName", + flags={"read_only": True}, + ) + _schema_on_200.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _schema_on_200.storage_profile = AAZObjectType( + serialized_name="storageProfile", + flags={"read_only": True}, + ) + _schema_on_200.unique_id = AAZStrType( + serialized_name="uniqueId", + flags={"read_only": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.user = AAZStrType( + flags={"read_only": True}, + ) + + hardware_profile = cls._schema_on_200.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + storage_profile = cls._schema_on_200.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_action.py new file mode 100644 index 00000000000..dfd659ea765 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_action.py @@ -0,0 +1,252 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box show-action", +) +class ShowAction(AAZCommand): + """Get an action. + + :example: Get + az devcenter dev dev-box show-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --name "myDevBox" --action-name "schedule-default" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/actions/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.action_name = AAZStrArg( + options=["--action-name"], + help="The name of the action.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetAction(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 DevBoxesGetAction(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "actionName", self.ctx.args.action_name, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.action_type = AAZStrType( + serialized_name="actionType", + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.next = AAZObjectType() + _schema_on_200.source_id = AAZStrType( + serialized_name="sourceId", + flags={"required": True}, + ) + _schema_on_200.source_type = AAZStrType( + serialized_name="sourceType", + flags={"required": True}, + ) + _schema_on_200.source_uri = AAZStrType( + serialized_name="sourceUri", + flags={"required": True}, + ) + _schema_on_200.suspended_until = AAZStrType( + serialized_name="suspendedUntil", + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + next = cls._schema_on_200.next + next.scheduled_time = AAZStrType( + serialized_name="scheduledTime", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowActionHelper: + """Helper class for ShowAction""" + + +__all__ = ["ShowAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_operation.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_operation.py new file mode 100644 index 00000000000..d81898bbb65 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_operation.py @@ -0,0 +1,315 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box show-operation", +) +class ShowOperation(AAZCommand): + """Get an operation on a dev box. + + :example: Show operation + az devcenter dev dev-box show-operation --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --name "myDevBox" --operation-id "f5dbdfab-fa0e-4831-8d13-25359aa5e680" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/operations/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.operation_id = AAZUuidArg( + options=["--operation-id"], + help="Unique identifier for the Dev Box operation.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$", + max_length=36, + min_length=36, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetOperation(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 DevBoxesGetOperation(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/operations/{operationId}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "operationId", self.ctx.args.operation_id, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.created_by_object_id = AAZStrType( + serialized_name="createdByObjectId", + ) + _schema_on_200.end_time = AAZStrType( + serialized_name="endTime", + ) + _schema_on_200.error = AAZObjectType() + _ShowOperationHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.kind = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.operation_id = AAZStrType( + serialized_name="operationId", + flags={"required": True}, + ) + _schema_on_200.start_time = AAZStrType( + serialized_name="startTime", + ) + _schema_on_200.status = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + disc_repair = cls._schema_on_200.discriminate_by("kind", "Repair") + disc_repair.result = AAZObjectType() + + result = cls._schema_on_200.discriminate_by("kind", "Repair").result + result.code = AAZStrType() + result.message = AAZStrType() + result.repair_outcome = AAZStrType( + serialized_name="repairOutcome", + ) + + disc_restore_snapshot = cls._schema_on_200.discriminate_by("kind", "RestoreSnapshot") + disc_restore_snapshot.snapshot_id = AAZStrType( + serialized_name="snapshotId", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowOperationHelper: + """Helper class for ShowOperation""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType() + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["ShowOperation"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_remote_connection.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_remote_connection.py new file mode 100644 index 00000000000..ec8723a7b96 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_remote_connection.py @@ -0,0 +1,215 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box show-remote-connection", +) +class ShowRemoteConnection(AAZCommand): + """Get RDP Connection info. + + :example: Gets RDP connection info + az devcenter dev dev-box show-remote-connection --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/remoteconnection", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetRemoteConnection(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 DevBoxesGetRemoteConnection(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/remoteConnection", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.cloud_pc_connection_url = AAZStrType( + serialized_name="cloudPcConnectionUrl", + ) + _schema_on_200.rdp_connection_url = AAZStrType( + serialized_name="rdpConnectionUrl", + ) + _schema_on_200.web_url = AAZStrType( + serialized_name="webUrl", + ) + + return cls._schema_on_200 + + +class _ShowRemoteConnectionHelper: + """Helper class for ShowRemoteConnection""" + + +__all__ = ["ShowRemoteConnection"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_snapshot.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_snapshot.py new file mode 100644 index 00000000000..370dcb7e2e0 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_show_snapshot.py @@ -0,0 +1,231 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box show-snapshot", +) +class ShowSnapshot(AAZCommand): + """Get a snapshot by snapshot id. + + :example: Show snapshot + az devcenter dev dev-box show-snapshot --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" --snapshot-id "CPC_974f0852-a0f4-4a9f-8ce7-d0d0d7a604cf_9b656834-3563-4bca-93c6-f90cfa3c6797" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/snapshots/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.snapshot_id = AAZStrArg( + options=["--snapshot-id"], + help="The id of the snapshot. Should be treated as opaque string.", + required=True, + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetSnapshot(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 DevBoxesGetSnapshot(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/snapshots/{snapshotId}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "snapshotId", self.ctx.args.snapshot_id, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _schema_on_200.expiration_time = AAZStrType( + serialized_name="expirationTime", + flags={"read_only": True}, + ) + _schema_on_200.snapshot_id = AAZStrType( + serialized_name="snapshotId", + flags={"read_only": True}, + ) + _schema_on_200.snapshot_type = AAZStrType( + serialized_name="snapshotType", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowSnapshotHelper: + """Helper class for ShowSnapshot""" + + +__all__ = ["ShowSnapshot"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_skip_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_skip_action.py new file mode 100644 index 00000000000..64dbeec8d4d --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_skip_action.py @@ -0,0 +1,189 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box skip-action", +) +class SkipAction(AAZCommand): + """Skips an occurrence of an action. + + :example: Skip action + az devcenter dev dev-box skip-action --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --name "myDevBox" --action-name "schedule-default" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}/actions/{}:skip", "2024-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.action_name = AAZStrArg( + options=["--action-name"], + help="The name of the action.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesSkipAction(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class DevBoxesSkipAction(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions/{actionName}:skip", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "actionName", self.ctx.args.action_name, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + +class _SkipActionHelper: + """Helper class for SkipAction""" + + +__all__ = ["SkipAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_start.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_start.py new file mode 100644 index 00000000000..d2c96da41d4 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_start.py @@ -0,0 +1,193 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box start", +) +class Start(AAZCommand): + """Starts a Dev Box. + + :example: Start + az devcenter dev dev-box start --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}:start", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.DevBoxesStartDevBox(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + + class DevBoxesStartDevBox(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:start", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _StartHelper: + """Helper class for Start""" + + +__all__ = ["Start"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_stop.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_stop.py new file mode 100644 index 00000000000..e4a6cab345f --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_stop.py @@ -0,0 +1,200 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev dev-box stop", +) +class Stop(AAZCommand): + """Stops a Dev Box. + + :example: Stop + az devcenter dev dev-box stop --name "MyDevBox" --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}:stop", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + _args_schema.hibernate = AAZBoolArg( + options=["--hibernate"], + help="Optional parameter to hibernate the dev box.", + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.DevBoxesStopDevBox(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + + class DevBoxesStopDevBox(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:stop", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "hibernate", self.ctx.args.hibernate, + ), + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + +class _StopHelper: + """Helper class for Stop""" + + +__all__ = ["Stop"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_wait.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_wait.py new file mode 100644 index 00000000000..8a6d66beb1d --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/dev_box/_wait.py @@ -0,0 +1,367 @@ +# -------------------------------------------------------------------------------------------- +# 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 * + + +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/devboxes/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.dev_box_name = AAZStrArg( + options=["-n", "--name", "--dev-box", "--dev-box-name"], + help="The name of a dev box.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DevBoxesGetDevBoxByUser(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=False) + return result + + class DevBoxesGetDevBoxByUser(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "devBoxName", self.ctx.args.dev_box_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.action_state = AAZStrType( + serialized_name="actionState", + flags={"read_only": True}, + ) + _schema_on_200.created_time = AAZStrType( + serialized_name="createdTime", + flags={"read_only": True}, + ) + _schema_on_200.error = AAZObjectType( + flags={"read_only": True}, + ) + _WaitHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + flags={"read_only": True}, + ) + _schema_on_200.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + flags={"read_only": True}, + ) + _schema_on_200.image_reference = AAZObjectType( + serialized_name="imageReference", + flags={"read_only": True}, + ) + _schema_on_200.last_connected_time = AAZStrType( + serialized_name="lastConnectedTime", + flags={"read_only": True}, + ) + _schema_on_200.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _schema_on_200.location = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.os_type = AAZStrType( + serialized_name="osType", + flags={"read_only": True}, + ) + _schema_on_200.pool_name = AAZStrType( + serialized_name="poolName", + flags={"required": True}, + ) + _schema_on_200.power_state = AAZStrType( + serialized_name="powerState", + flags={"read_only": True}, + ) + _schema_on_200.project_name = AAZStrType( + serialized_name="projectName", + flags={"read_only": True}, + ) + _schema_on_200.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _schema_on_200.storage_profile = AAZObjectType( + serialized_name="storageProfile", + flags={"read_only": True}, + ) + _schema_on_200.unique_id = AAZStrType( + serialized_name="uniqueId", + flags={"read_only": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.user = AAZStrType( + flags={"read_only": True}, + ) + + hardware_profile = cls._schema_on_200.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + storage_profile = cls._schema_on_200.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["Wait"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/__cmd_group.py new file mode 100644 index 00000000000..1ecaf541d07 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment", +) +class __CMDGroup(AAZCommandGroup): + """Manage environments. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/__init__.py new file mode 100644 index 00000000000..05ad12717c4 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/__init__.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._create import * +from ._delay_action import * +from ._delete import * +from ._list import * +from ._list_action import * +from ._list_operation import * +from ._show import * +from ._show_action import * +from ._show_logs_by_operation import * +from ._show_operation import * +from ._show_outputs import * +from ._skip_action import * +from ._update_expiration_date import * +from ._wait import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_create.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_create.py new file mode 100644 index 00000000000..143f4f71234 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_create.py @@ -0,0 +1,371 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment create", +) +class Create(AAZCommand): + """Create an environment. + + :example: Create + az devcenter dev environment create --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --catalog-name "main" --environment-definition-name "helloworld" --environment-type "DevTest" --parameters "{\\"functionAppRuntime\\":\\"node\\",\\"storageAccountType\\":\\"Standard_LRS\\"}" --name "mydevenv" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="The name of the environment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.catalog_name = AAZStrArg( + options=["--catalog-name"], + arg_group="Body", + help="Name of the catalog.", + required=True, + ) + _args_schema.environment_definition_name = AAZStrArg( + options=["--environment-definition-name"], + arg_group="Body", + help="Name of the environment definition.", + required=True, + ) + _args_schema.environment_type = AAZStrArg( + options=["--environment-type"], + arg_group="Body", + help="Environment type.", + required=True, + ) + _args_schema.expiration_date = AAZDateTimeArg( + options=["--expiration-date"], + arg_group="Body", + help="The time the expiration date will be triggered (UTC), after which the environment and associated resources will be deleted.", + ) + _args_schema.parameters = AAZFreeFormDictArg( + options=["--parameters"], + arg_group="Body", + help="Parameters object for the environment.", + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.EnvironmentsCreateOrReplaceEnvironment(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 EnvironmentsCreateOrReplaceEnvironment(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("catalogName", AAZStrType, ".catalog_name", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("environmentDefinitionName", AAZStrType, ".environment_definition_name", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("environmentType", AAZStrType, ".environment_type", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("expirationDate", AAZStrType, ".expiration_date") + _builder.set_prop("parameters", AAZFreeFormDictType, ".parameters") + + parameters = _builder.get(".parameters") + if parameters is not None: + parameters.set_anytype_elements(".") + + return self.serialize_content(_content_value) + + def on_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_201 + ) + + _schema_on_201 = None + + @classmethod + def _build_schema_on_201(cls): + if cls._schema_on_201 is not None: + return cls._schema_on_201 + + cls._schema_on_201 = AAZObjectType() + + _schema_on_201 = cls._schema_on_201 + _schema_on_201.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _schema_on_201.environment_definition_name = AAZStrType( + serialized_name="environmentDefinitionName", + flags={"required": True}, + ) + _schema_on_201.environment_type = AAZStrType( + serialized_name="environmentType", + flags={"required": True}, + ) + _schema_on_201.error = AAZObjectType( + flags={"read_only": True}, + ) + _CreateHelper._build_schema_azure_core_foundations_error_read(_schema_on_201.error) + _schema_on_201.expiration_date = AAZStrType( + serialized_name="expirationDate", + ) + _schema_on_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_201.parameters = AAZFreeFormDictType() + _schema_on_201.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _schema_on_201.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + flags={"read_only": True}, + ) + _schema_on_201.uri = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_201.user = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_201 + + +class _CreateHelper: + """Helper class for Create""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["Create"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_delay_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_delay_action.py new file mode 100644 index 00000000000..ca975c6d93c --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_delay_action.py @@ -0,0 +1,252 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment delay-action", +) +class DelayAction(AAZCommand): + """Delays the occurrence of an action. + + :example: Delay an action + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/actions/{}:delay", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.action_name = AAZStrArg( + options=["--action-name"], + help="Uniquely identifies the action.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + _args_schema.until = AAZDateTimeArg( + options=["--until"], + help="The time to delay the Environment action until, in RFC3339 format.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsDelayAction(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 EnvironmentsDelayAction(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions/{actionName}:delay", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "actionName", self.ctx.args.action_name, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "until", self.ctx.args.until, + required=True, + ), + **self.serialize_query_param( + "api-version", "2024-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.action_type = AAZStrType( + serialized_name="actionType", + flags={"required": True}, + ) + _schema_on_200.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + _schema_on_200.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.next = AAZObjectType() + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + + next = cls._schema_on_200.next + next.scheduled_time = AAZStrType( + serialized_name="scheduledTime", + ) + + return cls._schema_on_200 + + +class _DelayActionHelper: + """Helper class for DelayAction""" + + +__all__ = ["DelayAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_delete.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_delete.py new file mode 100644 index 00000000000..69fe7839c33 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_delete.py @@ -0,0 +1,212 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an environment and all its associated resources + + :example: Delete + az devcenter dev environment delete --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}", "2024-10-01-preview"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(self._execute_operations, None) + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="The name of the environment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + _args_schema.force = AAZBoolArg( + options=["--force"], + help="The query option to force environment deletion even if the environment definition does not exist. This is a best-effort delete, and anything custom that forces resource creation beyond the associated resource group may not be deleted.", + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + yield self.EnvironmentsDeleteEnvironment(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class EnvironmentsDeleteEnvironment(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [204]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_204, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "force", self.ctx.args.force, + ), + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + def on_200_201(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list.py new file mode 100644 index 00000000000..7f859321a2b --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list.py @@ -0,0 +1,430 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment list", +) +class List(AAZCommand): + """List the environments for a project or for a specific project and user. + + :example: List by user and project + az devcenter dev environment list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + + :example: List by project + az devcenter dev environment list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/environments", "2024-10-01-preview"], + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.project_name) and has_value(self.ctx.args.user_id) is not True + condition_1 = has_value(self.ctx.args.project_name) and has_value(self.ctx.args.user_id) + if condition_0: + self.EnvironmentsListEnvironments(ctx=self.ctx)() + if condition_1: + self.EnvironmentsListEnvironmentsByUser(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 EnvironmentsListEnvironments(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/environments", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _element.environment_definition_name = AAZStrType( + serialized_name="environmentDefinitionName", + flags={"required": True}, + ) + _element.environment_type = AAZStrType( + serialized_name="environmentType", + flags={"required": True}, + ) + _element.error = AAZObjectType( + flags={"read_only": True}, + ) + _ListHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.expiration_date = AAZStrType( + serialized_name="expirationDate", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.parameters = AAZFreeFormDictType() + _element.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _element.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + flags={"read_only": True}, + ) + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + _element.user = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + class EnvironmentsListEnvironmentsByUser(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _element.environment_definition_name = AAZStrType( + serialized_name="environmentDefinitionName", + flags={"required": True}, + ) + _element.environment_type = AAZStrType( + serialized_name="environmentType", + flags={"required": True}, + ) + _element.error = AAZObjectType( + flags={"read_only": True}, + ) + _ListHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.expiration_date = AAZStrType( + serialized_name="expirationDate", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.parameters = AAZFreeFormDictType() + _element.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _element.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + flags={"read_only": True}, + ) + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + _element.user = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list_action.py new file mode 100644 index 00000000000..58ccd9dd17e --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list_action.py @@ -0,0 +1,242 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment list-action", +) +class ListAction(AAZCommand): + """List all scheduled actions for a user within an environment. + + :example: List + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/actions", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsListActions(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 EnvironmentsListActions(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.action_type = AAZStrType( + serialized_name="actionType", + flags={"required": True}, + ) + _element.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + _element.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.next = AAZObjectType() + _element.uri = AAZStrType( + flags={"read_only": True}, + ) + + next = cls._schema_on_200.value.Element.next + next.scheduled_time = AAZStrType( + serialized_name="scheduledTime", + ) + + return cls._schema_on_200 + + +class _ListActionHelper: + """Helper class for ListAction""" + + +__all__ = ["ListAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list_operation.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list_operation.py new file mode 100644 index 00000000000..336df5a1641 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_list_operation.py @@ -0,0 +1,301 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment list-operation", +) +class ListOperation(AAZCommand): + """List operations on the environment which have occurred within the past 90 days + + :example: List + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/operations", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsListOperations(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 EnvironmentsListOperations(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.created_by_object_id = AAZStrType( + serialized_name="createdByObjectId", + ) + _element.end_time = AAZStrType( + serialized_name="endTime", + ) + _element.environment_parameters = AAZFreeFormDictType( + serialized_name="environmentParameters", + ) + _element.error = AAZObjectType() + _ListOperationHelper._build_schema_azure_core_foundations_error_read(_element.error) + _element.kind = AAZStrType( + flags={"required": True}, + ) + _element.operation_id = AAZStrType( + serialized_name="operationId", + flags={"required": True}, + ) + _element.start_time = AAZStrType( + serialized_name="startTime", + ) + _element.status = AAZStrType( + flags={"required": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListOperationHelper: + """Helper class for ListOperation""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType() + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["ListOperation"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show.py new file mode 100644 index 00000000000..b2c0029d984 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show.py @@ -0,0 +1,300 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment show", +) +class Show(AAZCommand): + """Get an environment. + + :example: Get + az devcenter dev environment show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --name "mydevenv" --project-name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetEnvironmentByUser(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 EnvironmentsGetEnvironmentByUser(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _schema_on_200.environment_definition_name = AAZStrType( + serialized_name="environmentDefinitionName", + flags={"required": True}, + ) + _schema_on_200.environment_type = AAZStrType( + serialized_name="environmentType", + flags={"required": True}, + ) + _schema_on_200.error = AAZObjectType( + flags={"read_only": True}, + ) + _ShowHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.expiration_date = AAZStrType( + serialized_name="expirationDate", + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.parameters = AAZFreeFormDictType() + _schema_on_200.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _schema_on_200.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + flags={"read_only": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.user = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_action.py new file mode 100644 index 00000000000..e2009575bf8 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_action.py @@ -0,0 +1,243 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment show-action", +) +class ShowAction(AAZCommand): + """Get a specific environment action. + + :example: Get + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/actions/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.action_name = AAZStrArg( + options=["--action-name"], + help="Uniquely identifies the action.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetAction(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 EnvironmentsGetAction(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions/{actionName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "actionName", self.ctx.args.action_name, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.action_type = AAZStrType( + serialized_name="actionType", + flags={"required": True}, + ) + _schema_on_200.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + _schema_on_200.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.next = AAZObjectType() + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + + next = cls._schema_on_200.next + next.scheduled_time = AAZStrType( + serialized_name="scheduledTime", + ) + + return cls._schema_on_200 + + +class _ShowActionHelper: + """Helper class for ShowAction""" + + +__all__ = ["ShowAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_logs_by_operation.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_logs_by_operation.py new file mode 100644 index 00000000000..04559f66df4 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_logs_by_operation.py @@ -0,0 +1,218 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment show-logs-by-operation", +) +class ShowLogsByOperation(AAZCommand): + """Get the logs for an operation on an environment. + + :example: Get + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/operations/{}/logs", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="The name of the environment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.operation_id = AAZStrArg( + options=["--operation-id"], + help="The id of the operation on an environment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$", + max_length=36, + min_length=36, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetLogsByOperation(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=False) + return result + + class EnvironmentsGetLogsByOperation(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations/{operationId}/logs", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "operationId", self.ctx.args.operation_id, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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 = AAZStrType() + + return cls._schema_on_200 + + +class _ShowLogsByOperationHelper: + """Helper class for ShowLogsByOperation""" + + +__all__ = ["ShowLogsByOperation"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_operation.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_operation.py new file mode 100644 index 00000000000..df8b4b55f4d --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_operation.py @@ -0,0 +1,302 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment show-operation", +) +class ShowOperation(AAZCommand): + """Get an environment action result. + + :example: Get + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/operations/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.operation_id = AAZUuidArg( + options=["--operation-id"], + help="Unique identifier for the environment operation.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$", + max_length=36, + min_length=36, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetOperation(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 EnvironmentsGetOperation(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/operations/{operationId}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "operationId", self.ctx.args.operation_id, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.created_by_object_id = AAZStrType( + serialized_name="createdByObjectId", + ) + _schema_on_200.end_time = AAZStrType( + serialized_name="endTime", + ) + _schema_on_200.environment_parameters = AAZFreeFormDictType( + serialized_name="environmentParameters", + ) + _schema_on_200.error = AAZObjectType() + _ShowOperationHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.kind = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.operation_id = AAZStrType( + serialized_name="operationId", + flags={"required": True}, + ) + _schema_on_200.start_time = AAZStrType( + serialized_name="startTime", + ) + _schema_on_200.status = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowOperationHelper: + """Helper class for ShowOperation""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType() + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["ShowOperation"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_outputs.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_outputs.py new file mode 100644 index 00000000000..cd3117c9908 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_show_outputs.py @@ -0,0 +1,215 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment show-outputs", +) +class ShowOutputs(AAZCommand): + """Get Outputs from the environment. + + :example: Get + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/outputs", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="The name of the environment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetOutputs(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 EnvironmentsGetOutputs(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/outputs", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.outputs = AAZDictType() + + outputs = cls._schema_on_200.outputs + outputs.Element = AAZObjectType() + + _element = cls._schema_on_200.outputs.Element + _element.sensitive = AAZBoolType() + _element.type = AAZStrType() + _element.value = AAZFreeFormDictType() + + return cls._schema_on_200 + + +class _ShowOutputsHelper: + """Helper class for ShowOutputs""" + + +__all__ = ["ShowOutputs"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_skip_action.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_skip_action.py new file mode 100644 index 00000000000..3b5e04192cb --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_skip_action.py @@ -0,0 +1,189 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment skip-action", +) +class SkipAction(AAZCommand): + """Skips an occurrence of an action. + + :example: Skip an action + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}/actions/{}:skip", "2024-10-01-preview"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.action_name = AAZStrArg( + options=["--action-name"], + help="Uniquely identifies the action.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsSkipAction(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class EnvironmentsSkipAction(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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 [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/projects/{projectName}/users/{userId}/environments/{environmentName}/actions/{actionName}:skip", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "actionName", self.ctx.args.action_name, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + def on_204(self, session): + pass + + +class _SkipActionHelper: + """Helper class for SkipAction""" + + +__all__ = ["SkipAction"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_update_expiration_date.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_update_expiration_date.py new file mode 100644 index 00000000000..420598b3776 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_update_expiration_date.py @@ -0,0 +1,323 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment update-expiration-date", +) +class UpdateExpirationDate(AAZCommand): + """Update an environment. + + :example: Update + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="The name of the environment.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.expiration_date = AAZDateTimeArg( + options=["--expiration-date"], + arg_group="Body", + help="The time the expiration date will be triggered (UTC), after which the environment and associated resources will be deleted.", + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsPatchEnvironment(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 EnvironmentsPatchEnvironment(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}", + **self.url_parameters + ) + + @property + def method(self): + return "PATCH" + + @property + def error_format(self): + return "ODataV4Format" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-10-01-preview", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("expirationDate", AAZStrType, ".expiration_date") + + return self.serialize_content(_content_value) + + 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.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _schema_on_200.environment_definition_name = AAZStrType( + serialized_name="environmentDefinitionName", + flags={"required": True}, + ) + _schema_on_200.environment_type = AAZStrType( + serialized_name="environmentType", + flags={"required": True}, + ) + _schema_on_200.error = AAZObjectType( + flags={"read_only": True}, + ) + _UpdateExpirationDateHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.expiration_date = AAZStrType( + serialized_name="expirationDate", + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.parameters = AAZFreeFormDictType() + _schema_on_200.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _schema_on_200.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + flags={"read_only": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.user = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _UpdateExpirationDateHelper: + """Helper class for UpdateExpirationDate""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["UpdateExpirationDate"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_wait.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_wait.py new file mode 100644 index 00000000000..6cc52e2dff7 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment/_wait.py @@ -0,0 +1,288 @@ +# -------------------------------------------------------------------------------------------- +# 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 * + + +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/environments/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_name = AAZStrArg( + options=["--environment-name"], + help="Environment name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.EnvironmentsGetEnvironmentByUser(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=False) + return result + + class EnvironmentsGetEnvironmentByUser(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/environments/{environmentName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentName", self.ctx.args.environment_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _schema_on_200.environment_definition_name = AAZStrType( + serialized_name="environmentDefinitionName", + flags={"required": True}, + ) + _schema_on_200.environment_type = AAZStrType( + serialized_name="environmentType", + flags={"required": True}, + ) + _schema_on_200.error = AAZObjectType( + flags={"read_only": True}, + ) + _WaitHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.expiration_date = AAZStrType( + serialized_name="expirationDate", + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.parameters = AAZFreeFormDictType() + _schema_on_200.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + _schema_on_200.resource_group_id = AAZStrType( + serialized_name="resourceGroupId", + flags={"read_only": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.user = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _WaitHelper: + """Helper class for Wait""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType( + flags={"read_only": True} + ) + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["Wait"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/__cmd_group.py new file mode 100644 index 00000000000..527cee7736f --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment-definition", +) +class __CMDGroup(AAZCommandGroup): + """Manage environment definitions. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/__init__.py new file mode 100644 index 00000000000..2df85698253 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * +from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/_list.py new file mode 100644 index 00000000000..3421809b4c7 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/_list.py @@ -0,0 +1,394 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment-definition list", +) +class List(AAZCommand): + """List all environment definitions available within a project or catalog. + + :example: List by project + az az devcenter dev environment-definition list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" + + :example: List by project and catalog + az devcenter dev environment-definition list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --catalog-name "myCatalog" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/catalogs/{}/environmentdefinitions", "2024-10-01-preview"], + ["data-plane:microsoft.devcenter", "/projects/{}/environmentdefinitions", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.catalog_name = AAZStrArg( + options=["--catalog-name"], + help="The name of the catalog", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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() + condition_0 = has_value(self.ctx.args.catalog_name) and has_value(self.ctx.args.project_name) + condition_1 = has_value(self.ctx.args.project_name) and has_value(self.ctx.args.catalog_name) is not True + if condition_0: + self.EnvironmentsListEnvironmentDefinitionsByCatalog(ctx=self.ctx)() + if condition_1: + self.EnvironmentsListEnvironmentDefinitionsByProject(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 EnvironmentsListEnvironmentDefinitionsByCatalog(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/catalogs/{catalogName}/environmentDefinitions", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "catalogName", self.ctx.args.catalog_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _element.description = AAZStrType() + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.parameters = AAZListType() + _element.parameters_schema = AAZStrType( + serialized_name="parametersSchema", + ) + _element.template_path = AAZStrType( + serialized_name="templatePath", + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + parameters = cls._schema_on_200.value.Element.parameters + parameters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.parameters.Element + _element.allowed = AAZListType() + _element.default = AAZStrType() + _element.description = AAZStrType() + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.read_only = AAZBoolType( + serialized_name="readOnly", + ) + _element.required = AAZBoolType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + allowed = cls._schema_on_200.value.Element.parameters.Element.allowed + allowed.Element = AAZStrType() + + return cls._schema_on_200 + + class EnvironmentsListEnvironmentDefinitionsByProject(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/environmentDefinitions", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _element.description = AAZStrType() + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.parameters = AAZListType() + _element.parameters_schema = AAZStrType( + serialized_name="parametersSchema", + ) + _element.template_path = AAZStrType( + serialized_name="templatePath", + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + parameters = cls._schema_on_200.value.Element.parameters + parameters.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.parameters.Element + _element.allowed = AAZListType() + _element.default = AAZStrType() + _element.description = AAZStrType() + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.read_only = AAZBoolType( + serialized_name="readOnly", + ) + _element.required = AAZBoolType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + allowed = cls._schema_on_200.value.Element.parameters.Element.allowed + allowed.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/_show.py new file mode 100644 index 00000000000..0fedcdd04fb --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_definition/_show.py @@ -0,0 +1,250 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment-definition show", +) +class Show(AAZCommand): + """Get an environment definition from a catalog. + + :example: Get + 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" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/catalogs/{}/environmentdefinitions/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.catalog_name = AAZStrArg( + options=["--catalog-name"], + help="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.definition_name = AAZStrArg( + options=["--definition-name"], + help="Name of the environment definition.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetEnvironmentDefinition(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 EnvironmentsGetEnvironmentDefinition(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/catalogs/{catalogName}/environmentDefinitions/{definitionName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "catalogName", self.ctx.args.catalog_name, + required=True, + ), + **self.serialize_url_param( + "definitionName", self.ctx.args.definition_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.catalog_name = AAZStrType( + serialized_name="catalogName", + flags={"required": True}, + ) + _schema_on_200.description = AAZStrType() + _schema_on_200.id = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.parameters = AAZListType() + _schema_on_200.parameters_schema = AAZStrType( + serialized_name="parametersSchema", + ) + _schema_on_200.template_path = AAZStrType( + serialized_name="templatePath", + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + parameters = cls._schema_on_200.parameters + parameters.Element = AAZObjectType() + + _element = cls._schema_on_200.parameters.Element + _element.allowed = AAZListType() + _element.default = AAZStrType() + _element.description = AAZStrType() + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType() + _element.read_only = AAZBoolType( + serialized_name="readOnly", + ) + _element.required = AAZBoolType( + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + + allowed = cls._schema_on_200.parameters.Element.allowed + allowed.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/__cmd_group.py new file mode 100644 index 00000000000..87cbb08b853 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment-type", +) +class __CMDGroup(AAZCommandGroup): + """Manage environment types. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/__init__.py new file mode 100644 index 00000000000..7df9beecbc2 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/__init__.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * +from ._list_abilities import * +from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_list.py new file mode 100644 index 00000000000..cbbce40909d --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_list.py @@ -0,0 +1,202 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment-type list", +) +class List(AAZCommand): + """List all environment types configured for a project. + + :example: List + az devcenter dev environment-type list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/environmenttypes", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsListEnvironmentTypes(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 EnvironmentsListEnvironmentTypes(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/environmentTypes", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.deployment_target_id = AAZStrType( + serialized_name="deploymentTargetId", + flags={"required": True}, + ) + _element.display_name = AAZStrType( + serialized_name="displayName", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.status = AAZStrType( + flags={"required": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_list_abilities.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_list_abilities.py new file mode 100644 index 00000000000..b05879c06ff --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_list_abilities.py @@ -0,0 +1,220 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment-type list-abilities", +) +class ListAbilities(AAZCommand): + """Get the signed-in user's permitted abilities in an environment type. + + :example: List + az devcenter dev environment-type show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --environment-type-name "dev" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/environmenttypes/{}/users/{}/abilities", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_type_name = AAZStrArg( + options=["-n", "--name", "--environment-type-name"], + help="The name of the environment type", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetEnvironmentTypeAbilities(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 EnvironmentsGetEnvironmentTypeAbilities(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/environmentTypes/{environmentTypeName}/users/{userId}/abilities", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentTypeName", self.ctx.args.environment_type_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.abilities_as_admin = AAZListType( + serialized_name="abilitiesAsAdmin", + flags={"required": True}, + ) + _schema_on_200.abilities_as_developer = AAZListType( + serialized_name="abilitiesAsDeveloper", + flags={"required": True}, + ) + + abilities_as_admin = cls._schema_on_200.abilities_as_admin + abilities_as_admin.Element = AAZStrType() + + abilities_as_developer = cls._schema_on_200.abilities_as_developer + abilities_as_developer.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListAbilitiesHelper: + """Helper class for ListAbilities""" + + +__all__ = ["ListAbilities"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_show.py new file mode 100644 index 00000000000..0ec72f386fe --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/environment_type/_show.py @@ -0,0 +1,207 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev environment-type show", +) +class Show(AAZCommand): + """Get an environment type configured for a project. + + :example: Get an environment type configured for a project. + az devcenter dev environment-type show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --environment-type-name "dev" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/environmenttypes/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.environment_type_name = AAZStrArg( + options=["-n", "--name", "--environment-type-name"], + help="The name of the environment type", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.EnvironmentsGetEnvironmentTypes(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 EnvironmentsGetEnvironmentTypes(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/environmentTypes/{environmentTypeName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "environmentTypeName", self.ctx.args.environment_type_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.deployment_target_id = AAZStrType( + serialized_name="deploymentTargetId", + flags={"required": True}, + ) + _schema_on_200.display_name = AAZStrType( + serialized_name="displayName", + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.status = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/__cmd_group.py new file mode 100644 index 00000000000..aaff3b81d89 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev image-build", +) +class __CMDGroup(AAZCommandGroup): + """Manage image builds. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/__init__.py new file mode 100644 index 00000000000..af940a6af77 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/__init__.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._show_log import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/_show_log.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/_show_log.py new file mode 100644 index 00000000000..125f1f90af4 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/image_build/_show_log.py @@ -0,0 +1,184 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev image-build show-log", +) +class ShowLog(AAZCommand): + """Get the log for an imaging build task. + + :example: Get + az devcenter dev image-build show-log --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" --image-build-log-id "91835dc0-ef5a-4f58-9e3a-099aea8481f4" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/imagebuildlogs/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.image_build_log_id = AAZUuidArg( + options=["-i", "--image-build-log-id"], + help="An imaging build log id.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetImagingTaskLog(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=False) + return result + + class DevBoxesGetImagingTaskLog(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/imageBuildLogs/{imageBuildLogId}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "imageBuildLogId", self.ctx.args.image_build_log_id, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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 = AAZStrType() + + return cls._schema_on_200 + + +class _ShowLogHelper: + """Helper class for ShowLog""" + + +__all__ = ["ShowLog"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/__cmd_group.py new file mode 100644 index 00000000000..354071c6d79 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev pool", +) +class __CMDGroup(AAZCommandGroup): + """Manage pools. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/__init__.py new file mode 100644 index 00000000000..2df85698253 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * +from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/_list.py new file mode 100644 index 00000000000..7099f510403 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/_list.py @@ -0,0 +1,287 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev pool list", +) +class List(AAZCommand): + """List available pools. + + :example: List + az devcenter dev pool list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/pools", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesListPools(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 DevBoxesListPools(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/pools", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.display_name = AAZStrType( + serialized_name="displayName", + ) + _element.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + ) + _element.health_status = AAZStrType( + serialized_name="healthStatus", + flags={"required": True}, + ) + _element.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + ) + _element.image_reference = AAZObjectType( + serialized_name="imageReference", + ) + _element.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _element.location = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.os_type = AAZStrType( + serialized_name="osType", + ) + _element.stop_on_disconnect = AAZObjectType( + serialized_name="stopOnDisconnect", + ) + _element.stop_on_no_connect = AAZObjectType( + serialized_name="stopOnNoConnect", + ) + _element.storage_profile = AAZObjectType( + serialized_name="storageProfile", + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + hardware_profile = cls._schema_on_200.value.Element.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200.value.Element.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + stop_on_disconnect = cls._schema_on_200.value.Element.stop_on_disconnect + stop_on_disconnect.grace_period_minutes = AAZIntType( + serialized_name="gracePeriodMinutes", + ) + stop_on_disconnect.status = AAZStrType( + flags={"required": True}, + ) + + stop_on_no_connect = cls._schema_on_200.value.Element.stop_on_no_connect + stop_on_no_connect.grace_period_minutes = AAZIntType( + serialized_name="gracePeriodMinutes", + ) + stop_on_no_connect.status = AAZStrType( + flags={"required": True}, + ) + + storage_profile = cls._schema_on_200.value.Element.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200.value.Element.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/_show.py new file mode 100644 index 00000000000..847219c6544 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/pool/_show.py @@ -0,0 +1,292 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev pool show", +) +class Show(AAZCommand): + """Get a pool. + + :example: Get + az devcenter dev pool show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --name "DevPool" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/pools/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pool_name = AAZStrArg( + options=["--pool-name"], + help="Pool name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetPool(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 DevBoxesGetPool(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/pools/{poolName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "poolName", self.ctx.args.pool_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.display_name = AAZStrType( + serialized_name="displayName", + ) + _schema_on_200.hardware_profile = AAZObjectType( + serialized_name="hardwareProfile", + ) + _schema_on_200.health_status = AAZStrType( + serialized_name="healthStatus", + flags={"required": True}, + ) + _schema_on_200.hibernate_support = AAZStrType( + serialized_name="hibernateSupport", + ) + _schema_on_200.image_reference = AAZObjectType( + serialized_name="imageReference", + ) + _schema_on_200.local_administrator = AAZStrType( + serialized_name="localAdministrator", + ) + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.os_type = AAZStrType( + serialized_name="osType", + ) + _schema_on_200.stop_on_disconnect = AAZObjectType( + serialized_name="stopOnDisconnect", + ) + _schema_on_200.stop_on_no_connect = AAZObjectType( + serialized_name="stopOnNoConnect", + ) + _schema_on_200.storage_profile = AAZObjectType( + serialized_name="storageProfile", + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + hardware_profile = cls._schema_on_200.hardware_profile + hardware_profile.memory_gb = AAZIntType( + serialized_name="memoryGB", + flags={"read_only": True}, + ) + hardware_profile.sku_name = AAZStrType( + serialized_name="skuName", + flags={"read_only": True}, + ) + hardware_profile.v_cp_us = AAZIntType( + serialized_name="vCPUs", + flags={"read_only": True}, + ) + + image_reference = cls._schema_on_200.image_reference + image_reference.name = AAZStrType( + flags={"read_only": True}, + ) + image_reference.operating_system = AAZStrType( + serialized_name="operatingSystem", + flags={"read_only": True}, + ) + image_reference.os_build_number = AAZStrType( + serialized_name="osBuildNumber", + flags={"read_only": True}, + ) + image_reference.published_date = AAZStrType( + serialized_name="publishedDate", + flags={"read_only": True}, + ) + image_reference.version = AAZStrType( + flags={"read_only": True}, + ) + + stop_on_disconnect = cls._schema_on_200.stop_on_disconnect + stop_on_disconnect.grace_period_minutes = AAZIntType( + serialized_name="gracePeriodMinutes", + ) + stop_on_disconnect.status = AAZStrType( + flags={"required": True}, + ) + + stop_on_no_connect = cls._schema_on_200.stop_on_no_connect + stop_on_no_connect.grace_period_minutes = AAZIntType( + serialized_name="gracePeriodMinutes", + ) + stop_on_no_connect.status = AAZStrType( + flags={"required": True}, + ) + + storage_profile = cls._schema_on_200.storage_profile + storage_profile.os_disk = AAZObjectType( + serialized_name="osDisk", + ) + + os_disk = cls._schema_on_200.storage_profile.os_disk + os_disk.disk_size_gb = AAZIntType( + serialized_name="diskSizeGB", + flags={"read_only": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/__cmd_group.py new file mode 100644 index 00000000000..11fe1a9b388 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev project", +) +class __CMDGroup(AAZCommandGroup): + """Manage projects. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/__init__.py new file mode 100644 index 00000000000..19edb06ef51 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/__init__.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * +from ._list_abilities import * +from ._show import * +from ._show_operation import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_list.py new file mode 100644 index 00000000000..0b3e0d689ce --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_list.py @@ -0,0 +1,180 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev project list", +) +class List(AAZCommand): + """List all projects. + + :example: List + az devcenter dev project list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DevCenterListProjects(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 DevCenterListProjects(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.description = AAZStrType() + _element.display_name = AAZStrType( + serialized_name="displayName", + ) + _element.max_dev_boxes_per_user = AAZIntType( + serialized_name="maxDevBoxesPerUser", + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_list_abilities.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_list_abilities.py new file mode 100644 index 00000000000..483a3925744 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_list_abilities.py @@ -0,0 +1,201 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev project list-abilities", +) +class ListAbilities(AAZCommand): + """Get the signed-in user's permitted abilities in a project. + + :example: List + az devcenter dev project list-abilities --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --name "DevProject" --user-id "00000000-0000-0000-0000-000000000000" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/users/{}/abilities", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The DevCenter Project upon which to execute operations.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.user_id = AAZStrArg( + options=["--user-id"], + help="The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.", + required=True, + default="me", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$|^me$", + max_length=36, + min_length=2, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.DevCenterGetProjectAbilities(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 DevCenterGetProjectAbilities(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/users/{userId}/abilities", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "userId", self.ctx.args.user_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.abilities_as_admin = AAZListType( + serialized_name="abilitiesAsAdmin", + flags={"required": True}, + ) + _schema_on_200.abilities_as_developer = AAZListType( + serialized_name="abilitiesAsDeveloper", + flags={"required": True}, + ) + + abilities_as_admin = cls._schema_on_200.abilities_as_admin + abilities_as_admin.Element = AAZStrType() + + abilities_as_developer = cls._schema_on_200.abilities_as_developer + abilities_as_developer.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListAbilitiesHelper: + """Helper class for ListAbilities""" + + +__all__ = ["ListAbilities"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_show.py new file mode 100644 index 00000000000..421ce330dfe --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_show.py @@ -0,0 +1,185 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev project show", +) +class Show(AAZCommand): + """Get a project. + + :example: Get + az devcenter dev project show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The DevCenter Project upon which to execute operations.", + required=True, + 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.DevCenterGetProject(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 DevCenterGetProject(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.description = AAZStrType() + _schema_on_200.display_name = AAZStrType( + serialized_name="displayName", + ) + _schema_on_200.max_dev_boxes_per_user = AAZIntType( + serialized_name="maxDevBoxesPerUser", + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_show_operation.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_show_operation.py new file mode 100644 index 00000000000..898b9e001b1 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/project/_show_operation.py @@ -0,0 +1,265 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev project show-operation", +) +class ShowOperation(AAZCommand): + """Get the status of an operation. + + :example: Get + az devcenter dev project show-operation --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --name "DevProject" --operation-id "f5dbdfab- fa0e-4831-8d13-25359aa5e680" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/operationstatuses/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.operation_id = AAZUuidArg( + options=["--operation-id"], + help="The operation id name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]{8}-([a-zA-Z0-9]{4}-){3}[a-zA-Z0-9]{12}$", + max_length=36, + min_length=36, + ), + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The DevCenter Project upon which to execute operations.", + required=True, + 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.OperationStatusesGet(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 OperationStatusesGet(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/operationstatuses/{operationId}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "operationId", self.ctx.args.operation_id, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.end_time = AAZStrType( + serialized_name="endTime", + ) + _schema_on_200.error = AAZObjectType() + _ShowOperationHelper._build_schema_azure_core_foundations_error_read(_schema_on_200.error) + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.percent_complete = AAZFloatType( + serialized_name="percentComplete", + ) + _schema_on_200.properties = AAZFreeFormDictType() + _schema_on_200.resource_id = AAZStrType( + serialized_name="resourceId", + ) + _schema_on_200.start_time = AAZStrType( + serialized_name="startTime", + ) + _schema_on_200.status = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowOperationHelper: + """Helper class for ShowOperation""" + + _schema_azure_core_foundations_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_error_read(cls, _schema): + if cls._schema_azure_core_foundations_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + return + + cls._schema_azure_core_foundations_error_read = _schema_azure_core_foundations_error_read = AAZObjectType() + + azure_core_foundations_error_read = _schema_azure_core_foundations_error_read + azure_core_foundations_error_read.code = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.details = AAZListType() + azure_core_foundations_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_error_read.innererror) + azure_core_foundations_error_read.message = AAZStrType( + flags={"required": True}, + ) + azure_core_foundations_error_read.target = AAZStrType() + + details = _schema_azure_core_foundations_error_read.details + details.Element = AAZObjectType() + cls._build_schema_azure_core_foundations_error_read(details.Element) + + _schema.code = cls._schema_azure_core_foundations_error_read.code + _schema.details = cls._schema_azure_core_foundations_error_read.details + _schema.innererror = cls._schema_azure_core_foundations_error_read.innererror + _schema.message = cls._schema_azure_core_foundations_error_read.message + _schema.target = cls._schema_azure_core_foundations_error_read.target + + _schema_azure_core_foundations_inner_error_read = None + + @classmethod + def _build_schema_azure_core_foundations_inner_error_read(cls, _schema): + if cls._schema_azure_core_foundations_inner_error_read is not None: + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + return + + cls._schema_azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read = AAZObjectType() + + azure_core_foundations_inner_error_read = _schema_azure_core_foundations_inner_error_read + azure_core_foundations_inner_error_read.code = AAZStrType() + azure_core_foundations_inner_error_read.innererror = AAZObjectType() + cls._build_schema_azure_core_foundations_inner_error_read(azure_core_foundations_inner_error_read.innererror) + + _schema.code = cls._schema_azure_core_foundations_inner_error_read.code + _schema.innererror = cls._schema_azure_core_foundations_inner_error_read.innererror + + +__all__ = ["ShowOperation"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/__cmd_group.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/__cmd_group.py new file mode 100644 index 00000000000..d003a56fcd7 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev schedule", +) +class __CMDGroup(AAZCommandGroup): + """Manage schedules. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/__init__.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/__init__.py new file mode 100644 index 00000000000..2df85698253 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/__init__.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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 ._list import * +from ._show import * diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/_list.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/_list.py new file mode 100644 index 00000000000..3d1a63c505b --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/_list.py @@ -0,0 +1,353 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev schedule list", +) +class List(AAZCommand): + """List all schedules within a project or a pool. + + :example: List by project + az devcenter dev schedule list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --project-name "DevProject" + + :example: List by pool + az devcenter dev schedule list --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --pool-name "DevPool" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/pools/{}/schedules", "2024-10-01-preview"], + ["data-plane:microsoft.devcenter", "/projects/{}/schedules", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pool_name = AAZStrArg( + options=["--pool-name"], + help="The name of a pool of Dev Boxes.", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.project_name = AAZStrArg( + options=["--project-name"], + help="The DevCenter Project upon which to execute operations.", + required=True, + 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() + condition_0 = has_value(self.ctx.args.pool_name) and has_value(self.ctx.args.project_name) + condition_1 = has_value(self.ctx.args.project_name) and has_value(self.ctx.args.pool_name) is not True + if condition_0: + self.DevBoxesListSchedulesByPool(ctx=self.ctx)() + if condition_1: + self.DevBoxesListSchedulesByProject(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 DevBoxesListSchedulesByPool(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/pools/{poolName}/schedules", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "poolName", self.ctx.args.pool_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.frequency = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source_type = AAZStrType( + serialized_name="sourceType", + flags={"required": True}, + ) + _element.source_uri = AAZStrType( + serialized_name="sourceUri", + flags={"required": True}, + ) + _element.time = AAZStrType( + flags={"required": True}, + ) + _element.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + class DevBoxesListSchedulesByProject(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/schedules", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.frequency = AAZStrType( + flags={"required": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.source_type = AAZStrType( + serialized_name="sourceType", + flags={"required": True}, + ) + _element.source_uri = AAZStrType( + serialized_name="sourceUri", + flags={"required": True}, + ) + _element.time = AAZStrType( + flags={"required": True}, + ) + _element.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + _element.type = AAZStrType( + flags={"required": True}, + ) + _element.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/_show.py b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/_show.py new file mode 100644 index 00000000000..2664489e9c5 --- /dev/null +++ b/src/devcenter/azext_devcenter/aaz/latest/devcenter/dev/schedule/_show.py @@ -0,0 +1,233 @@ +# -------------------------------------------------------------------------------------------- +# 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 dev schedule show", +) +class Show(AAZCommand): + """Get a schedule. + + :example: Get + az devcenter dev schedule show --endpoint "https://8a40af38-3b4c-4672-a6a4-5e964b1870ed-contosodevcenter.centralus.devcenter.azure.com/" --pool-name "DevPool" --project-name "DevProject" + """ + + _aaz_info = { + "version": "2024-10-01-preview", + "resources": [ + ["data-plane:microsoft.devcenter", "/projects/{}/pools/{}/schedules/{}", "2024-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 "Client" + + _args_schema = cls._args_schema + _args_schema.endpoint = AAZStrArg( + options=["--endpoint"], + arg_group="Client", + help="The API endpoint for the developer resources. Use az configure -d endpoint= to configure a default.", + required=True, + ) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.pool_name = AAZStrArg( + options=["--pool-name"], + help="Pool name.", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + _args_schema.schedule_name = AAZStrArg( + options=["--schedule-name"], + help="Display name for the Schedule.", + required=True, + default="default", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$", + max_length=63, + min_length=3, + ), + ) + + # define Arg Group "Default" + + _args_schema = cls._args_schema + _args_schema.project_name = AAZStrArg( + options=["--project", "--project-name"], + arg_group="Default", + help="The name of the project. Use az configure -d project= to configure a default.", + required=True, + 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.DevBoxesGetScheduleByPool(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=False) + return result + + class DevBoxesGetScheduleByPool(AAZHttpOperation): + CLIENT_TYPE = "AAZMicrosoftDevcenterDataPlaneClient_devcenter" + + 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( + "/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}", + **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( + "endpoint", self.ctx.args.endpoint, + skip_quote=True, + required=True, + ), + **self.serialize_url_param( + "poolName", self.ctx.args.pool_name, + required=True, + ), + **self.serialize_url_param( + "projectName", self.ctx.args.project_name, + required=True, + ), + **self.serialize_url_param( + "scheduleName", self.ctx.args.schedule_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2024-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.frequency = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.source_type = AAZStrType( + serialized_name="sourceType", + flags={"required": True}, + ) + _schema_on_200.source_uri = AAZStrType( + serialized_name="sourceUri", + flags={"required": True}, + ) + _schema_on_200.time = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.time_zone = AAZStrType( + serialized_name="timeZone", + flags={"required": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.uri = AAZStrType( + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/devcenter/azext_devcenter/action.py b/src/devcenter/azext_devcenter/action.py deleted file mode 100644 index 327d9c27e71..00000000000 --- a/src/devcenter/azext_devcenter/action.py +++ /dev/null @@ -1,88 +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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=protected-access -# pylint: disable=no-self-use - -import argparse -from collections import defaultdict -from knack.util import CLIError - - -class AddEmailNotification(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - action = self.get_action(values, option_string) - namespace.email_notification = action - - def get_action(self, values, option_string): - try: - properties = defaultdict(list) - for k, v in (x.split("=", 1) for x in values): - properties[k].append(v) - properties = dict(properties) - except ValueError: - raise CLIError( - f"usage error: {option_string} [KEY=VALUE ...]" - ) from ValueError - d = {} - for k in properties: - kl = k.lower() - v = properties[k] - - if kl == "enabled": - d["enabled"] = v[0] - - elif kl == "recipients": - d["recipients"] = v[0] - - elif kl == "cc": - d["cc"] = v[0] - - else: - raise CLIError( - f"Unsupported Key {k} is provided for parameter email-notification. All possible keys are: enabled," - f" recipients, cc" - ) - - return d - - -class AddWebhookNotification(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - action = self.get_action(values, option_string) - namespace.webhook_notification = action - - def get_action(self, values, option_string): - try: - properties = defaultdict(list) - for k, v in (x.split("=", 1) for x in values): - properties[k].append(v) - properties = dict(properties) - except ValueError: - raise CLIError( - f"usage error: {option_string} [KEY=VALUE ...]" - ) from ValueError - d = {} - for k in properties: - kl = k.lower() - v = properties[k] - - if kl == "enabled": - d["enabled"] = v[0] - - elif kl == "url": - d["url"] = v[0] - - else: - raise CLIError( - f"Unsupported Key {k} is provided for parameter webhook-notification. All possible keys are:" - f" enabled, url" - ) - - return d diff --git a/src/devcenter/azext_devcenter/azext_metadata.json b/src/devcenter/azext_devcenter/azext_metadata.json index a4a3d96c484..108df673ca9 100644 --- a/src/devcenter/azext_devcenter/azext_metadata.json +++ b/src/devcenter/azext_devcenter/azext_metadata.json @@ -1,3 +1,3 @@ { - "azext.minCliCoreVersion": "2.51.0" + "azext.minCliCoreVersion": "2.67.0" } \ No newline at end of file diff --git a/src/devcenter/azext_devcenter/commands.py b/src/devcenter/azext_devcenter/commands.py index ddbd2c8dddc..943e1764687 100644 --- a/src/devcenter/azext_devcenter/commands.py +++ b/src/devcenter/azext_devcenter/commands.py @@ -6,12 +6,6 @@ # pylint: disable=line-too-long # pylint: disable=too-many-locals # pylint: disable=too-many-statements -from azure.cli.core.commands import CliCommandType -from azext_devcenter._client_factory import ( - cf_dev_center_dp, - cf_dev_boxes_dp, - cf_environments_dp, -) from .custom import ( AttachedNetworkCreate, AttachedNetworkDelete, @@ -362,42 +356,21 @@ def load_command_table(self, _): self.command_table["devcenter admin schedule update"] = ScheduleUpdate(loader=self) self.command_table["devcenter admin schedule wait"] = ScheduleWait(loader=self) - # Data plane - - devcenter_dp = CliCommandType( - operations_tmpl="azext_devcenter.vendored_sdks.devcenter_dataplane.operations._operations#DevCenterOperations.{}", - client_factory=cf_dev_center_dp, - ) - - dev_boxes_dp = CliCommandType( - operations_tmpl="azext_devcenter.vendored_sdks.devcenter_dataplane.operations._operations#DevBoxesOperations.{}", - client_factory=cf_dev_boxes_dp, - ) - - environments_dp = CliCommandType( - operations_tmpl=( - "azext_devcenter.vendored_sdks.devcenter_dataplane.operations._operations#EnvironmentsOperations.{}" - ), - client_factory=cf_environments_dp, - ) - - with self.command_group("devcenter"): - pass +# Data plane - with self.command_group("devcenter dev"): - pass + with self.command_group("devcenter dev project") as g: + g.custom_command("list", "devcenter_project_list") + g.custom_show_command("show", "devcenter_project_show") + g.custom_command("list-abilities", "devcenter_project_list_abilities") + g.custom_command("show-operation", "devcenter_project_show_operation") - with self.command_group("devcenter dev project", devcenter_dp) as g: - g.custom_command("list", "devcenter_project_list_dp") - g.custom_show_command("show", "devcenter_project_show_dp") + with self.command_group("devcenter dev pool") as g: + g.custom_command("list", "devcenter_pool_list") + g.custom_show_command("show", "devcenter_pool_show") - with self.command_group("devcenter dev pool", dev_boxes_dp) as g: - g.custom_command("list", "devcenter_pool_list_dp") - g.custom_show_command("show", "devcenter_pool_show_dp") - - with self.command_group("devcenter dev schedule", dev_boxes_dp) as g: - g.custom_command("list", "devcenter_schedule_list_dp") - g.custom_show_command("show", "devcenter_schedule_show_dp") + with self.command_group("devcenter dev schedule") as g: + g.custom_command("list", "devcenter_schedule_list") + g.custom_show_command("show", "devcenter_schedule_show") with self.command_group("devcenter dev dev-box") as g: g.custom_command("list", "devcenter_dev_box_list") @@ -423,6 +396,10 @@ def load_command_table(self, _): g.custom_command("delay-all-actions", "devcenter_dev_box_delay_all_actions") g.custom_command("list-operation", "devcenter_dev_box_list_operation") g.custom_command("show-operation", "devcenter_dev_box_show_operation") + g.custom_command("capture-snapshot", "devcenter_dev_box_capture_snapshot", supports_no_wait=True) + g.custom_command("restore-snapshot", "devcenter_dev_box_restore_snapshot", supports_no_wait=True) + g.custom_command("show-snapshot", "devcenter_dev_box_show_snapshot") + g.custom_command("list-snapshot", "devcenter_dev_box_list_snapshot") with self.command_group("devcenter dev environment") as g: g.custom_command("list", "devcenter_environment_list") @@ -446,30 +423,35 @@ def load_command_table(self, _): g.custom_command("show-operation", "devcenter_environment_operation_show") g.custom_command( "show-logs-by-operation", - "devcenter_environment_operation_show_logs_by_operation", + "devcenter_environment_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("show-action", "devcenter_environment_show_action") + g.custom_command("list-action", "devcenter_environment_list_action") + g.custom_command("delay-action", "devcenter_environment_delay_action") + g.custom_command("skip-action", "devcenter_environment_skip_action") + g.custom_command("show-outputs", "devcenter_environment_show_outputs") g.custom_command( "update-expiration-date", - "devcenter_environment_operation_update_environment", + "devcenter_environment_update_expiration", ) - with self.command_group("devcenter dev catalog", environments_dp) as g: - g.custom_command("list", "devcenter_catalog_list_dp") - g.custom_show_command("show", "devcenter_catalog_show_dp") + with self.command_group("devcenter dev catalog") as g: + g.custom_command("list", "devcenter_catalog_list") + g.custom_show_command("show", "devcenter_catalog_show") with self.command_group( - "devcenter dev environment-definition", environments_dp + "devcenter dev environment-definition" ) as g: - g.custom_command("list", "devcenter_environment_definition_list_dp") - g.custom_show_command("show", "devcenter_environment_definition_show_dp") + g.custom_command("list", "devcenter_environment_definition_list") + g.custom_show_command("show", "devcenter_environment_definition_show") + + with self.command_group("devcenter dev environment-type") as g: + g.custom_command("list", "devcenter_environment_type_list") + g.custom_show_command("show", "devcenter_environment_type_show") + g.custom_command("list-abilities", "devcenter_environment_type_list_abilities") - with self.command_group("devcenter dev environment-type", environments_dp) as g: - g.custom_command("list", "devcenter_environment_type_list_dp") + with self.command_group("devcenter dev image-build") as g: + g.custom_command("show-log", "devcenter_image_build_show_log") with self.command_group("devcenter dev customization-group") as g: g.custom_command("list", "devcenter_customization_group_list") @@ -477,7 +459,7 @@ def load_command_table(self, _): g.custom_command("create", "devcenter_customization_group_create") with self.command_group("devcenter dev customization-task") as g: - g.custom_command("list", "devcenter_customization_task_definition_list") - g.custom_show_command("show", "devcenter_customization_task_definition_show") - g.custom_command("validate", "devcenter_customization_task_definition_validate") + g.custom_command("list", "devcenter_customization_task_list") + g.custom_show_command("show", "devcenter_customization_task_show") + g.custom_command("validate", "devcenter_customization_task_validate", supports_no_wait=True) g.custom_command("show-logs", "devcenter_customization_task_log_show") diff --git a/src/devcenter/azext_devcenter/custom.py b/src/devcenter/azext_devcenter/custom.py index 385d6ed8751..bcad0b94b3d 100644 --- a/src/devcenter/azext_devcenter/custom.py +++ b/src/devcenter/azext_devcenter/custom.py @@ -7,12 +7,9 @@ from datetime import datetime import json -from azure.cli.core.aaz import has_value -from azure.cli.core.aaz import register_callback +from azure.cli.core.aaz import register_callback, has_value from azure.cli.core.azclierror import ResourceNotFoundError -from azure.cli.core.util import sdk_no_wait -from ._client_factory import cf_devcenter_dataplane -from .utils import get_project_arg, get_earliest_time, get_delayed_time +from .utils import get_project_arg, get_earliest_time, get_delayed_time, get_dataplane_endpoint from .aaz.latest.devcenter.admin.attached_network import ( Create as _AttachedNetworkCreate, Delete as _AttachedNetworkDelete, @@ -155,6 +152,85 @@ from .aaz.latest.devcenter.admin.project_sku import ( List as _ProjectSkuList, ) +from .aaz.latest.devcenter.dev.project import ( + List as ProjectListDp, + Show as ProjectShowDp, + ListAbilities as ProjectListAbilitiesDp, + ShowOperation as ProjectShowOperationDp, +) +from .aaz.latest.devcenter.dev.pool import ( + List as PoolListDp, + Show as PoolShowDp, +) +from .aaz.latest.devcenter.dev.schedule import ( + List as ScheduleListDp, + Show as ScheduleShowDp, +) +from .aaz.latest.devcenter.dev.dev_box import ( + CaptureSnapshot as DevBoxCaptureSnapshot, + Create as DevBoxCreate, + DelayAction as DevBoxDelayAction, + DelayAllActions as DevBoxDelayAllActions, + Delete as DevBoxDelete, + ListAction as DevBoxListAction, + ListAll as DevBoxListAll, + ListOperation as DevBoxListOperation, + ListSnapshot as DevBoxListSnapshot, + List as DevBoxList, + Repair as DevBoxRepair, + Restart as DevBoxRestart, + RestoreSnapshot as DevBoxRestoreSnapshot, + ShowAction as DevBoxShowAction, + ShowOperation as DevBoxShowOperation, + ShowRemoteConnection as DevBoxShowRemoteConnection, + ShowSnapshot as DevBoxShowSnapshot, + Show as DevBoxShow, + SkipAction as DevBoxSkipAction, + Start as DevBoxStart, + Stop as DevBoxStop, +) +from .aaz.latest.devcenter.dev.environment import ( + Create as EnvironmentCreate, + DelayAction as EnvironmentDelayAction, + Delete as EnvironmentDelete, + ListAction as EnvironmentListAction, + ListOperation as EnvironmentListOperation, + List as EnvironmentList, + ShowAction as EnvironmentShowAction, + ShowLogsByOperation as EnvironmentShowLogsByOperation, + ShowOperation as EnvironmentShowOperation, + ShowOutputs as EnvironmentShowOutputs, + Show as EnvironmentShow, + SkipAction as EnvironmentSkipAction, + UpdateExpirationDate as EnvironmentUpdateExpirationDate, +) +from .aaz.latest.devcenter.dev.catalog import ( + List as CatalogListDp, + Show as CatalogShowDp, +) +from .aaz.latest.devcenter.dev.environment_definition import ( + List as EnvironmentDefinitionListDp, + Show as EnvironmentDefinitionShowDp, +) +from .aaz.latest.devcenter.dev.environment_type import ( + List as EnvironmentTypeListDp, + Show as EnvironmentTypeShowDp, + ListAbilities as EnvironmentTypeListAbilitiesDp, +) +from .aaz.latest.devcenter.dev.image_build import ( + ShowLog as ImageBuildShowLogDp, +) +from .aaz.latest.devcenter.dev.customization_group import ( + Create as CustomizationGroupCreate, + List as CustomizationGroupList, + Show as CustomizationGroupShow, +) +from .aaz.latest.devcenter.dev.customization_task import ( + List as CustomizationTaskList, + ShowLogs as CustomizationTaskShowLogs, + Show as CustomizationTaskShow, + Validate as CustomizationTaskValidate, +) from ._validators import ( validate_attached_network_or_dev_box_def, validate_env_name_already_exists, @@ -919,92 +995,109 @@ def _cli_arguments_loader(self): # Data plane - -def devcenter_project_list_dp(cmd, dev_center=None, endpoint=None): +def devcenter_project_list(cmd, dev_center=None, endpoint=None): if dev_center is not None and endpoint is None: resource_graph_data = get_project_arg(cmd.cli_ctx, dev_center) if len(resource_graph_data) == 0: return [] - cf_dataplane = cf_devcenter_dataplane(cmd.cli_ctx, endpoint, dev_center) - return cf_dataplane.dev_center.list_projects() + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return ProjectListDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + }) -def devcenter_project_show_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.dev_center.get_project(project_name=project_name) +def devcenter_project_show(cmd, project_name, dev_center=None, endpoint=None): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return ProjectShowDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "name": project_name + }) -def devcenter_pool_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.dev_boxes.list_pools(project_name=project_name) +def devcenter_project_list_abilities(cmd, project_name, user_id="me", dev_center=None, endpoint=None): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return ProjectListAbilitiesDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "name": project_name, + "user_id": user_id + }) -def devcenter_pool_show_dp( +def devcenter_project_show_operation(cmd, project_name, operation_id, dev_center=None, endpoint=None): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return ProjectShowOperationDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "name": project_name, + "operation_id": operation_id + }) + + +def devcenter_pool_list(cmd, project_name, dev_center=None, endpoint=None): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return PoolListDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name + }) + + +def devcenter_pool_show( cmd, project_name, pool_name, dev_center=None, endpoint=None ): - 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 - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return PoolShowDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "pool_name": pool_name + }) -def devcenter_schedule_list_dp( +def devcenter_schedule_list( cmd, project_name, pool_name=None, dev_center=None, endpoint=None ): - cf_dataplane = cf_devcenter_dataplane( - 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 - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return ScheduleListDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "pool_name": pool_name + }) -def devcenter_schedule_show_dp( +def devcenter_schedule_show( cmd, pool_name, project_name, dev_center=None, endpoint=None ): - cf_dataplane = cf_devcenter_dataplane( - 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" - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return ScheduleShowDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "pool_name": pool_name, + "schedule_name": "default" + }) -def devcenter_dev_box_list( - cmd, dev_center=None, endpoint=None, project_name=None, user_id=None -): - cf_dataplane = cf_devcenter_dataplane( - 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 - ) +def devcenter_dev_box_list(cmd, dev_center=None, endpoint=None, project_name=None, user_id=None): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) 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() + return DevBoxList(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "user_id": user_id, + "project_name": project_name + }) + return DevBoxListAll(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint + }) def devcenter_dev_box_show( cmd, dev_box_name, project_name, dev_center=None, endpoint=None, user_id="me" ): - cf_dataplane = cf_devcenter_dataplane( - 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 - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxShow(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name + }) def devcenter_dev_box_create( @@ -1016,20 +1109,18 @@ def devcenter_dev_box_create( no_wait=False, dev_center=None, endpoint=None, + local_administrator=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - body = {} - body["poolName"] = pool_name - return sdk_no_wait( - no_wait, - cf_dataplane.dev_boxes.begin_create_dev_box, - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - body=body, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxCreate(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "pool_name": pool_name, + "no_wait": no_wait, + "local_administrator": local_administrator + }) def devcenter_dev_box_delete( @@ -1041,16 +1132,14 @@ def devcenter_dev_box_delete( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return sdk_no_wait( - no_wait, - cf_dataplane.dev_boxes.begin_delete_dev_box, - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxDelete(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "no_wait": no_wait + }) def devcenter_dev_box_start( @@ -1062,16 +1151,14 @@ def devcenter_dev_box_start( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return sdk_no_wait( - no_wait, - cf_dataplane.dev_boxes.begin_start_dev_box, - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxStart(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "no_wait": no_wait + }) def devcenter_dev_box_stop( @@ -1084,17 +1171,15 @@ def devcenter_dev_box_stop( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return sdk_no_wait( - no_wait, - cf_dataplane.dev_boxes.begin_stop_dev_box, - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - hibernate=hibernate, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxStop(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "hibernate": hibernate, + "no_wait": no_wait + }) def devcenter_dev_box_restart( @@ -1106,16 +1191,14 @@ def devcenter_dev_box_restart( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return sdk_no_wait( - no_wait, - cf_dataplane.dev_boxes.begin_restart_dev_box, - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxRestart(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "no_wait": no_wait + }) def devcenter_dev_box_repair( @@ -1127,38 +1210,38 @@ def devcenter_dev_box_repair( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return sdk_no_wait( - no_wait, - cf_dataplane.dev_boxes.begin_repair_dev_box, - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxRepair(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "no_wait": no_wait + }) def devcenter_dev_box_get_remote_connection( cmd, project_name, dev_box_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.dev_boxes.get_remote_connection( - project_name=project_name, user_id=user_id, dev_box_name=dev_box_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxShowRemoteConnection(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name + }) def devcenter_dev_box_list_action( cmd, project_name, dev_box_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.dev_boxes.list_actions( - project_name=project_name, user_id=user_id, dev_box_name=dev_box_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxListAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name + }) def devcenter_dev_box_show_action( @@ -1170,16 +1253,14 @@ def devcenter_dev_box_show_action( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - return cf_dataplane.dev_boxes.get_action( - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - action_name=action_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxShowAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "action_name": action_name + }) def devcenter_dev_box_skip_action( @@ -1191,15 +1272,14 @@ def devcenter_dev_box_skip_action( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return cf_dataplane.dev_boxes.skip_action( - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - action_name=action_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxSkipAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "action_name": action_name + }) def devcenter_dev_box_delay_action( @@ -1212,28 +1292,28 @@ def devcenter_dev_box_delay_action( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - upcoming_action = cf_dataplane.dev_boxes.get_action( - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - action_name=action_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + + upcoming_action = DevBoxShowAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "action_name": action_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.dev_boxes.delay_action( - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - action_name=action_name, - until=delayed_time, - ) + return DevBoxDelayAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "action_name": action_name, + "until": delayed_time + }) def devcenter_dev_box_delay_all_actions( @@ -1245,36 +1325,38 @@ def devcenter_dev_box_delay_all_actions( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + actions = DevBoxListAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name + }) - actions = cf_dataplane.dev_boxes.list_actions( - project_name=project_name, user_id=user_id, dev_box_name=dev_box_name - ) earliest_time = get_earliest_time(actions) if earliest_time is None: raise ResourceNotFoundError("There are no scheduled actions for this dev box.") delayed_time = get_delayed_time(delay_time, earliest_time) - - return cf_dataplane.dev_boxes.delay_all_actions( - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - until=delayed_time, - ) + return DevBoxDelayAllActions(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "until": delayed_time + }) def devcenter_dev_box_list_operation( cmd, project_name, dev_box_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.dev_boxes.list_operations( - project_name=project_name, user_id=user_id, dev_box_name=dev_box_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxListOperation(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name + }) def devcenter_dev_box_show_operation( @@ -1286,43 +1368,113 @@ def devcenter_dev_box_show_operation( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return cf_dataplane.dev_boxes.get_operation( - project_name=project_name, - user_id=user_id, - dev_box_name=dev_box_name, - operation_id=operation_id, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxShowOperation(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "operation_id": operation_id + }) + + +def devcenter_dev_box_capture_snapshot( + cmd, + project_name, + dev_box_name, + user_id="me", + no_wait=False, + dev_center=None, + endpoint=None, +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxCaptureSnapshot(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "no_wait": no_wait + }) + + +def devcenter_dev_box_restore_snapshot( + cmd, + project_name, + dev_box_name, + snapshot_id, + user_id="me", + no_wait=False, + dev_center=None, + endpoint=None, +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxRestoreSnapshot(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "snapshot_id": snapshot_id, + "no_wait": no_wait + }) + + +def devcenter_dev_box_show_snapshot( + cmd, + project_name, + dev_box_name, + snapshot_id, + user_id="me", + dev_center=None, + endpoint=None, +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxShowSnapshot(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + "snapshot_id": snapshot_id, + }) + + +def devcenter_dev_box_list_snapshot( + cmd, + project_name, + dev_box_name, + user_id="me", + dev_center=None, + endpoint=None, +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return DevBoxListSnapshot(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "dev_box_name": dev_box_name, + }) def devcenter_environment_list( cmd, project_name, user_id=None, dev_center=None, endpoint=None ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - if user_id is not None: - return cf_dataplane.deployment_environments.list_environments( - project_name=project_name, user_id=user_id - ) - return cf_dataplane.deployment_environments.list_all_environments( - project_name=project_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentList(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id + }) def devcenter_environment_show( 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.deployment_environments.get_environment( - project_name=project_name, user_id=user_id, environment_name=environment_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentShow(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name + }) def devcenter_environment_create( @@ -1339,31 +1491,30 @@ def devcenter_environment_create( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - environments_iterator = cf_dataplane.deployment_environments.list_environments( - project_name=project_name, user_id=user_id - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + + environments_iterator = EnvironmentList(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id + }) + validate_env_name_already_exists( environments_iterator, environment_name, user_id, project_name ) - body = {} - if parameters is not None: - body["parameters"] = parameters - body["environmentType"] = environment_type - body["catalogName"] = catalog_name - body["environmentDefinitionName"] = environment_definition_name - if expiration_date is not None: - body["expirationDate"] = datetime.fromisoformat(expiration_date) - return sdk_no_wait( - no_wait, - cf_dataplane.deployment_environments.begin_create_or_update_environment, - project_name=project_name, - user_id=user_id, - environment_name=environment_name, - body=body, - ) + + return EnvironmentCreate(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "environment_type": environment_type, + "catalog_name": catalog_name, + "environment_definition_name": environment_definition_name, + "expiration_date": datetime.fromisoformat(expiration_date), + "parameters": parameters, + "no_wait": no_wait + }) def devcenter_environment_update( @@ -1377,28 +1528,29 @@ def devcenter_environment_update( endpoint=None, expiration_date=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - environment = cf_dataplane.deployment_environments.get_environment( - project_name=project_name, user_id=user_id, environment_name=environment_name - ) - body = {} - if parameters is not None: - body["parameters"] = parameters - body["environmentType"] = environment["environmentType"] - body["catalogName"] = environment["catalogName"] - body["environmentDefinitionName"] = environment["environmentDefinitionName"] - if expiration_date is not None: - body["expirationDate"] = datetime.fromisoformat(expiration_date) - return sdk_no_wait( - no_wait, - cf_dataplane.deployment_environments.begin_create_or_update_environment, - project_name=project_name, - user_id=user_id, - environment_name=environment_name, - body=body, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + environment = EnvironmentShow(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name + }) + environment_type = environment["environmentType"] + catalog_name = environment["catalogName"] + environment_definition_name = environment["environmentDefinitionName"] + + return EnvironmentCreate(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "environment_type": environment_type, + "catalog_name": catalog_name, + "environment_definition_name": environment_definition_name, + "expiration_date": datetime.fromisoformat(expiration_date), + "parameters": parameters, + "no_wait": no_wait + }) def devcenter_environment_delete( @@ -1411,86 +1563,27 @@ def devcenter_environment_delete( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - return sdk_no_wait( - no_wait, - cf_dataplane.deployment_environments.begin_delete_environment, - project_name=project_name, - user_id=user_id, - environment_name=environment_name, - force=force, - ) - - -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.deployment_environments.list_catalogs(project_name=project_name) - - -def devcenter_catalog_show_dp( - cmd, project_name, catalog_name, dev_center=None, endpoint=None -): - 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 - ) - - -def devcenter_environment_definition_list_dp( - cmd, project_name, dev_center=None, endpoint=None, catalog_name=None -): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - if catalog_name is not None: - 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 - ) - - -def devcenter_environment_definition_show_dp( - cmd, catalog_name, definition_name, project_name, dev_center=None, endpoint=None -): - cf_dataplane = cf_devcenter_dataplane( - 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, - ) - - -def devcenter_environment_type_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.deployment_environments.list_environment_types( - project_name=project_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentDelete(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "no_wait": no_wait, + "force": force + }) def devcenter_environment_operation_list( 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_operations( - project_name=project_name, environment_name=environment_name, user_id=user_id - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentListOperation(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name + }) def devcenter_environment_operation_show( @@ -1502,19 +1595,17 @@ def devcenter_environment_operation_show( 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, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentShowOperation(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "operation_id": operation_id, + "user_id": user_id, + "environment_name": environment_name + }) -def devcenter_environment_operation_show_logs_by_operation( +def devcenter_environment_show_logs_by_operation( cmd, project_name, environment_name, @@ -1523,16 +1614,14 @@ def devcenter_environment_operation_show_logs_by_operation( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - logs = cf_dataplane.environments.get_logs_by_operation( - project_name=project_name, - operation_id=operation_id, - user_id=user_id, - environment_name=environment_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + logs = EnvironmentShowLogsByOperation(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "operation_id": operation_id, + "user_id": user_id, + "environment_name": environment_name + }) for log in logs: if log: @@ -1543,7 +1632,7 @@ def devcenter_environment_operation_show_logs_by_operation( print(log) -def devcenter_environment_operation_show_action( +def devcenter_environment_show_action( cmd, project_name, environment_name, @@ -1552,31 +1641,29 @@ def devcenter_environment_operation_show_action( 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, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentShowAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "action_name": action_name + }) -def devcenter_environment_operation_list_action( +def devcenter_environment_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 - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentListAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name + }) -def devcenter_environment_operation_delay_action( +def devcenter_environment_delay_action( cmd, project_name, environment_name, @@ -1586,32 +1673,30 @@ def devcenter_environment_operation_delay_action( 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, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + upcoming_action = EnvironmentShowAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "action_name": action_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=delayed_time, - environment_name=environment_name, - ) + return EnvironmentDelayAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "action_name": action_name, + "until": delayed_time + }) -def devcenter_environment_operation_skip_action( +def devcenter_environment_skip_action( cmd, project_name, environment_name, @@ -1620,31 +1705,29 @@ def devcenter_environment_operation_skip_action( 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, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentSkipAction(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "action_name": action_name + }) -def devcenter_environment_operation_show_outputs( +def devcenter_environment_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 - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentShowOutputs(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name + }) -def devcenter_environment_operation_update_environment( +def devcenter_environment_update_expiration( cmd, project_name, environment_name, @@ -1653,19 +1736,98 @@ def devcenter_environment_operation_update_environment( endpoint=None, expiration_date=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - body = {} - if expiration_date is not None: - 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, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentUpdateExpirationDate(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "user_id": user_id, + "environment_name": environment_name, + "expiration_date": datetime.fromisoformat(expiration_date) + }) + + +def devcenter_catalog_list(cmd, project_name, dev_center=None, endpoint=None): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return CatalogListDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name + }) + + +def devcenter_catalog_show( + cmd, project_name, catalog_name, dev_center=None, endpoint=None +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return CatalogShowDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "catalog_name": catalog_name + }) + + +def devcenter_environment_definition_list( + cmd, project_name, dev_center=None, endpoint=None, catalog_name=None +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentDefinitionListDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "catalog_name": catalog_name + }) + + +def devcenter_environment_definition_show( + cmd, catalog_name, definition_name, project_name, dev_center=None, endpoint=None +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentDefinitionShowDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "catalog_name": catalog_name, + "definition_name": definition_name + }) + + +def devcenter_environment_type_list( + cmd, project_name, dev_center=None, endpoint=None +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentTypeListDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name + }) + + +def devcenter_environment_type_show( + cmd, project_name, environment_type_name, dev_center=None, endpoint=None +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentTypeShowDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "environment_type_name": environment_type_name + }) + + +def devcenter_environment_type_list_abilities( + cmd, project_name, environment_type_name, user_id="me", dev_center=None, endpoint=None +): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return EnvironmentTypeListAbilitiesDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "environment_type_name": environment_type_name, + "user_id": user_id + }) + + +def devcenter_image_build_show_log(cmd, project_name, image_build_log_id, dev_center=None, endpoint=None): + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return ImageBuildShowLogDp(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "image_build_log_id": image_build_log_id + }) def devcenter_customization_group_create( @@ -1678,21 +1840,16 @@ def devcenter_customization_group_create( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - body = {} - if tasks is not None: - body["tasks"] = tasks - else: - body["tasks"] = [] - return cf_dataplane.dev_boxes.create_customization_group( - project_name=project_name, - dev_box_name=dev_box_name, - customization_group_name=customization_group_name, - user_id=user_id, - body=body, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + + return CustomizationGroupCreate(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "dev_box_name": dev_box_name, + "customization_group_name": customization_group_name, + "user_id": user_id, + "tasks": tasks + }) def devcenter_customization_group_show( @@ -1704,16 +1861,14 @@ def devcenter_customization_group_show( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - return cf_dataplane.dev_boxes.get_customization_group( - project_name=project_name, - dev_box_name=dev_box_name, - customization_group_name=customization_group_name, - user_id=user_id, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return CustomizationGroupShow(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "dev_box_name": dev_box_name, + "customization_group_name": customization_group_name, + "user_id": user_id + }) def devcenter_customization_group_list( @@ -1725,23 +1880,22 @@ def devcenter_customization_group_list( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) include = None if include_tasks: - include = ["tasks"] + include = "tasks" - return cf_dataplane.dev_boxes.list_customization_groups( - project_name=project_name, - dev_box_name=dev_box_name, - user_id=user_id, - include=include, - ) + return CustomizationGroupList(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "dev_box_name": dev_box_name, + "user_id": user_id, + "include": include + }) -def devcenter_customization_task_definition_show( +def devcenter_customization_task_show( cmd, project_name, catalog_name, @@ -1749,33 +1903,29 @@ def devcenter_customization_task_definition_show( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - return cf_dataplane.projects.get_customization_task_definition( - project_name=project_name, - catalog_name=catalog_name, - task_name=task_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return CustomizationTaskShow(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "catalog_name": catalog_name, + "task_name": task_name + }) -def devcenter_customization_task_definition_list( +def devcenter_customization_task_list( cmd, project_name, dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - return cf_dataplane.projects.list_customization_task_definitions( - project_name=project_name, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return CustomizationTaskList(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name + }) -def devcenter_customization_task_definition_validate( +def devcenter_customization_task_validate( cmd, project_name, tasks, @@ -1783,19 +1933,13 @@ def devcenter_customization_task_definition_validate( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - body = {} - body["tasks"] = tasks - - return sdk_no_wait( - no_wait, - cf_dataplane.projects.begin_validate_customization_tasks, - project_name=project_name, - body=body, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return CustomizationTaskValidate(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "project_name": project_name, + "tasks": tasks, + "no_wait": no_wait + }) def devcenter_customization_task_log_show( @@ -1808,14 +1952,12 @@ def devcenter_customization_task_log_show( dev_center=None, endpoint=None, ): - cf_dataplane = cf_devcenter_dataplane( - cmd.cli_ctx, endpoint, dev_center, project_name - ) - - return cf_dataplane.dev_boxes.get_customization_task_log( - 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, - ) + updated_endpoint = get_dataplane_endpoint(cmd.cli_ctx, endpoint, dev_center) + return CustomizationTaskShowLogs(cli_ctx=cmd.cli_ctx)(command_args={ + "endpoint": updated_endpoint, + "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 + }) diff --git a/src/devcenter/azext_devcenter/utils.py b/src/devcenter/azext_devcenter/utils.py index 2a8c880db97..9afb383ac21 100644 --- a/src/devcenter/azext_devcenter/utils.py +++ b/src/devcenter/azext_devcenter/utils.py @@ -5,10 +5,11 @@ # # -------------------------------------------------------------------------- import json -from datetime import (timedelta, datetime) +from datetime import datetime, timedelta from azure.cli.core.azclierror import ResourceNotFoundError, AzureInternalError from azure.cli.core.util import send_raw_request from azure.cli.core._profile import Profile +from ._validators import validate_endpoint def get_project_arg(cli_ctx, dev_center_name, project_name=None): @@ -88,4 +89,15 @@ def get_delayed_time(delay_time, action_time): split_time = delay_time.split(":") hours = int(split_time[0]) minutes = int(split_time[1]) - return action_time + timedelta(hours=hours, minutes=minutes) + delayed_time = action_time + timedelta(hours=hours, minutes=minutes) + return delayed_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ") + + +def get_dataplane_endpoint(cli_ctx, endpoint=None, dev_center=None, project_name=None): + validate_endpoint(endpoint, dev_center) + if endpoint is None and dev_center is not None: + project = get_project_data(cli_ctx, dev_center, project_name) + endpoint = project["devCenterUri"] + endpoint = endpoint.split('//', 1)[-1] + + return endpoint diff --git a/src/devcenter/azext_devcenter/vendored_sdks/__init__.py b/src/devcenter/azext_devcenter/vendored_sdks/__init__.py deleted file mode 100644 index ee0c4f36bd0..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/__init__.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter/__init__.py deleted file mode 100644 index 70f6ed83dec..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._dev_center import DevCenter -__all__ = ['DevCenter'] - -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/_configuration.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter/_configuration.py deleted file mode 100644 index 209795f4a43..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/_configuration.py +++ /dev/null @@ -1,70 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.credentials import TokenCredential - -VERSION = "unknown" - -class DevCenterConfiguration(Configuration): - """Configuration for DevCenter. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - """ - - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if subscription_id is None: - raise ValueError("Parameter 'subscription_id' must not be None.") - super(DevCenterConfiguration, self).__init__(**kwargs) - - self.credential = credential - self.subscription_id = subscription_id - self.api_version = "2023-04-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'devcenter/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/_dev_center.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter/_dev_center.py deleted file mode 100644 index f3c1b9aa9af..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/_dev_center.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import TYPE_CHECKING - -from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - -from ._configuration import DevCenterConfiguration - - -class DevCenter(object): - """DevCenter Management API. - """ - - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = DevCenterConfiguration(credential, subscription_id, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> DevCenter - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/py.typed b/src/devcenter/azext_devcenter/vendored_sdks/devcenter/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/__init__.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/__init__.py deleted file mode 100644 index 6a0e21cc28d..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._client import DevCenterClient -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DevCenterClient", -] -__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/_client.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py deleted file mode 100644 index bf1f9601f26..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_client.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, TYPE_CHECKING - -from azure.core import PipelineClient -from azure.core.rest import HttpRequest, HttpResponse - -from ._configuration import DevCenterClientConfiguration -from ._serialization import Deserializer, Serializer -from .operations import ( - DeploymentEnvironmentsOperations, - DevBoxesOperations, - DevCenterOperations, - EnvironmentsOperations, - ProjectsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword - """DevBox API. - - :ivar dev_center: DevCenterOperations operations - :vartype dev_center: azure.developer.devcenter.operations.DevCenterOperations - :ivar dev_boxes: DevBoxesOperations operations - :vartype dev_boxes: azure.developer.devcenter.operations.DevBoxesOperations - :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 - :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 "2024-05-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 - Retry-After header is present. - """ - - 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) - - 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.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) - - 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 - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, **kwargs) - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> "DevCenterClient": - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py deleted file mode 100644 index 8cc9e7bd6a8..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -from ._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential - - -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 - attributes. - - :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 "2024-05-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", "2024-05-01-preview") - - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.endpoint = endpoint - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.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.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_patch.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py deleted file mode 100644 index 4bae2292227..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_serialization.py +++ /dev/null @@ -1,2006 +0,0 @@ -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- - -# pylint: skip-file -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - TypeVar, - MutableMapping, - Type, - List, - Mapping, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore - -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") - -ModelType = TypeVar("ModelType", bound="Model") -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - 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 - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # 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("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore - -_FLATTEN = re.compile(r"(? None: - 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__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes.""" - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node.""" - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - 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. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises: DeserializationError if something went wrong - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) - - @classmethod - def from_dict( - cls: Type[ModelType], - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> ModelType: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises: DeserializationError if something went wrong - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - """ - return key.replace("\\.", ".") - - -class Serializer(object): - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize(self, target_obj, data_type=None, **kwargs): - """Serialize data into a string according to type. - - :param target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises: SerializationError if serialization fails. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() - try: - attributes = target_obj._attribute_map - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - 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) - else: - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) - except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :keyword bool skip_quote: Whether to skip quote the serialized result. - Defaults to False. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None - """ - try: - # Treat the list aside, since we don't want to encode the div separator - 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)) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param data: The data to be serialized. - :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is AzureCoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - elif data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **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) - else: - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param data: Object to be serialized. - :param str data_type: Type of object in the iterable. - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param data: Object to be serialized. - :rtype: str - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - else: - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list attr: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - :keyword bool do_quote: Whether to quote the serialized result of each iterable element. - Defaults to False. - :rtype: list, str - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. - :rtype: dict - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is unicode_str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) - - @staticmethod - def serialize_bytearray(attr, **kwargs): - """Serialize bytearray into base-64 string. - - :param attr: Object to be serialized. - :rtype: str - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): - """Serialize str into base-64 string. - - :param attr: Object to be serialized. - :rtype: str - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): - """Serialize Decimal object to float. - - :param attr: Object to be serialized. - :rtype: float - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): - """Serialize long (Py2) or int (Py3). - - :param attr: Object to be serialized. - :rtype: int/long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises: TypeError if format invalid. - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises: SerializationError if format invalid. - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) - - @staticmethod - def serialize_unix(attr, **kwargs): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises: SerializationError if format invalid - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") - - -def rest_key_extractor(attr, attr_desc, data): - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor(attr, attr_desc, data): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer(object): - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. - :return: Deserialized object. - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. - :return: Deserialized object. - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, basestring): - return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None: - return data - try: - attributes = response._attribute_map # type: ignore - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - 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) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - """ - if target is None: - return None, None - - if isinstance(target, basestring): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - """ - try: - return self(target_obj, data, content_type=content_type) - except: - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param response: The response model class. - :param d_attrs: The deserialized response attributes. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) - - def deserialize_data(self, data, data_type): - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. - :return: Deserialized object. - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_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) - else: - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :rtype: dict - :raises: TypeError if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, basestring): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - elif isinstance(attr, basestring): - if attr.lower() in ["true", "1"]: - return True - elif attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - else: - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - 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: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :rtype: bytearray - :raises: TypeError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :rtype: bytearray - :raises: TypeError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(attr) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :rtype: long or int - :raises: ValueError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :rtype: TimeDelta - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) - else: - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :rtype: Date - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - 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) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :rtype: datetime.time - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: Datetime - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - 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) - else: - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: Datetime - :raises: DeserializationError if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :rtype: Datetime - :raises: DeserializationError if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - 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) - else: - return date_obj diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_vendor.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_vendor.py deleted file mode 100644 index 8598d2b7459..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/_vendor.py +++ /dev/null @@ -1,20 +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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import List, cast - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/__init__.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/__init__.py deleted file mode 100644 index 7f67c273cc7..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._client import DevCenterClient - -try: - from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DevCenterClient", -] -__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/_client.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py deleted file mode 100644 index f117fa44135..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_client.py +++ /dev/null @@ -1,105 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING - -from azure.core import AsyncPipelineClient -from azure.core.rest import AsyncHttpResponse, HttpRequest - -from .._serialization import Deserializer, Serializer -from ._configuration import DevCenterClientConfiguration -from .operations import ( - DeploymentEnvironmentsOperations, - DevBoxesOperations, - DevCenterOperations, - EnvironmentsOperations, - ProjectsOperations, -) - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -class DevCenterClient: # pylint: disable=client-accepts-api-version-keyword - """DevBox API. - - :ivar dev_center: DevCenterOperations operations - :vartype dev_center: azure.developer.devcenter.aio.operations.DevCenterOperations - :ivar dev_boxes: DevBoxesOperations operations - :vartype dev_boxes: azure.developer.devcenter.aio.operations.DevBoxesOperations - :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 - :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 "2024-05-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 - Retry-After header is present. - """ - - 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) - - 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.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) - - 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 - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, **kwargs) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "DevCenterClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index cd09fd70718..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -from .._version import VERSION - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - - -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 - attributes. - - :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 "2024-05-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", "2024-05-01-preview") - - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - - self.endpoint = endpoint - self.credential = credential - self.api_version = api_version - self.credential_scopes = kwargs.pop("credential_scopes", ["https://devcenter.azure.com/.default"]) - kwargs.setdefault("sdk_moniker", "developer-devcenter/{}".format(VERSION)) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.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.authentication_policy = kwargs.get("authentication_policy") - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( - self.credential, *self.credential_scopes, **kwargs - ) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_patch.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index 484f557dc65..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import DevCenterOperations -from ._operations import DevBoxesOperations -from ._operations import ProjectsOperations -from ._operations import DeploymentEnvironmentsOperations -from ._operations import EnvironmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DevCenterOperations", - "DevBoxesOperations", - "ProjectsOperations", - "DeploymentEnvironmentsOperations", - "EnvironmentsOperations", -] -__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 deleted file mode 100644 index a5550302bfa..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_operations.py +++ /dev/null @@ -1,8340 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -from io import IOBase -import sys -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 -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict - -from ...operations._operations import ( - 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_all_actions_request, - build_dev_boxes_delete_dev_box_request, - build_dev_boxes_get_action_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_request, - build_dev_boxes_list_actions_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_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_abilities_request, - build_dev_center_get_project_request, - build_dev_center_list_projects_request, - build_environments_delay_action_request, - build_environments_get_action_request, - build_environments_get_environment_type_abilities_request, - build_environments_get_environment_type_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): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DevCenterOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.developer.devcenter.aio.DevCenterClient`'s - :attr:`dev_center` 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_projects( - self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[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.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 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 - - 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_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 = 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_async - async def get_project_abilities(self, project_name: str, user_id: str = "me", **kwargs: Any) -> JSON: - """Gets the signed-in user's permitted abilities in a project. - - :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 - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "abilitiesAsAdmin": [ - "str" # The abilities the user has to perform actions on the project - as an admin. Required. - ], - "abilitiesAsDeveloper": [ - "str" # The abilities the user has to perform actions on the project - as a developer. 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_center_get_project_abilities_request( - project_name=project_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), {}) - - return cast(JSON, deserialized) - - -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 - ) -> AsyncIterable[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.async_paging.AsyncItemPaged[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 - - 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_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 = 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_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 {} - _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 - - 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 - def list_schedules( - self, - project_name: str, - pool_name: str, - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[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.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 {} - _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 - - 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_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 = 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_all_dev_boxes( - self, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[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.async_paging.AsyncItemPaged[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 - - 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 - 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. - - :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] - :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 - - 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 - def list_dev_boxes( - self, - project_name: str, - user_id: str = "me", - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable[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.async_paging.AsyncItemPaged[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 - - 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_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 = 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) - - async 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 = 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, 201]: - 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 == 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 - async 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 - ) -> AsyncLROPoller[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 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 = { - "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 - async 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 - ) -> AsyncLROPoller[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 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): 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_async - async def begin_create_dev_box( - self, project_name: str, dev_box_name: str, body: Union[JSON, IO], user_id: str = "me", **kwargs: Any - ) -> AsyncLROPoller[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 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 = { - "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, 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._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: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling( - lro_delay, - lro_options={"final-state-via": "original-uri"}, - 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, - ) - 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 - ) -> 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 = 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) - - return deserialized - - @distributed_trace_async - async def begin_delete_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> AsyncLROPoller[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 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_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: 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.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 - - async 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 = 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]: - 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) - - 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_async - async def begin_start_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> AsyncLROPoller[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 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._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: 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.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 - - async 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 = 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]: - 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) - - 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_async - async def begin_stop_dev_box( - self, - project_name: str, - dev_box_name: str, - user_id: str = "me", - *, - hibernate: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[JSON]: - """Stops 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 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 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._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: 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.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 - - async 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, - 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_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) - - _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]: - 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) - - 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_async - async def begin_restart_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> AsyncLROPoller[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 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._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: 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.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 - - async 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, - 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_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 = 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]: - 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) - - 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_async - async def begin_repair_dev_box( - self, project_name: str, dev_box_name: str, user_id: str = "me", **kwargs: Any - ) -> AsyncLROPoller[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 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._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: 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.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 - - @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 - :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.async_paging.AsyncItemPaged[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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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, - 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_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) - - 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_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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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_get_customization_group_request( - project_name=project_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, - ) - 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) - - @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 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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "uri": "str" # Optional. The unique URI of the customization group. - } - """ - - @overload - async 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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "uri": "str" # Optional. The unique URI of the customization group. - } - """ - - @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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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), {}) - - return cast(JSON, deserialized) - - @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), {}) - - return cast(AsyncIterator[bytes], deserialized) - - @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 == { - "cloudPcConnectionUrl": "str", # Optional. Link to open a remote desktop - session via a dev box's underlying Cloud PC. (This will default to Windows App). - "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, - 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), {}) - - 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 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_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), {}) - - return cast(JSON, deserialized) - - @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, {}) - - @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), {}) - - return cast(JSON, deserialized) - - @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) - - 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 - def list_operations( - self, - project_name: str, - dev_box_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[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 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 "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 - """ - _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 - - 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_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 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. - } - - # 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 - """ - 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), {}) - - return cast(JSON, deserialized) - - -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), {}) - - return cast(JSON, deserialized) - - async def _validate_customization_tasks_initial( - self, project_name: str, body: Union[JSON, IO], **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_projects_validate_customization_tasks_request( - project_name=project_name, - 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 [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) - 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 - 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. - - :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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ] - } - - # 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. - }, - "runAs": "str", # Optional. What account to - run the task as. Known values are: "System" and "User". - "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", "Failed", - "WaitingForUserInputUac", and "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in - seconds. Overrides any timeout provided on the task definition. - } - } - ] - }, - "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. - }, - "runAs": "str", # Optional. What account to - run the task as. Known values are: "System" and "User". - "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", "Failed", - "WaitingForUserInputUac", and "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in - seconds. Overrides any timeout provided on the task definition. - } - } - ] - }, - "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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ] - } - - # 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. - }, - "runAs": "str", # Optional. What account to - run the task as. Known values are: "System" and "User". - "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", "Failed", - "WaitingForUserInputUac", and "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in - seconds. Overrides any timeout provided on the task definition. - } - } - ] - }, - "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_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, - 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.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 - - -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:`deployment_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") - - @distributed_trace - 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. - :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 == { - "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, - 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_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 - - 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 - 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. - - :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.async_paging.AsyncItemPaged[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) - - 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_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) - - 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_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 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: - - 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. - } - """ - 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_deployment_environments_get_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 [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) - - 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 = { - 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_deployment_environments_create_or_update_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 = await 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: - 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) - - 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 - async 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 - ) -> AsyncLROPoller[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 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 = { - "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 == { - "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 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 - ) -> AsyncLROPoller[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 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): 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. - } - """ - - @distributed_trace_async - 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. - - :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 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 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 = { - "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 == { - "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 = 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._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) - - 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, - lro_options={"final-state-via": "original-uri"}, - 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, - ) - 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 - ) -> 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="2024-10-01-preview", #Overwriting while this is the only route on this version. Will remove when version bump completes. - 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) - - return deserialized - - @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.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 - - @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. - - :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, - 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_deployment_environments_get_catalog_request( - project_name=project_name, - catalog_name=catalog_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_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 - :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 == { - "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_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) - - 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 - 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. - - :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] - :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. - } - """ - _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_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) - - 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_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: - - 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. - } - """ - 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_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, - ) - 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_environment_types( - self, project_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable[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.async_paging.AsyncItemPaged[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) - - 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_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 - - 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) - - -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 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", # 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. - } - """ - 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/merge-patch+json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - request = build_environments_patch_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 = 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_async - 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 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: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "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 = { - 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_outputs_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 [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_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 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 - # 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 == environment_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_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, - ) - 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_operation( - self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any - ) -> JSON: - """Gets an environment action result. - - :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: - - 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 == 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), {}) - - return cast(JSON, deserialized) - - @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), {}) - - return cast(AsyncIterator[bytes], deserialized) - - @distributed_trace - def list_actions( - self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any - ) -> AsyncIterable[JSON]: - """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 - :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: 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. "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. - } - """ - _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_actions_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) - - 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_action( - self, project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any - ) -> JSON: - """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 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: 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_get_action_request( - project_name=project_name, - environment_name=environment_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), {}) - - return cast(JSON, deserialized) - - @distributed_trace_async - 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 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: 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_environments_skip_action_request( - project_name=project_name, - environment_name=environment_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, {}) - - @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 - ) - - 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_async - async def get_environment_type( - self, project_name: str, environment_type_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> JSON: - """Get an environment type configured for a project. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param environment_type_name: The name of the environment type. Required. - :type environment_type_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: JSON object - :rtype: 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. - } - """ - 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_environment_type_request( - project_name=project_name, - environment_type_name=environment_type_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) - - _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_async - async def get_environment_type_abilities( - self, - project_name: str, - environment_type_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - **kwargs: Any - ) -> JSON: - """Gets the signed-in user's permitted abilities in an environment type. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param environment_type_name: The name of the environment type. Required. - :type environment_type_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: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "abilitiesAsAdmin": [ - "str" # The abilities the user has to perform actions on the - environment type as an admin. Required. - ], - "abilitiesAsDeveloper": [ - "str" # The abilities the user has to perform actions on the - environment type as a developer. 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_environments_get_environment_type_abilities_request( - project_name=project_name, - environment_type_name=environment_type_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) - - _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) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_patch.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ 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 deleted file mode 100644 index 484f557dc65..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from ._operations import DevCenterOperations -from ._operations import DevBoxesOperations -from ._operations import ProjectsOperations -from ._operations import DeploymentEnvironmentsOperations -from ._operations import EnvironmentsOperations - -from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "DevCenterOperations", - "DevBoxesOperations", - "ProjectsOperations", - "DeploymentEnvironmentsOperations", - "EnvironmentsOperations", -] -__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 deleted file mode 100644 index 8b9f770f95f..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_operations.py +++ /dev/null @@ -1,10838 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# 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 Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, List, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.polling.base_polling import LROBasePolling -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict - -from .._serialization import Serializer - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_dev_center_list_projects_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects" - - # 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_get_project_request(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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}" - 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}$" - ), - } - - _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_dev_center_get_project_abilities_request( - project_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/abilities" - 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$", - ), - } - - _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_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/pools" - 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}$", - ), - } - - _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_dev_boxes_get_pool_request(project_name: str, pool_name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/pools/{poolName}" - 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}$", - ), - "poolName": _SERIALIZER.url( - "pool_name", pool_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_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/schedules" - 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}$", - ), - } - - _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_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/pools/{poolName}/schedules" - 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}$", - ), - "poolName": _SERIALIZER.url( - "pool_name", pool_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_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}" - 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}$", - ), - "poolName": _SERIALIZER.url( - "pool_name", pool_name, "str", max_length=63, min_length=3, pattern=r"^[a-zA-Z0-9][a-zA-Z0-9-_.]{2,62}$" - ), - "scheduleName": _SERIALIZER.url("schedule_name", schedule_name, "str"), - } - - _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_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-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( - 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", "2024-05-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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes" - 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$", - ), - } - - _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_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}" - 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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dev_boxes_create_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 {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}" - 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$", - ), - "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") - - # 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) - - -def build_dev_boxes_delete_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}" - 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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dev_boxes_start_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:start" - 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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dev_boxes_stop_dev_box_request( - project_name: str, dev_box_name: str, user_id: str = "me", *, hibernate: Optional[bool] = 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:stop" - 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$", - ), - "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 hibernate is not None: - _params["hibernate"] = _SERIALIZER.query("hibernate", hibernate, "bool") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dev_boxes_restart_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:restart" - 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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_dev_boxes_repair_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}:repair" - 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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups" - 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$", - ), - "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 include is not None: - _params["include"] = _SERIALIZER.query("include", include, "[str]", div=",") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}" - 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$", - ), - "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}$", - ), - "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 - - # 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_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 {}) - _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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}" - 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$", - ), - "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}$", - ), - "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 - - # Construct parameters - _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) - - -def build_dev_boxes_get_customization_task_log_request( - 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "text/plain") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/customizationGroups/{customizationGroupName}/logs/{customizationTaskId}" # pylint: disable=line-too-long - 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$", - ), - "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}$", - ), - "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}$", - ), - } - - _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_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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/remoteConnection" - 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$", - ), - "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") - - # 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_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - 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 -) -> 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", 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 -) -> 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/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$", - ), - "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", 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 -) -> 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/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$", - ), - "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") - _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) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/actions: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$", - ), - "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") - _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) - - -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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/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$", - ), - "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") - 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_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 {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/devboxes/{devBoxName}/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$", - ), - "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, - 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_projects_list_customization_task_definitions_request( - 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/customizationTasks" - 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}$", - ), - } - - _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="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_projects_get_customization_task_definition_request( - 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/catalogs/{catalogName}/customizationTasks/{taskName}" - 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}$", - ), - "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 - - # 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_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 {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/customizationTasks:validateGroup" - 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}$", - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/environments" - 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}$", - ), - } - - _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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/users/{userId}/environments" - 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$", - ), - } - - _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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - 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 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_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 {}) - _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", "2024-05-01-preview")) - 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 parameters - _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) - - -def build_deployment_environments_delete_environment_request( - project_name: str, environment_name: str, user_id: str = "me", force: Optional[bool] = 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", "2024-10-01-preview")) - 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 parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if force is not None: - _params["force"] = _SERIALIZER.query("force", force, "bool") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/catalogs" - 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}$", - ), - } - - _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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_deployment_environments_get_catalog_request( - 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/catalogs/{catalogName}" - 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}$", - ), - } - - _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_deployment_environments_list_environment_definitions_request( - 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # 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}$", - ), - } - - _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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # 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}$", - ), - } - - _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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # 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}$", - ), - } - - _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_deployment_environments_list_environment_types_request( - 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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # 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}$", - ), - } - - _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") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -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 {}) - _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", "2024-05-01-preview")) - 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 parameters - _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="PATCH", url=_url, params=_params, 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", "2024-05-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( - 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", "2024-05-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", "2024-05-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( - 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", "2024-05-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", "2024-05-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", "2024-05-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", "2024-05-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", "2024-05-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) - - -def build_environments_get_environment_type_request( - project_name: str, environment_type_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/environmentTypes/{environmentTypeName}" - 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}$", - ), - "environmentTypeName": _SERIALIZER.url( - "environment_type_name", - environment_type_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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_environments_get_environment_type_abilities_request( - project_name: str, environment_type_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", "2024-05-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/projects/{projectName}/environmentTypes/{environmentTypeName}/users/{userId}/abilities" - 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}$", - ), - "environmentTypeName": _SERIALIZER.url( - "environment_type_name", - environment_type_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$", - ), - } - - _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") - - 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 __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), {}) - - return cast(JSON, deserialized) - - @distributed_trace - def get_project_abilities(self, project_name: str, user_id: str = "me", **kwargs: Any) -> JSON: - """Gets the signed-in user's permitted abilities in a project. - - :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 - :return: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "abilitiesAsAdmin": [ - "str" # The abilities the user has to perform actions on the project - as an admin. Required. - ], - "abilitiesAsDeveloper": [ - "str" # The abilities the user has to perform actions on the project - as a developer. 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_center_get_project_abilities_request( - project_name=project_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) - - -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), {}) - - return cast(JSON, deserialized) - - @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), {}) - - return cast(JSON, deserialized) - - @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), {}) - - 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 - ) -> 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.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_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) - - return deserialized - - @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.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 _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) - - return cast(JSON, deserialized) - - @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.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")) - - 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_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. - - :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): 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._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.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 _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, - 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_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) - - _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) - - return cast(JSON, deserialized) - - @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. - - :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._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, - 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_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) - - 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 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 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 - :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: - - 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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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, - 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_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) - - 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_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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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_get_customization_group_request( - project_name=project_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, - ) - 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) - - @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 - :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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "uri": "str" # Optional. The unique URI of the customization group. - } - """ - - @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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ], - "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 = 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 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 - ) -> 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 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: - """ - 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[Iterator[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 = 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) - - deserialized = response.iter_bytes() - - if cls: - return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) - - 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: - """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 == { - "cloudPcConnectionUrl": "str", # Optional. Link to open a remote desktop - session via a dev box's underlying Cloud PC. (This will default to Windows App). - "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, - 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 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 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. - }, - "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 - - 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. - - :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 = 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 {} - - 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 = 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 - - # 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), {}) - - return cast(JSON, deserialized) - - @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 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] - :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 - - 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_operations( - 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. - - :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 - """ - _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 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 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. - } - - # 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 - """ - 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 = 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) - - -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 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 - :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 == { - "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 - - 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_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 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) - - def _validate_customization_tasks_initial(self, project_name: str, body: Union[JSON, IO], **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_projects_validate_customization_tasks_request( - project_name=project_name, - 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 [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) - - return cast(JSON, deserialized) - - @overload - def begin_validate_customization_tasks( - self, project_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[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: 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 - - # 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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ] - } - - # 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. - }, - "runAs": "str", # Optional. What account to - run the task as. Known values are: "System" and "User". - "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", "Failed", - "WaitingForUserInputUac", and "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in - seconds. Overrides any timeout provided on the task definition. - } - } - ] - }, - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } - """ - - @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. - - :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: - - 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. - }, - "runAs": "str", # Optional. What account to - run the task as. Known values are: "System" and "User". - "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", "Failed", - "WaitingForUserInputUac", and "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in - seconds. Overrides any timeout provided on the task definition. - } - } - ] - }, - "startTime": "2020-02-20 00:00:00" # Optional. The start time of the - operation. - } - """ - - @distributed_trace - def begin_validate_customization_tasks( - self, project_name: str, body: Union[JSON, IO], **kwargs: Any - ) -> LROPoller[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 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 = { - "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. - }, - "runAs": "str", # Optional. What account to run the task as. - Known values are: "System" and "User". - "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", "Failed", "WaitingForUserInputUac", and - "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in seconds. Overrides any - timeout provided on the task definition. - } - ] - } - - # 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. - }, - "runAs": "str", # Optional. What account to - run the task as. Known values are: "System" and "User". - "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", "Failed", - "WaitingForUserInputUac", and "WaitingForUserSession". - "timeout": 0 # Optional. Timeout, in - seconds. Overrides any timeout provided on the task definition. - } - } - ] - }, - "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, 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._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_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 - - -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) - - 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_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) - - 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_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) - - 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_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 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: - - 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. - } - """ - 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_deployment_environments_get_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 [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) - - 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, - 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_deployment_environments_create_or_update_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_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 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 - - # 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 == { - "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 - 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. - - :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", # 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 - 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 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 - :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 = { - "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 == { - "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 = 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) - - 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", force: Optional[bool] = None, **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, - force=force, - api_version="2024-10-01-preview", #Overwriting while this is the only route on this version. Will remove when version bump completes. - 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", force: Optional[bool] = None, **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 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 force: Optional parameter to force environment deletion even if the environment definition - does not exist. This is a best-effort delete, and anything custom that forces resource creation beyond - the associated resource group may not be deleted. Default value is None. - :paramtype force: 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): 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_environment_initial( - project_name=project_name, - environment_name=environment_name, - user_id=user_id, - force=force, - 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(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 - :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 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 - - 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 == { - "name": "str", # Name of the catalog. Required. - "uri": "str" # The unique URI of the catalog. 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_deployment_environments_get_catalog_request( - project_name=project_name, - catalog_name=catalog_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), {}) - - return cast(JSON, deserialized) - - @distributed_trace - 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 - :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. - } - """ - _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_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) - - 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_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. - } - """ - _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_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) - - 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_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: - - 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. - } - """ - 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_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, - ) - 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 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) - - 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_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) - - 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 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 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 - 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 - 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", # 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. - } - """ - 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/merge-patch+json" - _json = None - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _json = body - - request = build_environments_patch_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 [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 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 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: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "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 = { - 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_outputs_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 [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 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 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": - - # 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 - """ - _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_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, - ) - 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_operation( - self, project_name: str, environment_name: str, operation_id: str, user_id: str = "me", **kwargs: Any - ) -> JSON: - """Gets an environment action result. - - :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: - - 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 == 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 = 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 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 - :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: - """ - 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[Iterator[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 = 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) - - deserialized = response.iter_bytes() - - if cls: - return cls(pipeline_response, cast(Iterator[bytes], deserialized), {}) - - return cast(Iterator[bytes], deserialized) - - @distributed_trace - def list_actions( - self, project_name: str, environment_name: str, user_id: str = "me", **kwargs: Any - ) -> Iterable[JSON]: - """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 - :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: 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. "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. - } - """ - _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_actions_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) - - 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_action( - self, project_name: str, environment_name: str, action_name: str, user_id: str = "me", **kwargs: Any - ) -> JSON: - """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 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: 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_get_action_request( - project_name=project_name, - environment_name=environment_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, 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 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: 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_environments_skip_action_request( - project_name=project_name, - environment_name=environment_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, - 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 - ) - - 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 get_environment_type( - self, project_name: str, environment_type_name: str, *, top: Optional[int] = None, **kwargs: Any - ) -> JSON: - """Get an environment type configured for a project. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param environment_type_name: The name of the environment type. Required. - :type environment_type_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: JSON object - :rtype: 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. - } - """ - 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_environment_type_request( - project_name=project_name, - environment_type_name=environment_type_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) - - _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 get_environment_type_abilities( - self, - project_name: str, - environment_type_name: str, - user_id: str = "me", - *, - top: Optional[int] = None, - **kwargs: Any - ) -> JSON: - """Gets the signed-in user's permitted abilities in an environment type. - - :param project_name: The DevCenter Project upon which to execute operations. Required. - :type project_name: str - :param environment_type_name: The name of the environment type. Required. - :type environment_type_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: JSON object - :rtype: JSON - :raises ~azure.core.exceptions.HttpResponseError: - - Example: - .. code-block:: python - - # response body for status code(s): 200 - response == { - "abilitiesAsAdmin": [ - "str" # The abilities the user has to perform actions on the - environment type as an admin. Required. - ], - "abilitiesAsDeveloper": [ - "str" # The abilities the user has to perform actions on the - environment type as a developer. 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_environments_get_environment_type_abilities_request( - project_name=project_name, - environment_type_name=environment_type_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) - - _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) diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_patch.py b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level - - -def patch_sdk(): - """Do not remove from this file. - - `patch_sdk` is a last resort escape hatch that allows you to do customizations - you can't accomplish using the techniques described in - https://aka.ms/azsdk/python/dpcodegen/python/customize - """ diff --git a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/py.typed b/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/src/devcenter/azext_devcenter/vendored_sdks/devcenter_dataplane/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/src/devcenter/setup.py b/src/devcenter/setup.py index 18beab28b01..9af77fff45b 100644 --- a/src/devcenter/setup.py +++ b/src/devcenter/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages # HISTORY.rst entry. -VERSION = '6.1.0' +VERSION = '6.2.0' try: from azext_devcenter.manual.version import VERSION except ImportError: