diff --git a/src/computelimit/HISTORY.rst b/src/computelimit/HISTORY.rst new file mode 100644 index 00000000000..aa8c06b372a --- /dev/null +++ b/src/computelimit/HISTORY.rst @@ -0,0 +1,10 @@ +.. :changelog: + +Release History +=============== + +1.0.0b1 +++++++ +* Initial release. +* Add shared-limit commands (add, remove, show, list). +* Add guest-subscription commands (add, remove, show, list). \ No newline at end of file diff --git a/src/computelimit/README.md b/src/computelimit/README.md new file mode 100644 index 00000000000..aa21c6c053a --- /dev/null +++ b/src/computelimit/README.md @@ -0,0 +1,64 @@ +# Azure CLI Computelimit Extension # +This is an extension to Azure CLI to manage Computelimit resources. + +## How to use ## +Install the Computelimit extension using the CLI command below + +``` +az extension add --name computelimit +``` + +### Included features ### +There are 2 groups of compute limit operations that customers can perform on their host subscription + +**Guest Subscription Operations:** These type of operations are to add/remove/get guest subscriptions that are added to the host subscription to shared compute limits. + +**Shared Limit Operations:** These type of operations are to enable/disable/get compute limits that are enabled for sharing with the guest subscriptions. + +#### Add a subscription as a guest to the host subscription. #### + +```bash + az computelimit guest-subscription add --location eastus --guest-subscription-id 11111111-1111-1111-1111-111111111111 +``` + +#### Remove a subscription as a guest to the host subscription. #### + +```bash + az computelimit guest-subscription remove --location eastus --guest-subscription-id 11111111-1111-1111-1111-111111111111 +``` + +#### Get a guest subscription added to the host subscription. #### + +```bash + az computelimit guest-subscription show --location eastus --guest-subscription-id 11111111-1111-1111-1111-111111111111 +``` + +#### List all guest subscriptions added to the host subscription. #### + +```bash + az computelimit guest-subscription list --location eastus +``` + +#### Enable a compute limit to be shared by the host subscription with its guest subscriptions. #### + +```bash + az computelimit shared-limit add --location eastus --name StandardDSv3Family +``` + +#### Disable sharing of a compute limit by the host subscription with its guest subscriptions. #### + +```bash + az computelimit shared-limit remove --location eastus --name StandardDSv3Family +``` + +#### Get a compute limit shared by the host subscription with its guest subscriptions. #### + +```bash + az computelimit shared-limit show --location eastus --name StandardDSv3Family +``` + +#### List all compute limits shared by the host subscription with its guest subscriptions. #### + +```bash + az computelimit shared-limit list --location eastus +``` \ No newline at end of file diff --git a/src/computelimit/azext_computelimit/__init__.py b/src/computelimit/azext_computelimit/__init__.py new file mode 100644 index 00000000000..c5e38bf23bb --- /dev/null +++ b/src/computelimit/azext_computelimit/__init__.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_computelimit._help import helps # pylint: disable=unused-import + + +class ComputelimitCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azext_computelimit.custom#{}') + super().__init__(cli_ctx=cli_ctx, + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azext_computelimit.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_computelimit._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = ComputelimitCommandsLoader diff --git a/src/computelimit/azext_computelimit/_help.py b/src/computelimit/azext_computelimit/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/computelimit/azext_computelimit/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/computelimit/azext_computelimit/_params.py b/src/computelimit/azext_computelimit/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/computelimit/azext_computelimit/_params.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: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/computelimit/azext_computelimit/aaz/__init__.py b/src/computelimit/azext_computelimit/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/computelimit/azext_computelimit/aaz/latest/__init__.py b/src/computelimit/azext_computelimit/aaz/latest/__init__.py new file mode 100644 index 00000000000..f6acc11aa4e --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/__init__.py @@ -0,0 +1,10 @@ +# -------------------------------------------------------------------------------------------- +# 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 + diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/__cmd_group.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/__cmd_group.py new file mode 100644 index 00000000000..6e81e362a52 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage compute shared limit resources + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/__init__.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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 * diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/__cmd_group.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/__cmd_group.py new file mode 100644 index 00000000000..03c68a7e68c --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit guest-subscription", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage Guest Subscription + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/__init__.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/__init__.py new file mode 100644 index 00000000000..79e2d553408 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/__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 ._add import * +from ._list import * +from ._remove import * +from ._show import * diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_add.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_add.py new file mode 100644 index 00000000000..c678e8877fc --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_add.py @@ -0,0 +1,225 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit guest-subscription add", + is_preview=True, +) +class Add(AAZCommand): + """Add a subscription as a guest to consume the compute limits shared by the host subscription. + + :example: Add a guest subscription + az computelimit guest-subscription add --location eastus --guest-subscription-id 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/guestsubscriptions/{}", "2025-08-15"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.guest_subscription_id = AAZStrArg( + options=["--id", "--guest-subscription-id"], + help="The guest subscription id", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$", + ), + ) + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.GuestSubscriptionsCreate(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 GuestSubscriptionsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/guestSubscriptions/{guestSubscriptionId}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "guestSubscriptionId", self.ctx.args.guest_subscription_id, + required=True, + ), + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + 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}} + ) + + 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.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _AddHelper: + """Helper class for Add""" + + +__all__ = ["Add"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_list.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_list.py new file mode 100644 index 00000000000..dd34efc5b4f --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_list.py @@ -0,0 +1,211 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit guest-subscription list", + is_preview=True, +) +class List(AAZCommand): + """List all guest subscriptions added to the host subscription in a location. + + :example: List all guest subscriptions + az computelimit guest-subscription list --location eastus + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/guestsubscriptions", "2025-08-15"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.GuestSubscriptionsListBySubscriptionLocationResource(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 GuestSubscriptionsListBySubscriptionLocationResource(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/guestSubscriptions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + 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.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_remove.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_remove.py new file mode 100644 index 00000000000..b054d09a23f --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_remove.py @@ -0,0 +1,145 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit guest-subscription remove", + is_preview=True, + confirmation="Are you sure you want to perform this operation?", +) +class Remove(AAZCommand): + """Remove a subscription as a guest to stop consuming the compute limits shared by the host subscription. + + :example: Remove a guest subscription + az computelimit guest-subscription remove --location eastus --guest-subscription-id 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/guestsubscriptions/{}", "2025-08-15"], + ] + } + + 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 "" + + _args_schema = cls._args_schema + _args_schema.guest_subscription_id = AAZStrArg( + options=["--id", "--guest-subscription-id"], + help="The guest subscription id", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$", + ), + ) + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.GuestSubscriptionsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class GuestSubscriptionsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + 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( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/guestSubscriptions/{guestSubscriptionId}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "guestSubscriptionId", self.ctx.args.guest_subscription_id, + required=True, + ), + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _RemoveHelper: + """Helper class for Remove""" + + +__all__ = ["Remove"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_show.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_show.py new file mode 100644 index 00000000000..922b4626612 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/guest_subscription/_show.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( + "computelimit guest-subscription show", + is_preview=True, +) +class Show(AAZCommand): + """Get a guest subscription added to the host subscription + + :example: Get a guest subscription + az computelimit guest-subscription show --location eastus --guest-subscription-id 11111111-1111-1111-1111-111111111111 + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/guestsubscriptions/{}", "2025-08-15"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.guest_subscription_id = AAZStrArg( + options=["--id", "--guest-subscription-id"], + help="The guest subscription id", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$", + ), + ) + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.GuestSubscriptionsGet(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 GuestSubscriptionsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/guestSubscriptions/{guestSubscriptionId}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "guestSubscriptionId", self.ctx.args.guest_subscription_id, + required=True, + ), + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/__cmd_group.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/__cmd_group.py new file mode 100644 index 00000000000..8f0886470d7 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/__cmd_group.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit shared-limit", + is_preview=True, +) +class __CMDGroup(AAZCommandGroup): + """Manage Shared Limit + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/__init__.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/__init__.py new file mode 100644 index 00000000000..79e2d553408 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/__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 ._add import * +from ._list import * +from ._remove import * +from ._show import * diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_add.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_add.py new file mode 100644 index 00000000000..94fb25c21c6 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_add.py @@ -0,0 +1,244 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit shared-limit add", + is_preview=True, +) +class Add(AAZCommand): + """Enable a compute limit to be shared by the host subscription with its guest subscriptions. + + :example: Enable a shared limit + az computelimit shared-limit add --location eastus --name StandardDSv3Family + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/sharedlimits/{}", "2025-08-15"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The VM Family Name of the quota limit to be shared", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,24}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SharedLimitsCreate(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 SharedLimitsCreate(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200, 201]: + return self.on_200_201(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/sharedLimits/{name}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + 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}} + ) + + 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.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.limit = AAZIntType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.resource_name = AAZObjectType( + serialized_name="resourceName", + flags={"read_only": True}, + ) + properties.unit = AAZStrType( + flags={"read_only": True}, + ) + + resource_name = cls._schema_on_200_201.properties.resource_name + resource_name.localized_value = AAZStrType( + serialized_name="localizedValue", + flags={"read_only": True}, + ) + resource_name.value = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200_201 + + +class _AddHelper: + """Helper class for Add""" + + +__all__ = ["Add"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_list.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_list.py new file mode 100644 index 00000000000..59ca4977a52 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_list.py @@ -0,0 +1,230 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit shared-limit list", + is_preview=True, +) +class List(AAZCommand): + """List all compute limits shared by the host subscription with its guest subscriptions. + + :example: List all shared limits + az computelimit shared-limit list --location eastus + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/sharedlimits", "2025-08-15"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SharedLimitsListBySubscriptionLocationResource(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 SharedLimitsListBySubscriptionLocationResource(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/sharedLimits", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + 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.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.limit = AAZIntType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.resource_name = AAZObjectType( + serialized_name="resourceName", + flags={"read_only": True}, + ) + properties.unit = AAZStrType( + flags={"read_only": True}, + ) + + resource_name = cls._schema_on_200.value.Element.properties.resource_name + resource_name.localized_value = AAZStrType( + serialized_name="localizedValue", + flags={"read_only": True}, + ) + resource_name.value = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_remove.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_remove.py new file mode 100644 index 00000000000..ca92072f414 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_remove.py @@ -0,0 +1,145 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "computelimit shared-limit remove", + is_preview=True, + confirmation="Are you sure you want to perform this operation?", +) +class Remove(AAZCommand): + """Disable sharing of a compute limit by the host subscription with its guest subscriptions. + + :example: Disable a shared limit + az computelimit shared-limit remove --location eastus --name StandardDSv3Family + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/sharedlimits/{}", "2025-08-15"], + ] + } + + 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 "" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The VM Family Name of the quota limit to be shared", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,24}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SharedLimitsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class SharedLimitsDelete(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + 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( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/sharedLimits/{name}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _RemoveHelper: + """Helper class for Remove""" + + +__all__ = ["Remove"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_show.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_show.py new file mode 100644 index 00000000000..f67c62265ea --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/shared_limit/_show.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( + "computelimit shared-limit show", + is_preview=True, +) +class Show(AAZCommand): + """Get a compute limit shared by the host subscription with its guest subscriptions. + + :example: Get a shared limit + az computelimit shared-limit show --location eastus --name StandardDSv3Family + """ + + _aaz_info = { + "version": "2025-08-15", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/sharedlimits/{}", "2025-08-15"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + help="The Azure location name", + required=True, + id_part="name", + ) + _args_schema.name = AAZStrArg( + options=["-n", "--name"], + help="The VM Family Name of the quota limit to be shared", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,24}$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SharedLimitsGet(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 SharedLimitsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/providers/Microsoft.ComputeLimit/locations/{location}/sharedLimits/{name}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "location", self.ctx.args.location, + required=True, + ), + **self.serialize_url_param( + "name", self.ctx.args.name, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-08-15", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": True}, + ) + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.properties + properties.limit = AAZIntType( + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.resource_name = AAZObjectType( + serialized_name="resourceName", + flags={"read_only": True}, + ) + properties.unit = AAZStrType( + flags={"read_only": True}, + ) + + resource_name = cls._schema_on_200.properties.resource_name + resource_name.localized_value = AAZStrType( + serialized_name="localizedValue", + flags={"read_only": True}, + ) + resource_name.value = AAZStrType( + flags={"required": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/computelimit/azext_computelimit/azext_metadata.json b/src/computelimit/azext_computelimit/azext_metadata.json new file mode 100644 index 00000000000..71889bb136b --- /dev/null +++ b/src/computelimit/azext_computelimit/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.75.0" +} \ No newline at end of file diff --git a/src/computelimit/azext_computelimit/commands.py b/src/computelimit/azext_computelimit/commands.py new file mode 100644 index 00000000000..b0d842e4993 --- /dev/null +++ b/src/computelimit/azext_computelimit/commands.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: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): # pylint: disable=unused-argument + pass diff --git a/src/computelimit/azext_computelimit/custom.py b/src/computelimit/azext_computelimit/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/computelimit/azext_computelimit/custom.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: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger + + +logger = get_logger(__name__) diff --git a/src/computelimit/azext_computelimit/tests/__init__.py b/src/computelimit/azext_computelimit/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/computelimit/azext_computelimit/tests/latest/__init__.py b/src/computelimit/azext_computelimit/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_add.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_add.yaml new file mode 100644 index 00000000000..6a2108c8758 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_add.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription add + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111","name":"11111111-1111-1111-1111-111111111111","type":"Microsoft.ComputeLimit/locations/guestSubscriptions","properties":{"provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_crud.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_crud.yaml new file mode 100644 index 00000000000..af903607e2d --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_crud.yaml @@ -0,0 +1,148 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription add + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111","name":"11111111-1111-1111-1111-111111111111","type":"Microsoft.ComputeLimit/locations/guestSubscriptions","properties":{"provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:01 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription show + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111","name":"11111111-1111-1111-1111-111111111111","type":"Microsoft.ComputeLimit/locations/guestSubscriptions","properties":{"provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:02 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions?api-version=2025-08-15 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111","name":"11111111-1111-1111-1111-111111111111","type":"Microsoft.ComputeLimit/locations/guestSubscriptions","properties":{"provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}]}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription remove + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111?api-version=2025-08-15 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 24 Mar 2026 12:00:04 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_list.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_list.yaml new file mode 100644 index 00000000000..e8cb94df7c9 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_list.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions?api-version=2025-08-15 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111","name":"11111111-1111-1111-1111-111111111111","type":"Microsoft.ComputeLimit/locations/guestSubscriptions","properties":{"provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}]}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_remove.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_remove.yaml new file mode 100644 index 00000000000..dfc3ddb5807 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_remove.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription remove + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111?api-version=2025-08-15 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_show.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_show.yaml new file mode 100644 index 00000000000..f3f1a3cf34a --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_guest_subscription_show.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit guest-subscription show + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/guestSubscriptions/11111111-1111-1111-1111-111111111111","name":"11111111-1111-1111-1111-111111111111","type":"Microsoft.ComputeLimit/locations/guestSubscriptions","properties":{"provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_add.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_add.yaml new file mode 100644 index 00000000000..0c589dd19ae --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_add.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit add + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family","name":"StandardDSv3Family","type":"Microsoft.ComputeLimit/locations/sharedLimits","properties":{"resourceName":{"value":"StandardDSv3Family","localizedValue":"Standard + DSv3 Family vCPUs"},"limit":100,"unit":"Count","provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_crud.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_crud.yaml new file mode 100644 index 00000000000..563ca11f555 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_crud.yaml @@ -0,0 +1,151 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit add + Connection: + - keep-alive + Content-Type: + - application/json + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family","name":"StandardDSv3Family","type":"Microsoft.ComputeLimit/locations/sharedLimits","properties":{"resourceName":{"value":"StandardDSv3Family","localizedValue":"Standard + DSv3 Family vCPUs"},"limit":100,"unit":"Count","provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:01 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit show + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family","name":"StandardDSv3Family","type":"Microsoft.ComputeLimit/locations/sharedLimits","properties":{"resourceName":{"value":"StandardDSv3Family","localizedValue":"Standard + DSv3 Family vCPUs"},"limit":100,"unit":"Count","provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:02 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits?api-version=2025-08-15 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family","name":"StandardDSv3Family","type":"Microsoft.ComputeLimit/locations/sharedLimits","properties":{"resourceName":{"value":"StandardDSv3Family","localizedValue":"Standard + DSv3 Family vCPUs"},"limit":100,"unit":"Count","provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}]}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit remove + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family?api-version=2025-08-15 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 24 Mar 2026 12:00:04 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_list.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_list.yaml new file mode 100644 index 00000000000..dd328002e6f --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_list.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits?api-version=2025-08-15 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family","name":"StandardDSv3Family","type":"Microsoft.ComputeLimit/locations/sharedLimits","properties":{"resourceName":{"value":"StandardDSv3Family","localizedValue":"Standard + DSv3 Family vCPUs"},"limit":100,"unit":"Count","provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}]}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_remove.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_remove.yaml new file mode 100644 index 00000000000..3cd0e30c90b --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_remove.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit remove + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family?api-version=2025-08-15 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_show.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_show.yaml new file mode 100644 index 00000000000..d107c3a0419 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_shared_limit_show.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit shared-limit show + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.84.0 azsdk-python-core/1.31.0 Python/3.12.10 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family?api-version=2025-08-15 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/sharedLimits/StandardDSv3Family","name":"StandardDSv3Family","type":"Microsoft.ComputeLimit/locations/sharedLimits","properties":{"resourceName":{"value":"StandardDSv3Family","localizedValue":"Standard + DSv3 Family vCPUs"},"limit":100,"unit":"Count","provisioningState":"Succeeded"},"systemData":{"createdBy":"user@contoso.com","createdByType":"User","createdAt":"2025-03-01T00:00:00.0000000Z","lastModifiedBy":"user@contoso.com","lastModifiedByType":"User","lastModifiedAt":"2025-03-01T00:00:00.0000000Z"}}' + headers: + cache-control: + - no-cache + content-type: + - application/json; charset=utf-8 + date: + - Mon, 24 Mar 2026 12:00:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/test_computelimit.py b/src/computelimit/azext_computelimit/tests/latest/test_computelimit.py new file mode 100644 index 00000000000..43a2dc21f1f --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/test_computelimit.py @@ -0,0 +1,293 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, record_only +from azure.cli.core.azclierror import InvalidArgumentValueError + + +class ComputelimitScenario(ScenarioTest): + + @record_only() + def test_computelimit_shared_limit_list(self): + """Test listing all shared limits in a location.""" + self.kwargs.update({ + 'location': 'eastus' + }) + + # List all shared limits + result = self.cmd( + 'az computelimit shared-limit list --location {location}' + ).get_output_in_json() + + # Verify result is a list + self.assertIsInstance(result, list) + + @record_only() + def test_computelimit_shared_limit_show(self): + """Test showing a specific shared limit.""" + self.kwargs.update({ + 'location': 'eastus', + 'name': 'StandardDSv3Family' + }) + + # Show a shared limit + result = self.cmd( + 'az computelimit shared-limit show --location {location} --name {name}', + checks=[ + self.check('name', '{name}'), + self.check('provisioningState', 'Succeeded') + ] + ).get_output_in_json() + + # Verify response contains expected fields + self.assertIsNotNone(result) + self.assertIn('name', result) + self.assertIn('id', result) + self.assertIn('type', result) + + @record_only() + def test_computelimit_shared_limit_add(self): + """Test enabling a shared limit.""" + self.kwargs.update({ + 'location': 'eastus', + 'name': 'StandardDSv3Family' + }) + + # Add/enable a shared limit + result = self.cmd( + 'az computelimit shared-limit add --location {location} --name {name}', + checks=[ + self.check('name', '{name}'), + self.check('provisioningState', 'Succeeded') + ] + ).get_output_in_json() + + # Verify response contains expected fields + self.assertIsNotNone(result) + self.assertIn('name', result) + self.assertIn('id', result) + + @record_only() + def test_computelimit_shared_limit_remove(self): + """Test disabling a shared limit.""" + self.kwargs.update({ + 'location': 'eastus', + 'name': 'StandardDSv3Family' + }) + + # Remove/disable a shared limit (using --yes to skip confirmation) + self.cmd( + 'az computelimit shared-limit remove --location {location} --name {name} --yes' + ) + + @record_only() + def test_computelimit_shared_limit_crud(self): + """Test complete CRUD workflow for shared limits.""" + self.kwargs.update({ + 'location': 'eastus', + 'name': 'StandardDSv3Family' + }) + + # Add a shared limit + add_result = self.cmd( + 'az computelimit shared-limit add --location {location} --name {name}', + checks=[ + self.check('name', '{name}') + ] + ).get_output_in_json() + self.assertIsNotNone(add_result) + + # Show the shared limit + show_result = self.cmd( + 'az computelimit shared-limit show --location {location} --name {name}', + checks=[ + self.check('name', '{name}') + ] + ).get_output_in_json() + self.assertIsNotNone(show_result) + self.assertEqual(show_result['name'], self.kwargs['name']) + + # List shared limits and verify the added limit is present + list_result = self.cmd( + 'az computelimit shared-limit list --location {location}' + ).get_output_in_json() + self.assertIsInstance(list_result, list) + names = [item['name'] for item in list_result] + self.assertIn(self.kwargs['name'], names) + + # Remove the shared limit + self.cmd( + 'az computelimit shared-limit remove --location {location} --name {name} --yes' + ) + + # ============================================= + # Guest Subscription Tests + # ============================================= + + @record_only() + def test_computelimit_guest_subscription_list(self): + """Test listing all guest subscriptions in a location.""" + self.kwargs.update({ + 'location': 'eastus' + }) + + # List all guest subscriptions + result = self.cmd( + 'az computelimit guest-subscription list --location {location}' + ).get_output_in_json() + + # Verify result is a list + self.assertIsInstance(result, list) + + @record_only() + def test_computelimit_guest_subscription_show(self): + """Test showing a specific guest subscription.""" + self.kwargs.update({ + 'location': 'eastus', + 'guest_subscription_id': '11111111-1111-1111-1111-111111111111' + }) + + # Show a guest subscription + result = self.cmd( + 'az computelimit guest-subscription show --location {location} --guest-subscription-id {guest_subscription_id}', + checks=[ + self.check('name', '{guest_subscription_id}'), + self.check('provisioningState', 'Succeeded') + ] + ).get_output_in_json() + + # Verify response contains expected fields + self.assertIsNotNone(result) + self.assertIn('name', result) + self.assertIn('id', result) + self.assertIn('type', result) + + @record_only() + def test_computelimit_guest_subscription_add(self): + """Test adding a guest subscription.""" + self.kwargs.update({ + 'location': 'eastus', + 'guest_subscription_id': '11111111-1111-1111-1111-111111111111' + }) + + # Add a guest subscription + result = self.cmd( + 'az computelimit guest-subscription add --location {location} --guest-subscription-id {guest_subscription_id}', + checks=[ + self.check('name', '{guest_subscription_id}'), + self.check('provisioningState', 'Succeeded') + ] + ).get_output_in_json() + + # Verify response contains expected fields + self.assertIsNotNone(result) + self.assertIn('name', result) + self.assertIn('id', result) + + @record_only() + def test_computelimit_guest_subscription_remove(self): + """Test removing a guest subscription.""" + self.kwargs.update({ + 'location': 'eastus', + 'guest_subscription_id': '11111111-1111-1111-1111-111111111111' + }) + + # Remove a guest subscription (using --yes to skip confirmation) + self.cmd( + 'az computelimit guest-subscription remove --location {location} --guest-subscription-id {guest_subscription_id} --yes' + ) + + @record_only() + def test_computelimit_guest_subscription_crud(self): + """Test complete CRUD workflow for guest subscriptions.""" + self.kwargs.update({ + 'location': 'eastus', + 'guest_subscription_id': '11111111-1111-1111-1111-111111111111' + }) + + # Add a guest subscription + add_result = self.cmd( + 'az computelimit guest-subscription add --location {location} --guest-subscription-id {guest_subscription_id}', + checks=[ + self.check('name', '{guest_subscription_id}') + ] + ).get_output_in_json() + self.assertIsNotNone(add_result) + + # Show the guest subscription + show_result = self.cmd( + 'az computelimit guest-subscription show --location {location} --guest-subscription-id {guest_subscription_id}', + checks=[ + self.check('name', '{guest_subscription_id}') + ] + ).get_output_in_json() + self.assertIsNotNone(show_result) + self.assertEqual(show_result['name'], self.kwargs['guest_subscription_id']) + + # List guest subscriptions and verify the added subscription is present + list_result = self.cmd( + 'az computelimit guest-subscription list --location {location}' + ).get_output_in_json() + self.assertIsInstance(list_result, list) + names = [item['name'] for item in list_result] + self.assertIn(self.kwargs['guest_subscription_id'], names) + + # Remove the guest subscription + self.cmd( + 'az computelimit guest-subscription remove --location {location} --guest-subscription-id {guest_subscription_id} --yes' + ) + + # ============================================= + # Negative / Validation Tests + # ============================================= + + def test_computelimit_guest_subscription_add_invalid_uuid(self): + """Test that an invalid guest subscription ID (not a UUID) is rejected.""" + self.kwargs.update({ + 'location': 'eastus', + 'guest_subscription_id': 'not-a-valid-uuid' + }) + with self.assertRaises(InvalidArgumentValueError): + self.cmd( + 'az computelimit guest-subscription add --location {location} ' + '--guest-subscription-id {guest_subscription_id}' + ) + + def test_computelimit_shared_limit_add_name_too_short(self): + """Test that a shared limit name shorter than 3 characters is rejected.""" + self.kwargs.update({ + 'location': 'eastus', + 'name': 'ab' + }) + with self.assertRaises(InvalidArgumentValueError): + self.cmd( + 'az computelimit shared-limit add --location {location} --name {name}' + ) + + def test_computelimit_shared_limit_add_name_special_chars(self): + """Test that a shared limit name with special characters is rejected.""" + self.kwargs.update({ + 'location': 'eastus', + 'name': 'Standard@DSv3!' + }) + with self.assertRaises(InvalidArgumentValueError): + self.cmd( + 'az computelimit shared-limit add --location {location} --name {name}' + ) + + def test_computelimit_shared_limit_add_missing_location(self): + """Test that missing required --location parameter is rejected.""" + with self.assertRaises(InvalidArgumentValueError): + self.cmd('az computelimit shared-limit add --name StandardDSv3Family') + + def test_computelimit_guest_subscription_add_missing_location(self): + """Test that missing required --location parameter is rejected.""" + with self.assertRaises(InvalidArgumentValueError): + self.cmd( + 'az computelimit guest-subscription add ' + '--guest-subscription-id 11111111-1111-1111-1111-111111111111' + ) diff --git a/src/computelimit/setup.cfg b/src/computelimit/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/computelimit/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/computelimit/setup.py b/src/computelimit/setup.py new file mode 100644 index 00000000000..8d640c4d985 --- /dev/null +++ b/src/computelimit/setup.py @@ -0,0 +1,51 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + + +# HISTORY.rst entry. +VERSION = '1.0.0b1' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='computelimit', + version=VERSION, + description='Microsoft Azure Command-Line Tools Computelimit Extension.', + long_description=README + '\n\n' + HISTORY, + license='MIT', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/main/src/computelimit', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + package_data={'azext_computelimit': ['azext_metadata.json']}, + install_requires=DEPENDENCIES +)