diff --git a/src/computelimit/HISTORY.rst b/src/computelimit/HISTORY.rst index a5c413a223e..6153d7eb179 100644 --- a/src/computelimit/HISTORY.rst +++ b/src/computelimit/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +1.1.0 +++++++ +* Add trusted-host-subscription commands (add, remove, show, list). + 1.0.0 ++++++ * Stable release of the computelimit extension. diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/__cmd_group.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/__cmd_group.py new file mode 100644 index 00000000000..a3c5da34185 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command_group( + "computelimit trusted-host-subscription", +) +class __CMDGroup(AAZCommandGroup): + """Manage Trusted Host Subscription + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/__init__.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/__init__.py new file mode 100644 index 00000000000..79e2d553408 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_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/trusted_host_subscription/_add.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_add.py new file mode 100644 index 00000000000..9d2d815e3e7 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_add.py @@ -0,0 +1,217 @@ +# -------------------------------------------------------------------------------------------- +# 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 trusted-host-subscription add", +) +class Add(AAZCommand): + """Create a host subscription to the guest subscription's list of trusted hosts. A guest +subscription can trust multiple host subscriptions; this only establishes trust and +does not check the guest in to the host. Guest-to-host association is determined at +check-in time, where a subscription can be a guest of at most one host per region. + + :example: Add a trusted host subscription + az computelimit trusted-host-subscription add --location eastus --host-subscription-id 22222222-2222-2222-2222-222222222222 + """ + + _aaz_info = { + "version": "2026-07-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/trustedhostsubscriptions/{}", "2026-07-31"], + ] + } + + 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.host_subscription_id = AAZStrArg( + options=["-n", "--name", "--host-subscription-id"], + help="The name of the TrustedHostSubscription", + 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( + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TrustedHostSubscriptionsCreate(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 TrustedHostSubscriptionsCreate(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}/trustedHostSubscriptions/{hostSubscriptionId}", + **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( + "hostSubscriptionId", self.ctx.args.host_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", "2026-07-31", + 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.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.type = AAZStrType( + 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/trusted_host_subscription/_list.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_list.py new file mode 100644 index 00000000000..b4554988040 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_list.py @@ -0,0 +1,200 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "computelimit trusted-host-subscription list", +) +class List(AAZCommand): + """List all host subscriptions that the guest subscription trusts in a location. + + :example: List all trusted host subscriptions + az computelimit trusted-host-subscription list --location eastus + """ + + _aaz_info = { + "version": "2026-07-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/trustedhostsubscriptions", "2026-07-31"], + ] + } + + 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( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TrustedHostSubscriptionsListBySubscriptionLocationResource(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 TrustedHostSubscriptionsListBySubscriptionLocationResource(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}/trustedHostSubscriptions", + **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", "2026-07-31", + 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.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_remove.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_remove.py new file mode 100644 index 00000000000..c6926fbdb6b --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_remove.py @@ -0,0 +1,143 @@ +# -------------------------------------------------------------------------------------------- +# 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 trusted-host-subscription remove", + confirmation="Are you sure you want to perform this operation?", +) +class Remove(AAZCommand): + """Delete a host subscription from the guest subscription's list of trusted hosts. + + :example: Remove a trusted host subscription + az computelimit trusted-host-subscription remove --location eastus --host-subscription-id 22222222-2222-2222-2222-222222222222 + """ + + _aaz_info = { + "version": "2026-07-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/trustedhostsubscriptions/{}", "2026-07-31"], + ] + } + + 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.host_subscription_id = AAZStrArg( + options=["-n", "--name", "--host-subscription-id"], + help="The name of the TrustedHostSubscription", + 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( + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TrustedHostSubscriptionsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class TrustedHostSubscriptionsDelete(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}/trustedHostSubscriptions/{hostSubscriptionId}", + **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( + "hostSubscriptionId", self.ctx.args.host_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", "2026-07-31", + 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/trusted_host_subscription/_show.py b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_show.py new file mode 100644 index 00000000000..b454b735fd7 --- /dev/null +++ b/src/computelimit/azext_computelimit/aaz/latest/computelimit/trusted_host_subscription/_show.py @@ -0,0 +1,201 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "computelimit trusted-host-subscription show", +) +class Show(AAZCommand): + """Get a host subscription that the guest subscription trusts. + + :example: Get a trusted host subscription + az computelimit trusted-host-subscription show --location eastus --host-subscription-id 22222222-2222-2222-2222-222222222222 + """ + + _aaz_info = { + "version": "2026-07-31", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.computelimit/locations/{}/trustedhostsubscriptions/{}", "2026-07-31"], + ] + } + + 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.host_subscription_id = AAZStrArg( + options=["-n", "--name", "--host-subscription-id"], + help="The name of the TrustedHostSubscription", + 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( + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TrustedHostSubscriptionsGet(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 TrustedHostSubscriptionsGet(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}/trustedHostSubscriptions/{hostSubscriptionId}", + **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( + "hostSubscriptionId", self.ctx.args.host_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", "2026-07-31", + 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.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_add.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_add.yaml new file mode 100644 index 00000000000..03807ca52df --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_add.yaml @@ -0,0 +1,40 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit trusted-host-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/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222?api-version=2026-07-31 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222","name":"22222222-2222-2222-2222-222222222222","type":"Microsoft.ComputeLimit/locations/trustedHostSubscriptions","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 +version: 1 diff --git a/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_crud.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_crud.yaml new file mode 100644 index 00000000000..5f066728940 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_crud.yaml @@ -0,0 +1,148 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit trusted-host-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/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222?api-version=2026-07-31 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222","name":"22222222-2222-2222-2222-222222222222","type":"Microsoft.ComputeLimit/locations/trustedHostSubscriptions","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 trusted-host-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/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222?api-version=2026-07-31 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222","name":"22222222-2222-2222-2222-222222222222","type":"Microsoft.ComputeLimit/locations/trustedHostSubscriptions","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 trusted-host-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/trustedHostSubscriptions?api-version=2026-07-31 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222","name":"22222222-2222-2222-2222-222222222222","type":"Microsoft.ComputeLimit/locations/trustedHostSubscriptions","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 trusted-host-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/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222?api-version=2026-07-31 + 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_trusted_host_subscription_list.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_list.yaml new file mode 100644 index 00000000000..1b9d078dee9 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_list.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit trusted-host-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/trustedHostSubscriptions?api-version=2026-07-31 + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222","name":"22222222-2222-2222-2222-222222222222","type":"Microsoft.ComputeLimit/locations/trustedHostSubscriptions","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_trusted_host_subscription_remove.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_remove.yaml new file mode 100644 index 00000000000..0d3c4a44e32 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_remove.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit trusted-host-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/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222?api-version=2026-07-31 + 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_trusted_host_subscription_show.yaml b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_show.yaml new file mode 100644 index 00000000000..1b1709ed168 --- /dev/null +++ b/src/computelimit/azext_computelimit/tests/latest/recordings/test_computelimit_trusted_host_subscription_show.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - computelimit trusted-host-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/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222?api-version=2026-07-31 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ComputeLimit/locations/eastus/trustedHostSubscriptions/22222222-2222-2222-2222-222222222222","name":"22222222-2222-2222-2222-222222222222","type":"Microsoft.ComputeLimit/locations/trustedHostSubscriptions","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 index 43a2dc21f1f..74a1d4206f6 100644 --- a/src/computelimit/azext_computelimit/tests/latest/test_computelimit.py +++ b/src/computelimit/azext_computelimit/tests/latest/test_computelimit.py @@ -291,3 +291,138 @@ def test_computelimit_guest_subscription_add_missing_location(self): 'az computelimit guest-subscription add ' '--guest-subscription-id 11111111-1111-1111-1111-111111111111' ) + + # ============================================= + # Trusted Host Subscription Tests + # ============================================= + + @record_only() + def test_computelimit_trusted_host_subscription_list(self): + """Test listing all trusted host subscriptions in a location.""" + self.kwargs.update({ + 'location': 'eastus' + }) + + # List all trusted host subscriptions + result = self.cmd( + 'az computelimit trusted-host-subscription list --location {location}' + ).get_output_in_json() + + # Verify result is a list + self.assertIsInstance(result, list) + + @record_only() + def test_computelimit_trusted_host_subscription_show(self): + """Test showing a specific trusted host subscription.""" + self.kwargs.update({ + 'location': 'eastus', + 'host_subscription_id': '22222222-2222-2222-2222-222222222222' + }) + + # Show a trusted host subscription + result = self.cmd( + 'az computelimit trusted-host-subscription show --location {location} --host-subscription-id {host_subscription_id}', + checks=[ + self.check('name', '{host_subscription_id}') + ] + ).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_trusted_host_subscription_add(self): + """Test adding a trusted host subscription.""" + self.kwargs.update({ + 'location': 'eastus', + 'host_subscription_id': '22222222-2222-2222-2222-222222222222' + }) + + # Add a trusted host subscription + result = self.cmd( + 'az computelimit trusted-host-subscription add --location {location} --host-subscription-id {host_subscription_id}', + checks=[ + self.check('name', '{host_subscription_id}') + ] + ).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_trusted_host_subscription_remove(self): + """Test removing a trusted host subscription.""" + self.kwargs.update({ + 'location': 'eastus', + 'host_subscription_id': '22222222-2222-2222-2222-222222222222' + }) + + # Remove a trusted host subscription (using --yes to skip confirmation) + self.cmd( + 'az computelimit trusted-host-subscription remove --location {location} --host-subscription-id {host_subscription_id} --yes' + ) + + @record_only() + def test_computelimit_trusted_host_subscription_crud(self): + """Test complete CRUD workflow for trusted host subscriptions.""" + self.kwargs.update({ + 'location': 'eastus', + 'host_subscription_id': '22222222-2222-2222-2222-222222222222' + }) + + # Add a trusted host subscription + add_result = self.cmd( + 'az computelimit trusted-host-subscription add --location {location} --host-subscription-id {host_subscription_id}', + checks=[ + self.check('name', '{host_subscription_id}') + ] + ).get_output_in_json() + self.assertIsNotNone(add_result) + + # Show the trusted host subscription + show_result = self.cmd( + 'az computelimit trusted-host-subscription show --location {location} --host-subscription-id {host_subscription_id}', + checks=[ + self.check('name', '{host_subscription_id}') + ] + ).get_output_in_json() + self.assertIsNotNone(show_result) + self.assertEqual(show_result['name'], self.kwargs['host_subscription_id']) + + # List trusted host subscriptions and verify the added subscription is present + list_result = self.cmd( + 'az computelimit trusted-host-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['host_subscription_id'], names) + + # Remove the trusted host subscription + self.cmd( + 'az computelimit trusted-host-subscription remove --location {location} --host-subscription-id {host_subscription_id} --yes' + ) + + def test_computelimit_trusted_host_subscription_add_invalid_uuid(self): + """Test that an invalid host subscription ID (not a UUID) is rejected.""" + self.kwargs.update({ + 'location': 'eastus', + 'host_subscription_id': 'not-a-valid-uuid' + }) + with self.assertRaises(InvalidArgumentValueError): + self.cmd( + 'az computelimit trusted-host-subscription add --location {location} ' + '--host-subscription-id {host_subscription_id}' + ) + + def test_computelimit_trusted_host_subscription_add_missing_location(self): + """Test that missing required --location parameter is rejected.""" + with self.assertRaises(InvalidArgumentValueError): + self.cmd( + 'az computelimit trusted-host-subscription add ' + '--host-subscription-id 22222222-2222-2222-2222-222222222222' + ) diff --git a/src/computelimit/setup.py b/src/computelimit/setup.py index 690ad308cbf..65c1bab42ce 100644 --- a/src/computelimit/setup.py +++ b/src/computelimit/setup.py @@ -10,7 +10,7 @@ # HISTORY.rst entry. -VERSION = '1.0.0' +VERSION = '1.1.0' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers