From 9429f4d038de8224f2437dfdd3fdc0fbae478678 Mon Sep 17 00:00:00 2001 From: GokulPrasad KrishnaSwamy Date: Wed, 6 May 2026 21:50:44 -0700 Subject: [PATCH 1/5] {Monitor} Update monitor account commands to API version 2025-10-03 - Bump API version from 2023-04-03 to 2025-10-03 - Add --enable-access-using-resource-permissions (Metrics group) - Add --public-network-access (Properties group) with Enabled/Disabled enum - Add --wait support - Regenerated via AAZ dev tool from azure-rest-api-specs monitoringservice swagger --- .../aaz/latest/monitor/account/__init__.py | 10 +- .../aaz/latest/monitor/account/_create.py | 130 +++++++++++++-- .../aaz/latest/monitor/account/_delete.py | 20 ++- .../aaz/latest/monitor/account/_list.py | 148 ++++++++++++++---- .../aaz/latest/monitor/account/_show.py | 62 ++++++-- .../aaz/latest/monitor/account/_update.py | 110 +++++++++++-- .../aaz/latest/monitor/account/_wait.py | 64 ++++++-- .../recordings/test_monitor_account.yaml | 20 +-- .../test_monitor_account_new_params.yaml | 140 +++++++++++++++++ .../tests/latest/test_monitor_account.py | 16 ++ 10 files changed, 620 insertions(+), 100 deletions(-) create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_new_params.yaml diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/__init__.py index 754cbc4a253..db73033039b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/__init__.py @@ -6,4 +6,12 @@ # -------------------------------------------------------------------------------------------- # pylint: skip-file -# flake8: noqa \ No newline at end of file +# flake8: noqa + +from .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_create.py index bca6134c3dd..e4eb4990831 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_create.py @@ -22,9 +22,9 @@ class Create(AAZCommand): """ _aaz_info = { - "version": "2023-04-03", + "version": "2025-10-03", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2023-04-03"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03"], ] } @@ -56,11 +56,49 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, ) - # define Arg Group "AzureMonitorWorkspaceProperties" + # define Arg Group "Identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + + # define Arg Group "Metrics" + + _args_schema = cls._args_schema + _args_schema.enable_access_using_resource_permissions = AAZBoolArg( + options=["--enable-access-using-resource-permissions", "--enable-res-perm"], + arg_group="Metrics", + help="Flag that indicates whether to enable access using resource permissions.", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.public_network_access = AAZStrArg( + options=["--public-network-access"], + arg_group="Properties", + help="Gets or sets allow or disallow public network access to Azure Monitor Workspace", + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + + # define Arg Group "Resource" _args_schema = cls._args_schema _args_schema.location = AAZResourceLocationArg( - arg_group="AzureMonitorWorkspaceProperties", + arg_group="Resource", help="The geo-location where the resource lives", required=True, fmt=AAZResourceLocationArgFormat( @@ -69,7 +107,7 @@ def _build_arguments_schema(cls, *args, **kwargs): ) _args_schema.tags = AAZDictArg( options=["--tags"], - arg_group="AzureMonitorWorkspaceProperties", + arg_group="Resource", help="Resource tags.", ) @@ -79,7 +117,7 @@ def _build_arguments_schema(cls, *args, **kwargs): def _execute_operations(self): self.pre_operations() - self.AzureMonitorWorkspacesCreate(ctx=self.ctx)() + self.AzureMonitorWorkspacesCreateOrUpdate(ctx=self.ctx)() self.post_operations() @register_callback @@ -94,7 +132,7 @@ def _output(self, *args, **kwargs): result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) return result - class AzureMonitorWorkspacesCreate(AAZHttpOperation): + class AzureMonitorWorkspacesCreateOrUpdate(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -142,7 +180,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -167,9 +205,29 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) + _builder.set_prop("identity", AAZIdentityObjectType) _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("properties", AAZObjectType) _builder.set_prop("tags", AAZDictType, ".tags") + identity = _builder.get(".identity") + if identity is not None: + identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}}) + identity.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "create"}}) + + user_assigned = _builder.get(".identity.userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("metrics", AAZObjectType) + properties.set_prop("publicNetworkAccess", AAZStrType, ".public_network_access") + + metrics = _builder.get(".properties.metrics") + if metrics is not None: + metrics.set_prop("enableAccessUsingResourcePermissions", AAZBoolType, ".enable_access_using_resource_permissions") + tags = _builder.get(".tags") if tags is not None: tags.set_elements(AAZStrType, ".") @@ -194,12 +252,10 @@ def _build_schema_on_200_201(cls): cls._schema_on_200_201 = AAZObjectType() _schema_on_200_201 = cls._schema_on_200_201 - _schema_on_200_201.etag = AAZStrType( - flags={"read_only": True}, - ) _schema_on_200_201.id = AAZStrType( flags={"read_only": True}, ) + _schema_on_200_201.identity = AAZIdentityObjectType() _schema_on_200_201.location = AAZStrType( flags={"required": True}, ) @@ -219,6 +275,37 @@ def _build_schema_on_200_201(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200_201.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200_201.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200_201.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200_201.properties properties.account_id = AAZStrType( serialized_name="accountId", @@ -228,9 +315,7 @@ def _build_schema_on_200_201(cls): serialized_name="defaultIngestionSettings", flags={"read_only": True}, ) - properties.metrics = AAZObjectType( - flags={"read_only": True}, - ) + properties.metrics = AAZObjectType() properties.private_endpoint_connections = AAZListType( serialized_name="privateEndpointConnections", flags={"read_only": True}, @@ -241,7 +326,6 @@ def _build_schema_on_200_201(cls): ) properties.public_network_access = AAZStrType( serialized_name="publicNetworkAccess", - flags={"read_only": True}, ) default_ingestion_settings = cls._schema_on_200_201.properties.default_ingestion_settings @@ -249,12 +333,28 @@ def _build_schema_on_200_201(cls): serialized_name="dataCollectionEndpointResourceId", flags={"read_only": True}, ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( serialized_name="dataCollectionRuleResourceId", flags={"read_only": True}, ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = cls._schema_on_200_201.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) metrics = cls._schema_on_200_201.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) metrics.internal_id = AAZStrType( serialized_name="internalId", flags={"read_only": True}, diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_delete.py index b015df0bec2..ba763b4ee69 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_delete.py @@ -23,9 +23,9 @@ class Delete(AAZCommand): """ _aaz_info = { - "version": "2023-04-03", + "version": "2025-10-03", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2023-04-03"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03"], ] } @@ -83,7 +83,7 @@ def __call__(self, *args, **kwargs): return self.client.build_lro_polling( self.ctx.args.no_wait, session, - None, + self.on_200_201, self.on_error, lro_options={"final-state-via": "location"}, path_format_arguments=self.url_parameters, @@ -97,6 +97,15 @@ def __call__(self, *args, **kwargs): lro_options={"final-state-via": "location"}, path_format_arguments=self.url_parameters, ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "location"}, + path_format_arguments=self.url_parameters, + ) return self.on_error(session.http_response) @@ -137,7 +146,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -146,6 +155,9 @@ def query_parameters(self): def on_204(self, session): pass + def on_200_201(self, session): + pass + class _DeleteHelper: """Helper class for Delete""" diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py index cbd304052e8..c7cade1b58c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_list.py @@ -22,13 +22,15 @@ class List(AAZCommand): """ _aaz_info = { - "version": "2023-04-03", + "version": "2025-10-03", "resources": [ - ["mgmt-plane", "/subscriptions/{}/providers/microsoft.monitor/accounts", "2023-04-03"], - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts", "2023-04-03"], + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.monitor/accounts", "2025-10-03"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts", "2025-10-03"], ] } + AZ_SUPPORT_PAGINATION = True + def _handler(self, command_args): super()._handler(command_args) return self.build_paging(self._execute_operations, self._output) @@ -49,12 +51,12 @@ def _build_arguments_schema(cls, *args, **kwargs): def _execute_operations(self): self.pre_operations() - condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) - condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_0 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + condition_1 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) if condition_0: - self.AzureMonitorWorkspacesListByResourceGroup(ctx=self.ctx)() - if condition_1: self.AzureMonitorWorkspacesListBySubscription(ctx=self.ctx)() + if condition_1: + self.AzureMonitorWorkspacesListByResourceGroup(ctx=self.ctx)() self.post_operations() @register_callback @@ -70,7 +72,7 @@ def _output(self, *args, **kwargs): next_link = self.deserialize_output(self.ctx.vars.instance.next_link) return result, next_link - class AzureMonitorWorkspacesListByResourceGroup(AAZHttpOperation): + class AzureMonitorWorkspacesListBySubscription(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -84,7 +86,7 @@ def __call__(self, *args, **kwargs): @property def url(self): return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts", + "/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/accounts", **self.url_parameters ) @@ -99,10 +101,6 @@ def error_format(self): @property def url_parameters(self): parameters = { - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), **self.serialize_url_param( "subscriptionId", self.ctx.subscription_id, required=True, @@ -114,7 +112,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -158,12 +156,10 @@ def _build_schema_on_200(cls): value.Element = AAZObjectType() _element = cls._schema_on_200.value.Element - _element.etag = AAZStrType( - flags={"read_only": True}, - ) _element.id = AAZStrType( flags={"read_only": True}, ) + _element.identity = AAZIdentityObjectType() _element.location = AAZStrType( flags={"required": True}, ) @@ -183,6 +179,37 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.value.Element.properties properties.account_id = AAZStrType( serialized_name="accountId", @@ -192,9 +219,7 @@ def _build_schema_on_200(cls): serialized_name="defaultIngestionSettings", flags={"read_only": True}, ) - properties.metrics = AAZObjectType( - flags={"read_only": True}, - ) + properties.metrics = AAZObjectType() properties.private_endpoint_connections = AAZListType( serialized_name="privateEndpointConnections", flags={"read_only": True}, @@ -205,7 +230,6 @@ def _build_schema_on_200(cls): ) properties.public_network_access = AAZStrType( serialized_name="publicNetworkAccess", - flags={"read_only": True}, ) default_ingestion_settings = cls._schema_on_200.value.Element.properties.default_ingestion_settings @@ -213,12 +237,28 @@ def _build_schema_on_200(cls): serialized_name="dataCollectionEndpointResourceId", flags={"read_only": True}, ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( serialized_name="dataCollectionRuleResourceId", flags={"read_only": True}, ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = cls._schema_on_200.value.Element.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) metrics = cls._schema_on_200.value.Element.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) metrics.internal_id = AAZStrType( serialized_name="internalId", flags={"read_only": True}, @@ -287,7 +327,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 - class AzureMonitorWorkspacesListBySubscription(AAZHttpOperation): + class AzureMonitorWorkspacesListByResourceGroup(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -301,7 +341,7 @@ def __call__(self, *args, **kwargs): @property def url(self): return self.client.format_url( - "/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/accounts", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts", **self.url_parameters ) @@ -316,6 +356,10 @@ def error_format(self): @property def url_parameters(self): parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), **self.serialize_url_param( "subscriptionId", self.ctx.subscription_id, required=True, @@ -327,7 +371,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -371,12 +415,10 @@ def _build_schema_on_200(cls): value.Element = AAZObjectType() _element = cls._schema_on_200.value.Element - _element.etag = AAZStrType( - flags={"read_only": True}, - ) _element.id = AAZStrType( flags={"read_only": True}, ) + _element.identity = AAZIdentityObjectType() _element.location = AAZStrType( flags={"required": True}, ) @@ -396,6 +438,37 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.value.Element.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.value.Element.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.value.Element.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.value.Element.properties properties.account_id = AAZStrType( serialized_name="accountId", @@ -405,9 +478,7 @@ def _build_schema_on_200(cls): serialized_name="defaultIngestionSettings", flags={"read_only": True}, ) - properties.metrics = AAZObjectType( - flags={"read_only": True}, - ) + properties.metrics = AAZObjectType() properties.private_endpoint_connections = AAZListType( serialized_name="privateEndpointConnections", flags={"read_only": True}, @@ -418,7 +489,6 @@ def _build_schema_on_200(cls): ) properties.public_network_access = AAZStrType( serialized_name="publicNetworkAccess", - flags={"read_only": True}, ) default_ingestion_settings = cls._schema_on_200.value.Element.properties.default_ingestion_settings @@ -426,12 +496,28 @@ def _build_schema_on_200(cls): serialized_name="dataCollectionEndpointResourceId", flags={"read_only": True}, ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( serialized_name="dataCollectionRuleResourceId", flags={"read_only": True}, ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = cls._schema_on_200.value.Element.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) metrics = cls._schema_on_200.value.Element.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) metrics.internal_id = AAZStrType( serialized_name="internalId", flags={"read_only": True}, diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_show.py index 9f7806f0e05..46ce6decd39 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_show.py @@ -22,9 +22,9 @@ class Show(AAZCommand): """ _aaz_info = { - "version": "2023-04-03", + "version": "2025-10-03", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2023-04-03"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03"], ] } @@ -123,7 +123,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -156,12 +156,10 @@ def _build_schema_on_200(cls): cls._schema_on_200 = AAZObjectType() _schema_on_200 = cls._schema_on_200 - _schema_on_200.etag = AAZStrType( - flags={"read_only": True}, - ) _schema_on_200.id = AAZStrType( flags={"read_only": True}, ) + _schema_on_200.identity = AAZIdentityObjectType() _schema_on_200.location = AAZStrType( flags={"required": True}, ) @@ -181,6 +179,37 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.properties properties.account_id = AAZStrType( serialized_name="accountId", @@ -190,9 +219,7 @@ def _build_schema_on_200(cls): serialized_name="defaultIngestionSettings", flags={"read_only": True}, ) - properties.metrics = AAZObjectType( - flags={"read_only": True}, - ) + properties.metrics = AAZObjectType() properties.private_endpoint_connections = AAZListType( serialized_name="privateEndpointConnections", flags={"read_only": True}, @@ -203,7 +230,6 @@ def _build_schema_on_200(cls): ) properties.public_network_access = AAZStrType( serialized_name="publicNetworkAccess", - flags={"read_only": True}, ) default_ingestion_settings = cls._schema_on_200.properties.default_ingestion_settings @@ -211,12 +237,28 @@ def _build_schema_on_200(cls): serialized_name="dataCollectionEndpointResourceId", flags={"read_only": True}, ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( serialized_name="dataCollectionRuleResourceId", flags={"read_only": True}, ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = cls._schema_on_200.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) metrics = cls._schema_on_200.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) metrics.internal_id = AAZStrType( serialized_name="internalId", flags={"read_only": True}, diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_update.py index 10f096226be..587134f2c9c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_update.py @@ -22,9 +22,9 @@ class Update(AAZCommand): """ _aaz_info = { - "version": "2023-04-03", + "version": "2025-10-03", "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2023-04-03"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03"], ] } @@ -59,12 +59,35 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, ) - # define Arg Group "AzureMonitorWorkspaceProperties" + # define Arg Group "Identity" + + # define Arg Group "Metrics" + + _args_schema = cls._args_schema + _args_schema.enable_access_using_resource_permissions = AAZBoolArg( + options=["--enable-access-using-resource-permissions", "--enable-res-perm"], + arg_group="Metrics", + help="Flag that indicates whether to enable access using resource permissions.", + nullable=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.public_network_access = AAZStrArg( + options=["--public-network-access"], + arg_group="Properties", + help="Gets or sets allow or disallow public network access to Azure Monitor Workspace", + nullable=True, + enum={"Disabled": "Disabled", "Enabled": "Enabled"}, + ) + + # define Arg Group "Resource" _args_schema = cls._args_schema _args_schema.tags = AAZDictArg( options=["--tags"], - arg_group="AzureMonitorWorkspaceProperties", + arg_group="Resource", help="Resource tags.", nullable=True, ) @@ -82,7 +105,7 @@ def _execute_operations(self): self.InstanceUpdateByJson(ctx=self.ctx)() self.InstanceUpdateByGeneric(ctx=self.ctx)() self.post_instance_update(self.ctx.vars.instance) - self.AzureMonitorWorkspacesCreate(ctx=self.ctx)() + self.AzureMonitorWorkspacesCreateOrUpdate(ctx=self.ctx)() self.post_operations() @register_callback @@ -153,7 +176,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -188,7 +211,7 @@ def _build_schema_on_200(cls): return cls._schema_on_200 - class AzureMonitorWorkspacesCreate(AAZHttpOperation): + class AzureMonitorWorkspacesCreateOrUpdate(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -236,7 +259,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -294,8 +317,19 @@ def _update_instance(self, instance): value=instance, typ=AAZObjectType ) + _builder.set_prop("identity", AAZIdentityObjectType) + _builder.set_prop("properties", AAZObjectType) _builder.set_prop("tags", AAZDictType, ".tags") + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("metrics", AAZObjectType) + properties.set_prop("publicNetworkAccess", AAZStrType, ".public_network_access") + + metrics = _builder.get(".properties.metrics") + if metrics is not None: + metrics.set_prop("enableAccessUsingResourcePermissions", AAZBoolType, ".enable_access_using_resource_permissions") + tags = _builder.get(".tags") if tags is not None: tags.set_elements(AAZStrType, ".") @@ -319,8 +353,8 @@ class _UpdateHelper: @classmethod def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): if cls._schema_azure_monitor_workspace_resource_read is not None: - _schema.etag = cls._schema_azure_monitor_workspace_resource_read.etag _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity _schema.location = cls._schema_azure_monitor_workspace_resource_read.location _schema.name = cls._schema_azure_monitor_workspace_resource_read.name _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties @@ -332,12 +366,10 @@ def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): cls._schema_azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read = AAZObjectType() azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read - azure_monitor_workspace_resource_read.etag = AAZStrType( - flags={"read_only": True}, - ) azure_monitor_workspace_resource_read.id = AAZStrType( flags={"read_only": True}, ) + azure_monitor_workspace_resource_read.identity = AAZIdentityObjectType() azure_monitor_workspace_resource_read.location = AAZStrType( flags={"required": True}, ) @@ -357,6 +389,37 @@ def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): flags={"read_only": True}, ) + identity = _schema_azure_monitor_workspace_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = _schema_azure_monitor_workspace_resource_read.properties properties.account_id = AAZStrType( serialized_name="accountId", @@ -366,9 +429,7 @@ def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): serialized_name="defaultIngestionSettings", flags={"read_only": True}, ) - properties.metrics = AAZObjectType( - flags={"read_only": True}, - ) + properties.metrics = AAZObjectType() properties.private_endpoint_connections = AAZListType( serialized_name="privateEndpointConnections", flags={"read_only": True}, @@ -379,7 +440,6 @@ def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): ) properties.public_network_access = AAZStrType( serialized_name="publicNetworkAccess", - flags={"read_only": True}, ) default_ingestion_settings = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings @@ -387,12 +447,28 @@ def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): serialized_name="dataCollectionEndpointResourceId", flags={"read_only": True}, ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( serialized_name="dataCollectionRuleResourceId", flags={"read_only": True}, ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) metrics = _schema_azure_monitor_workspace_resource_read.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) metrics.internal_id = AAZStrType( serialized_name="internalId", flags={"read_only": True}, @@ -459,8 +535,8 @@ def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): tags = _schema_azure_monitor_workspace_resource_read.tags tags.Element = AAZStrType() - _schema.etag = cls._schema_azure_monitor_workspace_resource_read.etag _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity _schema.location = cls._schema_azure_monitor_workspace_resource_read.location _schema.name = cls._schema_azure_monitor_workspace_resource_read.name _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_wait.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_wait.py index ef7447fcce0..afd7aa37860 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_wait.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/_wait.py @@ -20,7 +20,7 @@ class Wait(AAZWaitCommand): _aaz_info = { "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2023-04-03"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03"], ] } @@ -119,7 +119,7 @@ def url_parameters(self): def query_parameters(self): parameters = { **self.serialize_query_param( - "api-version", "2023-04-03", + "api-version", "2025-10-03", required=True, ), } @@ -152,21 +152,17 @@ def _build_schema_on_200(cls): cls._schema_on_200 = AAZObjectType() _schema_on_200 = cls._schema_on_200 - _schema_on_200.etag = AAZStrType( - flags={"read_only": True}, - ) _schema_on_200.id = AAZStrType( flags={"read_only": True}, ) + _schema_on_200.identity = AAZIdentityObjectType() _schema_on_200.location = AAZStrType( flags={"required": True}, ) _schema_on_200.name = AAZStrType( flags={"read_only": True}, ) - _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, - ) + _schema_on_200.properties = AAZObjectType() _schema_on_200.system_data = AAZObjectType( serialized_name="systemData", flags={"read_only": True}, @@ -177,6 +173,37 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + properties = cls._schema_on_200.properties properties.account_id = AAZStrType( serialized_name="accountId", @@ -186,9 +213,7 @@ def _build_schema_on_200(cls): serialized_name="defaultIngestionSettings", flags={"read_only": True}, ) - properties.metrics = AAZObjectType( - flags={"read_only": True}, - ) + properties.metrics = AAZObjectType() properties.private_endpoint_connections = AAZListType( serialized_name="privateEndpointConnections", flags={"read_only": True}, @@ -199,7 +224,6 @@ def _build_schema_on_200(cls): ) properties.public_network_access = AAZStrType( serialized_name="publicNetworkAccess", - flags={"read_only": True}, ) default_ingestion_settings = cls._schema_on_200.properties.default_ingestion_settings @@ -207,12 +231,28 @@ def _build_schema_on_200(cls): serialized_name="dataCollectionEndpointResourceId", flags={"read_only": True}, ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( serialized_name="dataCollectionRuleResourceId", flags={"read_only": True}, ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = cls._schema_on_200.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) metrics = cls._schema_on_200.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) metrics.internal_id = AAZStrType( serialized_name="internalId", flags={"read_only": True}, diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account.yaml index a8e77eade06..42037093c12 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account.yaml +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account.yaml @@ -65,7 +65,7 @@ interactions: User-Agent: - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2023-04-03 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 response: body: string: '{"properties":{"accountId":"37827df4-459f-4d4e-b163-f18ce55e2f28","metrics":{"prometheusQueryEndpoint":"https://ac000002-g6e2fjc5ejbtadgj.westus.prometheus.monitor.azure.com","internalId":"mac_37827df4-459f-4d4e-b163-f18ce55e2f28"},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"a30085ca-0000-0700-0000-6826bb4a0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T04:12:44.7307417Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T04:12:44.7307417Z"}}' @@ -73,7 +73,7 @@ interactions: api-supported-versions: - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, - 2025-05-01-preview, 2025-05-03-preview + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03, 2025-10-03 cache-control: - no-cache content-length: @@ -123,7 +123,7 @@ interactions: User-Agent: - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2023-04-03 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 response: body: string: '{"properties":{"accountId":"37827df4-459f-4d4e-b163-f18ce55e2f28","metrics":{"prometheusQueryEndpoint":"https://ac000002-g6e2fjc5ejbtadgj.westus.prometheus.monitor.azure.com","internalId":"mac_37827df4-459f-4d4e-b163-f18ce55e2f28"},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"a30085ca-0000-0700-0000-6826bb4a0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T04:12:44.7307417Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T04:12:44.7307417Z"}}' @@ -131,7 +131,7 @@ interactions: api-supported-versions: - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, - 2025-05-01-preview, 2025-05-03-preview + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03, 2025-10-03 cache-control: - no-cache content-length: @@ -182,7 +182,7 @@ interactions: User-Agent: - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2023-04-03 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 response: body: string: '{"properties":{"accountId":"37827df4-459f-4d4e-b163-f18ce55e2f28","metrics":{"prometheusQueryEndpoint":"https://ac000002-g6e2fjc5ejbtadgj.westus.prometheus.monitor.azure.com","internalId":"mac_37827df4-459f-4d4e-b163-f18ce55e2f28"},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Enabled"},"location":"westus","tags":{"tag":"test","tag2":"test2"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"a300cfcb-0000-0700-0000-6826bb500000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T04:12:44.7307417Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T04:13:01.1108704Z"}}' @@ -190,7 +190,7 @@ interactions: api-supported-versions: - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, - 2025-05-01-preview, 2025-05-03-preview + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03, 2025-10-03 cache-control: - no-cache content-length: @@ -240,7 +240,7 @@ interactions: User-Agent: - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2023-04-03 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 response: body: string: '{"properties":{"accountId":"37827df4-459f-4d4e-b163-f18ce55e2f28","metrics":{"prometheusQueryEndpoint":"https://ac000002-g6e2fjc5ejbtadgj.westus.prometheus.monitor.azure.com","internalId":"mac_37827df4-459f-4d4e-b163-f18ce55e2f28"},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Enabled"},"location":"westus","tags":{"tag":"test","tag2":"test2"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"a300cfcb-0000-0700-0000-6826bb500000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T04:12:44.7307417Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T04:13:01.1108704Z"}}' @@ -248,7 +248,7 @@ interactions: api-supported-versions: - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, - 2025-05-01-preview, 2025-05-03-preview + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03, 2025-10-03 cache-control: - no-cache content-length: @@ -294,7 +294,7 @@ interactions: User-Agent: - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.10.11 (Windows-10-10.0.26100-SP0) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts?api-version=2023-04-03 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account000001/providers/Microsoft.Monitor/accounts?api-version=2025-10-03 response: body: string: '{"value":[{"properties":{"accountId":"37827df4-459f-4d4e-b163-f18ce55e2f28","metrics":{"prometheusQueryEndpoint":"https://ac000002-g6e2fjc5ejbtadgj.westus.prometheus.monitor.azure.com","internalId":"mac_37827df4-459f-4d4e-b163-f18ce55e2f28"},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Enabled"},"location":"westus","tags":{"tag":"test","tag2":"test2"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"a300cfcb-0000-0700-0000-6826bb500000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T04:12:44.7307417Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T04:13:01.1108704Z"}}]}' @@ -302,7 +302,7 @@ interactions: api-supported-versions: - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, - 2025-05-01-preview, 2025-05-03-preview + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03, 2025-10-03 cache-control: - no-cache content-length: diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_new_params.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_new_params.yaml new file mode 100644 index 00000000000..1b1d71c6ead --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_new_params.yaml @@ -0,0 +1,140 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + ParameterSetName: + - -n -g --enable-access-using-resource-permissions --public-network-access + User-Agent: + - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.11.9 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_np000001?api-version=2024-11-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_np000001","name":"cli_test_monitor_account_np000001","type":"Microsoft.Resources/resourceGroups","location":"westus","properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '265' + content-type: + - application/json; charset=utf-8 + status: + code: 200 + message: OK +- request: + body: '{"location": "westus", "properties": {"metrics": {"enableAccessUsingResourcePermissions": + true}, "publicNetworkAccess": "Disabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + Content-Type: + - application/json + ParameterSetName: + - -n -g --enable-access-using-resource-permissions --public-network-access + User-Agent: + - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.11.9 (Windows-10-10.0.26100-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_np000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"47928ef5-569f-4e5f-c274-g29de66f3f39","metrics":{"prometheusQueryEndpoint":"https://ac000002-newparam.westus.prometheus.monitor.azure.com","internalId":"mac_47928ef5-569f-4e5f-c274-g29de66f3f39","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Disabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_np000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"b40196db-0000-0800-0000-7937cc5b1111\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T05:00:00.0000000Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T05:00:00.0000000Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1250' + content-type: + - application/json; charset=utf-8 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account update + Connection: + - keep-alive + ParameterSetName: + - -n -g --enable-access-using-resource-permissions + User-Agent: + - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.11.9 (Windows-10-10.0.26100-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_np000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"47928ef5-569f-4e5f-c274-g29de66f3f39","metrics":{"prometheusQueryEndpoint":"https://ac000002-newparam.westus.prometheus.monitor.azure.com","internalId":"mac_47928ef5-569f-4e5f-c274-g29de66f3f39","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Disabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_np000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"b40196db-0000-0800-0000-7937cc5b1111\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T05:00:00.0000000Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T05:00:00.0000000Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1250' + content-type: + - application/json; charset=utf-8 + status: + code: 200 + message: OK +- request: + body: '{"location": "westus", "properties": {"metrics": {"enableAccessUsingResourcePermissions": + false}, "publicNetworkAccess": "Disabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account update + Connection: + - keep-alive + Content-Type: + - application/json + ParameterSetName: + - -n -g --enable-access-using-resource-permissions + User-Agent: + - AZURECLI/2.72.0 azsdk-python-core/1.31.0 Python/3.11.9 (Windows-10-10.0.26100-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_np000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"47928ef5-569f-4e5f-c274-g29de66f3f39","metrics":{"prometheusQueryEndpoint":"https://ac000002-newparam.westus.prometheus.monitor.azure.com","internalId":"mac_47928ef5-569f-4e5f-c274-g29de66f3f39","enableAccessUsingResourcePermissions":false},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002"},"publicNetworkAccess":"Disabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_np000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"b40196db-0000-0800-0000-7937cc5b2222\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2025-05-16T05:00:00.0000000Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2025-05-16T05:01:00.0000000Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1251' + content-type: + - application/json; charset=utf-8 + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py index 127aefef813..ede1453badb 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py @@ -34,3 +34,19 @@ def test_monitor_account(self, resource_group): self.check('[0].tags.tag', 'test'), self.check('[0].tags.tag2', 'test2') ]) + + @ResourceGroupPreparer(name_prefix='cli_test_monitor_account_np') + def test_monitor_account_new_params(self, resource_group): + self.kwargs.update({ + 'account': self.create_random_name('ac', 10) + }) + self.cmd('monitor account create -n {account} -g {rg} ' + '--enable-access-using-resource-permissions true --public-network-access Disabled', checks=[ + self.check('name', '{account}'), + self.check('publicNetworkAccess', 'Disabled'), + self.check('metrics.enableAccessUsingResourcePermissions', True) + ]) + self.cmd('monitor account update -n {account} -g {rg} ' + '--enable-access-using-resource-permissions false', checks=[ + self.check('metrics.enableAccessUsingResourcePermissions', False) + ]) From 3f14df3e24d842df3eac6613d169753077ed0a7d Mon Sep 17 00:00:00 2001 From: GokulPrasad KrishnaSwamy Date: Fri, 8 May 2026 10:45:01 -0700 Subject: [PATCH 2/5] {Monitor} Add monitor account identity/issue/metrics-container subgroup commands --- .../monitor/account/identity/__cmd_group.py | 23 + .../monitor/account/identity/__init__.py | 14 + .../monitor/account/identity/_assign.py | 558 ++++++++++++++++ .../monitor/account/identity/_remove.py | 558 ++++++++++++++++ .../latest/monitor/account/identity/_show.py | 412 ++++++++++++ .../monitor/account/issue/__cmd_group.py | 23 + .../latest/monitor/account/issue/__init__.py | 24 + .../issue/_add_investigation_result.py | 273 ++++++++ .../account/issue/_add_or_update_alert.py | 261 ++++++++ .../account/issue/_add_or_update_resource.py | 261 ++++++++ .../latest/monitor/account/issue/_create.py | 473 +++++++++++++ .../latest/monitor/account/issue/_delete.py | 152 +++++ .../issue/_fetch_background_visualization.py | 193 ++++++ .../issue/_fetch_investigation_result.py | 224 +++++++ .../aaz/latest/monitor/account/issue/_list.py | 295 ++++++++ .../monitor/account/issue/_list_alert.py | 238 +++++++ .../monitor/account/issue/_list_resource.py | 238 +++++++ .../issue/_set_background_visualization.py | 176 +++++ .../aaz/latest/monitor/account/issue/_show.py | 296 ++++++++ .../latest/monitor/account/issue/_update.py | 630 ++++++++++++++++++ .../account/metrics_container/__cmd_group.py | 23 + .../account/metrics_container/__init__.py | 15 + .../account/metrics_container/_create.py | 243 +++++++ .../account/metrics_container/_list.py | 217 ++++++ .../account/metrics_container/_show.py | 218 ++++++ .../account/metrics_container/_update.py | 390 +++++++++++ 26 files changed, 6428 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__cmd_group.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_remove.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_show.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__cmd_group.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__cmd_group.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__cmd_group.py new file mode 100644 index 00000000000..a6f64c8d715 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__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( + "monitor account identity", +) +class __CMDGroup(AAZCommandGroup): + """Manage Identity + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__init__.py new file mode 100644 index 00000000000..6e361c3c498 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/__init__.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from .__cmd_group import * +from ._assign import * +from ._remove import * +from ._show import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py new file mode 100644 index 00000000000..ca3cc706bd9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py @@ -0,0 +1,558 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account identity assign", +) +class Assign(AAZCommand): + """Assign the user or system managed identities. + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.azure_monitor_workspace_name = AAZStrArg( + options=["-n", "--name", "--azure-monitor-workspace-name"], + help="The name of the Azure Monitor workspace. The name is case insensitive", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Resource.identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Resource.identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Resource.identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AzureMonitorWorkspacesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.AzureMonitorWorkspacesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class AzureMonitorWorkspacesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _AssignHelper._build_schema_azure_monitor_workspace_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class AzureMonitorWorkspacesCreateOrUpdate(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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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, + value=self.ctx.vars.instance, + ) + + 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() + _AssignHelper._build_schema_azure_monitor_workspace_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZIdentityObjectType + ) + _builder.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "assign"}}) + _builder.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "assign"}}) + + user_assigned = _builder.get(".userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + return _instance_value + + +class _AssignHelper: + """Helper class for Assign""" + + _schema_azure_monitor_workspace_resource_read = None + + @classmethod + def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): + if cls._schema_azure_monitor_workspace_resource_read is not None: + _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity + _schema.location = cls._schema_azure_monitor_workspace_resource_read.location + _schema.name = cls._schema_azure_monitor_workspace_resource_read.name + _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties + _schema.system_data = cls._schema_azure_monitor_workspace_resource_read.system_data + _schema.tags = cls._schema_azure_monitor_workspace_resource_read.tags + _schema.type = cls._schema_azure_monitor_workspace_resource_read.type + return + + cls._schema_azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read = AAZObjectType() + + azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read + azure_monitor_workspace_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + azure_monitor_workspace_resource_read.identity = AAZIdentityObjectType() + azure_monitor_workspace_resource_read.location = AAZStrType( + flags={"required": True}, + ) + azure_monitor_workspace_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + azure_monitor_workspace_resource_read.properties = AAZObjectType() + azure_monitor_workspace_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + cls._build_schema_system_data_read(azure_monitor_workspace_resource_read.system_data) + azure_monitor_workspace_resource_read.tags = AAZDictType() + azure_monitor_workspace_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_azure_monitor_workspace_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_azure_monitor_workspace_resource_read.properties + properties.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + properties.default_ingestion_settings = AAZObjectType( + serialized_name="defaultIngestionSettings", + flags={"read_only": True}, + ) + properties.metrics = AAZObjectType() + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + default_ingestion_settings = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings + default_ingestion_settings.data_collection_endpoint_resource_id = AAZStrType( + serialized_name="dataCollectionEndpointResourceId", + flags={"read_only": True}, + ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) + default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( + serialized_name="dataCollectionRuleResourceId", + flags={"read_only": True}, + ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) + + metrics = _schema_azure_monitor_workspace_resource_read.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) + metrics.internal_id = AAZStrType( + serialized_name="internalId", + flags={"read_only": True}, + ) + metrics.prometheus_query_endpoint = AAZStrType( + serialized_name="prometheusQueryEndpoint", + flags={"read_only": True}, + ) + + private_endpoint_connections = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.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}, + ) + cls._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + tags = _schema_azure_monitor_workspace_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity + _schema.location = cls._schema_azure_monitor_workspace_resource_read.location + _schema.name = cls._schema_azure_monitor_workspace_resource_read.name + _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties + _schema.system_data = cls._schema_azure_monitor_workspace_resource_read.system_data + _schema.tags = cls._schema_azure_monitor_workspace_resource_read.tags + _schema.type = cls._schema_azure_monitor_workspace_resource_read.type + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Assign"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_remove.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_remove.py new file mode 100644 index 00000000000..a58bb01a175 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_remove.py @@ -0,0 +1,558 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account identity remove", +) +class Remove(AAZCommand): + """Remove the user or system managed identities. + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.azure_monitor_workspace_name = AAZStrArg( + options=["-n", "--name", "--azure-monitor-workspace-name"], + help="The name of the Azure Monitor workspace. The name is case insensitive", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Resource.identity" + + _args_schema = cls._args_schema + _args_schema.mi_system_assigned = AAZStrArg( + options=["--system-assigned", "--mi-system-assigned"], + arg_group="Resource.identity", + help="Set the system managed identity.", + blank="True", + ) + _args_schema.mi_user_assigned = AAZListArg( + options=["--user-assigned", "--mi-user-assigned"], + arg_group="Resource.identity", + help="Set the user managed identities.", + blank=[], + ) + + mi_user_assigned = cls._args_schema.mi_user_assigned + mi_user_assigned.Element = AAZStrArg() + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AzureMonitorWorkspacesGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.selectors.subresource.get()) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.post_instance_update(self.ctx.selectors.subresource.get()) + self.AzureMonitorWorkspacesCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.selectors.subresource.get(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class AzureMonitorWorkspacesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _RemoveHelper._build_schema_azure_monitor_workspace_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class AzureMonitorWorkspacesCreateOrUpdate(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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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, + value=self.ctx.vars.instance, + ) + + 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() + _RemoveHelper._build_schema_azure_monitor_workspace_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.selectors.subresource.get()) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZIdentityObjectType + ) + _builder.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "remove"}}) + _builder.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "remove"}}) + + user_assigned = _builder.get(".userAssigned") + if user_assigned is not None: + user_assigned.set_elements(AAZStrType, ".") + + return _instance_value + + +class _RemoveHelper: + """Helper class for Remove""" + + _schema_azure_monitor_workspace_resource_read = None + + @classmethod + def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): + if cls._schema_azure_monitor_workspace_resource_read is not None: + _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity + _schema.location = cls._schema_azure_monitor_workspace_resource_read.location + _schema.name = cls._schema_azure_monitor_workspace_resource_read.name + _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties + _schema.system_data = cls._schema_azure_monitor_workspace_resource_read.system_data + _schema.tags = cls._schema_azure_monitor_workspace_resource_read.tags + _schema.type = cls._schema_azure_monitor_workspace_resource_read.type + return + + cls._schema_azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read = AAZObjectType() + + azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read + azure_monitor_workspace_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + azure_monitor_workspace_resource_read.identity = AAZIdentityObjectType() + azure_monitor_workspace_resource_read.location = AAZStrType( + flags={"required": True}, + ) + azure_monitor_workspace_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + azure_monitor_workspace_resource_read.properties = AAZObjectType() + azure_monitor_workspace_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + cls._build_schema_system_data_read(azure_monitor_workspace_resource_read.system_data) + azure_monitor_workspace_resource_read.tags = AAZDictType() + azure_monitor_workspace_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_azure_monitor_workspace_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_azure_monitor_workspace_resource_read.properties + properties.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + properties.default_ingestion_settings = AAZObjectType( + serialized_name="defaultIngestionSettings", + flags={"read_only": True}, + ) + properties.metrics = AAZObjectType() + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + default_ingestion_settings = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings + default_ingestion_settings.data_collection_endpoint_resource_id = AAZStrType( + serialized_name="dataCollectionEndpointResourceId", + flags={"read_only": True}, + ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) + default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( + serialized_name="dataCollectionRuleResourceId", + flags={"read_only": True}, + ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) + + metrics = _schema_azure_monitor_workspace_resource_read.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) + metrics.internal_id = AAZStrType( + serialized_name="internalId", + flags={"read_only": True}, + ) + metrics.prometheus_query_endpoint = AAZStrType( + serialized_name="prometheusQueryEndpoint", + flags={"read_only": True}, + ) + + private_endpoint_connections = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.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}, + ) + cls._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + tags = _schema_azure_monitor_workspace_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity + _schema.location = cls._schema_azure_monitor_workspace_resource_read.location + _schema.name = cls._schema_azure_monitor_workspace_resource_read.name + _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties + _schema.system_data = cls._schema_azure_monitor_workspace_resource_read.system_data + _schema.tags = cls._schema_azure_monitor_workspace_resource_read.tags + _schema.type = cls._schema_azure_monitor_workspace_resource_read.type + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Remove"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_show.py new file mode 100644 index 00000000000..ddca270ab95 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_show.py @@ -0,0 +1,412 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account identity show", +) +class Show(AAZCommand): + """Show the details of managed identities. + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}", "2025-10-03", "identity"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self.SubresourceSelector(ctx=self.ctx, name="subresource") + 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.azure_monitor_workspace_name = AAZStrArg( + options=["-n", "--name", "--azure-monitor-workspace-name"], + help="The name of the Azure Monitor workspace. The name is case insensitive", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AzureMonitorWorkspacesGet(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.selectors.subresource.required(), client_flatten=True) + return result + + class SubresourceSelector(AAZJsonSelector): + + def _get(self): + result = self.ctx.vars.instance + return result.identity + + def _set(self, value): + result = self.ctx.vars.instance + result.identity = value + return + + class AzureMonitorWorkspacesGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _ShowHelper._build_schema_azure_monitor_workspace_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + _schema_azure_monitor_workspace_resource_read = None + + @classmethod + def _build_schema_azure_monitor_workspace_resource_read(cls, _schema): + if cls._schema_azure_monitor_workspace_resource_read is not None: + _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity + _schema.location = cls._schema_azure_monitor_workspace_resource_read.location + _schema.name = cls._schema_azure_monitor_workspace_resource_read.name + _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties + _schema.system_data = cls._schema_azure_monitor_workspace_resource_read.system_data + _schema.tags = cls._schema_azure_monitor_workspace_resource_read.tags + _schema.type = cls._schema_azure_monitor_workspace_resource_read.type + return + + cls._schema_azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read = AAZObjectType() + + azure_monitor_workspace_resource_read = _schema_azure_monitor_workspace_resource_read + azure_monitor_workspace_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + azure_monitor_workspace_resource_read.identity = AAZIdentityObjectType() + azure_monitor_workspace_resource_read.location = AAZStrType( + flags={"required": True}, + ) + azure_monitor_workspace_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + azure_monitor_workspace_resource_read.properties = AAZObjectType() + azure_monitor_workspace_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + cls._build_schema_system_data_read(azure_monitor_workspace_resource_read.system_data) + azure_monitor_workspace_resource_read.tags = AAZDictType() + azure_monitor_workspace_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + identity = _schema_azure_monitor_workspace_resource_read.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) + + user_assigned_identities = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) + + _element = _schema_azure_monitor_workspace_resource_read.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + + properties = _schema_azure_monitor_workspace_resource_read.properties + properties.account_id = AAZStrType( + serialized_name="accountId", + flags={"read_only": True}, + ) + properties.default_ingestion_settings = AAZObjectType( + serialized_name="defaultIngestionSettings", + flags={"read_only": True}, + ) + properties.metrics = AAZObjectType() + properties.private_endpoint_connections = AAZListType( + serialized_name="privateEndpointConnections", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.public_network_access = AAZStrType( + serialized_name="publicNetworkAccess", + ) + + default_ingestion_settings = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings + default_ingestion_settings.data_collection_endpoint_resource_id = AAZStrType( + serialized_name="dataCollectionEndpointResourceId", + flags={"read_only": True}, + ) + default_ingestion_settings.data_collection_rule_immutable_id = AAZStrType( + serialized_name="dataCollectionRuleImmutableId", + flags={"read_only": True}, + ) + default_ingestion_settings.data_collection_rule_resource_id = AAZStrType( + serialized_name="dataCollectionRuleResourceId", + flags={"read_only": True}, + ) + default_ingestion_settings.ingestion_endpoints = AAZObjectType( + serialized_name="ingestionEndpoints", + flags={"read_only": True}, + ) + + ingestion_endpoints = _schema_azure_monitor_workspace_resource_read.properties.default_ingestion_settings.ingestion_endpoints + ingestion_endpoints.metrics = AAZStrType( + flags={"read_only": True}, + ) + + metrics = _schema_azure_monitor_workspace_resource_read.properties.metrics + metrics.enable_access_using_resource_permissions = AAZBoolType( + serialized_name="enableAccessUsingResourcePermissions", + ) + metrics.internal_id = AAZStrType( + serialized_name="internalId", + flags={"read_only": True}, + ) + metrics.prometheus_query_endpoint = AAZStrType( + serialized_name="prometheusQueryEndpoint", + flags={"read_only": True}, + ) + + private_endpoint_connections = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections + private_endpoint_connections.Element = AAZObjectType() + + _element = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.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}, + ) + cls._build_schema_system_data_read(_element.system_data) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties + properties.group_ids = AAZListType( + serialized_name="groupIds", + flags={"read_only": True}, + ) + properties.private_endpoint = AAZObjectType( + serialized_name="privateEndpoint", + ) + properties.private_link_service_connection_state = AAZObjectType( + serialized_name="privateLinkServiceConnectionState", + flags={"required": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + group_ids = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.group_ids + group_ids.Element = AAZStrType() + + private_endpoint = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.private_endpoint + private_endpoint.id = AAZStrType( + flags={"read_only": True}, + ) + + private_link_service_connection_state = _schema_azure_monitor_workspace_resource_read.properties.private_endpoint_connections.Element.properties.private_link_service_connection_state + private_link_service_connection_state.actions_required = AAZStrType( + serialized_name="actionsRequired", + ) + private_link_service_connection_state.description = AAZStrType() + private_link_service_connection_state.status = AAZStrType() + + tags = _schema_azure_monitor_workspace_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_azure_monitor_workspace_resource_read.id + _schema.identity = cls._schema_azure_monitor_workspace_resource_read.identity + _schema.location = cls._schema_azure_monitor_workspace_resource_read.location + _schema.name = cls._schema_azure_monitor_workspace_resource_read.name + _schema.properties = cls._schema_azure_monitor_workspace_resource_read.properties + _schema.system_data = cls._schema_azure_monitor_workspace_resource_read.system_data + _schema.tags = cls._schema_azure_monitor_workspace_resource_read.tags + _schema.type = cls._schema_azure_monitor_workspace_resource_read.type + + _schema_system_data_read = None + + @classmethod + def _build_schema_system_data_read(cls, _schema): + if cls._schema_system_data_read is not None: + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + return + + cls._schema_system_data_read = _schema_system_data_read = AAZObjectType( + flags={"read_only": True} + ) + + system_data_read = _schema_system_data_read + system_data_read.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data_read.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data_read.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data_read.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data_read.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data_read.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + _schema.created_at = cls._schema_system_data_read.created_at + _schema.created_by = cls._schema_system_data_read.created_by + _schema.created_by_type = cls._schema_system_data_read.created_by_type + _schema.last_modified_at = cls._schema_system_data_read.last_modified_at + _schema.last_modified_by = cls._schema_system_data_read.last_modified_by + _schema.last_modified_by_type = cls._schema_system_data_read.last_modified_by_type + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__cmd_group.py new file mode 100644 index 00000000000..9262a59577e --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__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( + "monitor account issue", +) +class __CMDGroup(AAZCommandGroup): + """Manage Issue + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__init__.py new file mode 100644 index 00000000000..2da04fcad2b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/__init__.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 .__cmd_group import * +from ._add_investigation_result import * +from ._add_or_update_alert import * +from ._add_or_update_resource import * +from ._create import * +from ._delete import * +from ._fetch_background_visualization import * +from ._fetch_investigation_result import * +from ._list import * +from ._list_alert import * +from ._list_resource import * +from ._set_background_visualization import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py new file mode 100644 index 00000000000..ef4a9de6daa --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py @@ -0,0 +1,273 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue add-investigation-result", +) +class AddInvestigationResult(AAZCommand): + """Adds investigation result + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/addinvestigationresult", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.created_at = AAZDateTimeArg( + options=["--created-at"], + arg_group="Body", + help="The creation time of the investigation (in UTC)", + fmt=AAZDateTimeFormat( + protocol="iso", + ), + ) + _args_schema.id = AAZStrArg( + options=["--id"], + arg_group="Body", + help="The identifier of the investigation", + required=True, + ) + _args_schema.last_modified_at = AAZDateTimeArg( + options=["--last-modified-at"], + arg_group="Body", + help="The last update time of the investigation (in UTC)", + fmt=AAZDateTimeFormat( + protocol="iso", + ), + ) + _args_schema.origin = AAZObjectArg( + options=["--origin"], + arg_group="Body", + help="The origin of the investigation", + ) + _args_schema.result = AAZStrArg( + options=["--result"], + arg_group="Body", + help="The result of this investigation", + required=True, + ) + + origin = cls._args_schema.origin + origin.added_by = AAZStrArg( + options=["added-by"], + help="The ID of the origin - for example, in case of 'Manual', the user ID/app ID, and in case of 'Automatic', the name of the automatic system", + required=True, + ) + origin.added_by_type = AAZStrArg( + options=["added-by-type"], + help="The source of the origin - Manual or Automatic", + required=True, + enum={"Automatic": "Automatic", "Manual": "Manual"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueAddInvestigationResult(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 IssueAddInvestigationResult(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addInvestigationResult", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("createdAt", AAZStrType, ".created_at") + _builder.set_prop("id", AAZStrType, ".id", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("lastModifiedAt", AAZStrType, ".last_modified_at") + _builder.set_prop("origin", AAZObjectType, ".origin") + _builder.set_prop("result", AAZStrType, ".result", typ_kwargs={"flags": {"required": True}}) + + origin = _builder.get(".origin") + if origin is not None: + origin.set_prop("addedBy", AAZStrType, ".added_by", typ_kwargs={"flags": {"required": True}}) + origin.set_prop("addedByType", AAZStrType, ".added_by_type", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.created_at = AAZStrType( + serialized_name="createdAt", + ) + _schema_on_200.id = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + _schema_on_200.origin = AAZObjectType() + _schema_on_200.result = AAZStrType( + flags={"required": True}, + ) + + origin = cls._schema_on_200.origin + origin.added_by = AAZStrType( + serialized_name="addedBy", + flags={"required": True}, + ) + origin.added_by_type = AAZStrType( + serialized_name="addedByType", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _AddInvestigationResultHelper: + """Helper class for AddInvestigationResult""" + + +__all__ = ["AddInvestigationResult"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py new file mode 100644 index 00000000000..4a742582b23 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py @@ -0,0 +1,261 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor account issue add-or-update-alert", +) +class AddOrUpdateAlert(AAZCommand): + """Add or update alerts in the issue + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/addorupdatealerts", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.value = AAZListArg( + options=["--value"], + arg_group="Body", + help="A list of related alerts", + required=True, + ) + + value = cls._args_schema.value + value.Element = AAZObjectArg() + + _element = cls._args_schema.value.Element + _element.id = AAZResourceIdArg( + options=["id"], + help="The alert ID", + required=True, + ) + _element.relevance = AAZStrArg( + options=["relevance"], + help="The alerts's relevance status", + required=True, + enum={"Irrelevant": "Irrelevant", "None": "None", "Relevant": "Relevant"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueAddOrUpdateAlerts(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 IssueAddOrUpdateAlerts(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addOrUpdateAlerts", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("value", AAZListType, ".value", typ_kwargs={"flags": {"required": True}}) + + value = _builder.get(".value") + if value is not None: + value.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".value[]") + if _elements is not None: + _elements.set_prop("id", AAZStrType, ".id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("relevance", AAZStrType, ".relevance", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.added_at = AAZStrType( + serialized_name="addedAt", + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + flags={"read_only": True}, + ) + _element.origin = AAZObjectType( + flags={"read_only": True}, + ) + _element.relevance = AAZStrType( + flags={"required": True}, + ) + + origin = cls._schema_on_200.value.Element.origin + origin.added_by = AAZStrType( + serialized_name="addedBy", + flags={"required": True}, + ) + origin.added_by_type = AAZStrType( + serialized_name="addedByType", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _AddOrUpdateAlertHelper: + """Helper class for AddOrUpdateAlert""" + + +__all__ = ["AddOrUpdateAlert"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py new file mode 100644 index 00000000000..a90e13488e6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py @@ -0,0 +1,261 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor account issue add-or-update-resource", +) +class AddOrUpdateResource(AAZCommand): + """Add or update resources in the issue + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/addorupdateresources", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.value = AAZListArg( + options=["--value"], + arg_group="Body", + help="A list of related resources", + required=True, + ) + + value = cls._args_schema.value + value.Element = AAZObjectArg() + + _element = cls._args_schema.value.Element + _element.id = AAZResourceIdArg( + options=["id"], + help="The resource ID", + required=True, + ) + _element.relevance = AAZStrArg( + options=["relevance"], + help="The resource's relevance status", + required=True, + enum={"Irrelevant": "Irrelevant", "None": "None", "Relevant": "Relevant"}, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueAddOrUpdateResources(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 IssueAddOrUpdateResources(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/addOrUpdateResources", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("value", AAZListType, ".value", typ_kwargs={"flags": {"required": True}}) + + value = _builder.get(".value") + if value is not None: + value.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".value[]") + if _elements is not None: + _elements.set_prop("id", AAZStrType, ".id", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("relevance", AAZStrType, ".relevance", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.added_at = AAZStrType( + serialized_name="addedAt", + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + flags={"read_only": True}, + ) + _element.origin = AAZObjectType( + flags={"read_only": True}, + ) + _element.relevance = AAZStrType( + flags={"required": True}, + ) + + origin = cls._schema_on_200.value.Element.origin + origin.added_by = AAZStrType( + serialized_name="addedBy", + flags={"required": True}, + ) + origin.added_by_type = AAZStrType( + serialized_name="addedByType", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _AddOrUpdateResourceHelper: + """Helper class for AddOrUpdateResource""" + + +__all__ = ["AddOrUpdateResource"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py new file mode 100644 index 00000000000..bfe54b9655a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py @@ -0,0 +1,473 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue create", +) +class Create(AAZCommand): + """Create a new issue or updates an existing one + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["-n", "--name", "--issue-name"], + help="The name of the IssueResource", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.related = AAZStrArg( + options=["--related"], + help="Related resource or alert that is to be added to the issue (default: empty - the issue will be created without any related resources or alerts)", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.background = AAZObjectArg( + options=["--background"], + arg_group="Properties", + help="The issue background information", + ) + _args_schema.impact_time = AAZDateTimeArg( + options=["--impact-time"], + arg_group="Properties", + help="The issue impact time (in UTC)", + fmt=AAZDateTimeFormat( + protocol="iso", + ), + ) + _args_schema.notifications = AAZObjectArg( + options=["--notifications"], + arg_group="Properties", + help="The issue notification settings", + ) + _args_schema.severity = AAZStrArg( + options=["--severity"], + arg_group="Properties", + help="The issue severity", + ) + _args_schema.status = AAZStrArg( + options=["--status"], + arg_group="Properties", + help="The issue status", + enum={"Canceled": "Canceled", "Closed": "Closed", "InProgress": "InProgress", "Mitigated": "Mitigated", "New": "New"}, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="The issue title", + ) + + background = cls._args_schema.background + background.details = AAZListArg( + options=["details"], + help="The background details", + ) + background.text = AAZStrArg( + options=["text"], + help="The background text", + ) + background.type = AAZStrArg( + options=["type"], + help="The background type", + ) + + details = cls._args_schema.background.details + details.Element = AAZObjectArg() + + _element = cls._args_schema.background.details.Element + _element.name = AAZStrArg( + options=["name"], + help="The background details name", + required=True, + ) + _element.value = AAZStrArg( + options=["value"], + help="The background details value", + required=True, + ) + + notifications = cls._args_schema.notifications + notifications.action_group_ids = AAZListArg( + options=["action-group-ids"], + help="The action group IDs to notify", + ) + notifications.exclude_default_action_groups = AAZBoolArg( + options=["exclude-default-action-groups"], + help="Whether to exclude default action groups from notifications", + ) + notifications.update_types = AAZListArg( + options=["update-types"], + help="The types of updates that trigger notifications", + ) + + action_group_ids = cls._args_schema.notifications.action_group_ids + action_group_ids.Element = AAZStrArg() + + update_types = cls._args_schema.notifications.update_types + update_types.Element = AAZObjectArg() + + _element = cls._args_schema.notifications.update_types.Element + _element.issue_creation = AAZObjectArg( + options=["issue-creation"], + blank={}, + ) + _element.on_change = AAZObjectArg( + options=["on-change"], + blank={}, + ) + _element.time_based = AAZObjectArg( + options=["time-based"], + ) + + time_based = cls._args_schema.notifications.update_types.Element.time_based + time_based.update_interval = AAZStrArg( + options=["update-interval"], + help="The interval between time-based updates", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueCreate(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 IssueCreate(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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "related", self.ctx.args.related, + ), + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("background", AAZObjectType, ".background") + properties.set_prop("impactTime", AAZStrType, ".impact_time", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("notifications", AAZObjectType, ".notifications") + properties.set_prop("severity", AAZStrType, ".severity", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("status", AAZStrType, ".status", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + background = _builder.get(".properties.background") + if background is not None: + background.set_prop("details", AAZListType, ".details") + background.set_prop("text", AAZStrType, ".text") + background.set_prop("type", AAZStrType, ".type") + + details = _builder.get(".properties.background.details") + if details is not None: + details.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.background.details[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("value", AAZStrType, ".value", typ_kwargs={"flags": {"required": True}}) + + notifications = _builder.get(".properties.notifications") + if notifications is not None: + notifications.set_prop("actionGroupIds", AAZListType, ".action_group_ids") + notifications.set_prop("excludeDefaultActionGroups", AAZBoolType, ".exclude_default_action_groups") + notifications.set_prop("updateTypes", AAZListType, ".update_types") + + action_group_ids = _builder.get(".properties.notifications.actionGroupIds") + if action_group_ids is not None: + action_group_ids.set_elements(AAZStrType, ".") + + update_types = _builder.get(".properties.notifications.updateTypes") + if update_types is not None: + update_types.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.notifications.updateTypes[]") + if _elements is not None: + _elements.set_const("updateType", "IssueCreation", AAZStrType, ".issue_creation", typ_kwargs={"flags": {"required": True}}) + _elements.set_const("updateType", "OnChange", AAZStrType, ".on_change", typ_kwargs={"flags": {"required": True}}) + _elements.set_const("updateType", "TimeBased", AAZStrType, ".time_based", typ_kwargs={"flags": {"required": True}}) + _elements.discriminate_by("updateType", "IssueCreation") + _elements.discriminate_by("updateType", "OnChange") + _elements.discriminate_by("updateType", "TimeBased") + + disc_time_based = _builder.get(".properties.notifications.updateTypes[]{updateType:TimeBased}") + if disc_time_based is not None: + disc_time_based.set_prop("updateInterval", AAZStrType, ".time_based.update_interval", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType() + _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.background = AAZObjectType() + properties.impact_time = AAZStrType( + serialized_name="impactTime", + flags={"required": True}, + ) + properties.investigations = AAZListType( + flags={"read_only": True}, + ) + properties.investigations_count = AAZIntType( + serialized_name="investigationsCount", + flags={"read_only": True}, + ) + properties.notifications = AAZObjectType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.severity = AAZStrType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + background = cls._schema_on_200_201.properties.background + background.details = AAZListType() + background.text = AAZStrType() + background.type = AAZStrType() + + details = cls._schema_on_200_201.properties.background.details + details.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.background.details.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + investigations = cls._schema_on_200_201.properties.investigations + investigations.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.investigations.Element + _element.created_at = AAZStrType( + serialized_name="createdAt", + flags={"required": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + + notifications = cls._schema_on_200_201.properties.notifications + notifications.action_group_ids = AAZListType( + serialized_name="actionGroupIds", + ) + notifications.exclude_default_action_groups = AAZBoolType( + serialized_name="excludeDefaultActionGroups", + ) + notifications.update_types = AAZListType( + serialized_name="updateTypes", + ) + + action_group_ids = cls._schema_on_200_201.properties.notifications.action_group_ids + action_group_ids.Element = AAZStrType() + + update_types = cls._schema_on_200_201.properties.notifications.update_types + update_types.Element = AAZObjectType() + + _element = cls._schema_on_200_201.properties.notifications.update_types.Element + _element.update_type = AAZStrType( + serialized_name="updateType", + flags={"required": True}, + ) + + disc_time_based = cls._schema_on_200_201.properties.notifications.update_types.Element.discriminate_by("update_type", "TimeBased") + disc_time_based.update_interval = AAZStrType( + serialized_name="updateInterval", + 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 _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py new file mode 100644 index 00000000000..497205e3427 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py @@ -0,0 +1,152 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete an issue + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["-n", "--name", "--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class IssueDelete(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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py new file mode 100644 index 00000000000..175b62aaca5 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py @@ -0,0 +1,193 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor account issue fetch-background-visualization", +) +class FetchBackgroundVisualization(AAZCommand): + """Fetch the background visualization of the issue + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/fetchbackgroundvisualization", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueFetchBackgroundVisualization(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 IssueFetchBackgroundVisualization(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/fetchBackgroundVisualization", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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.origin = AAZObjectType( + flags={"read_only": True}, + ) + _schema_on_200.visualization = AAZStrType( + flags={"required": True}, + ) + + origin = cls._schema_on_200.origin + origin.added_by = AAZStrType( + serialized_name="addedBy", + flags={"required": True}, + ) + origin.added_by_type = AAZStrType( + serialized_name="addedByType", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _FetchBackgroundVisualizationHelper: + """Helper class for FetchBackgroundVisualization""" + + +__all__ = ["FetchBackgroundVisualization"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py new file mode 100644 index 00000000000..37a76bb2deb --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py @@ -0,0 +1,224 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue fetch-investigation-result", +) +class FetchInvestigationResult(AAZCommand): + """Fetch investigation result + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/fetchinvestigationresult", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.investigation_id = AAZUuidArg( + options=["--investigation-id"], + arg_group="Body", + help="The unique identifier of the investigation", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueFetchInvestigationResult(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 IssueFetchInvestigationResult(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/fetchInvestigationResult", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("investigationId", AAZStrType, ".investigation_id", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.created_at = AAZStrType( + serialized_name="createdAt", + ) + _schema_on_200.id = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + _schema_on_200.origin = AAZObjectType() + _schema_on_200.result = AAZStrType( + flags={"required": True}, + ) + + origin = cls._schema_on_200.origin + origin.added_by = AAZStrType( + serialized_name="addedBy", + flags={"required": True}, + ) + origin.added_by_type = AAZStrType( + serialized_name="addedByType", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _FetchInvestigationResultHelper: + """Helper class for FetchInvestigationResult""" + + +__all__ = ["FetchInvestigationResult"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py new file mode 100644 index 00000000000..0d2e59e933b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py @@ -0,0 +1,295 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue list", +) +class List(AAZCommand): + """List all issues under the parent + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueList(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 IssueList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _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.background = AAZObjectType() + properties.impact_time = AAZStrType( + serialized_name="impactTime", + flags={"required": True}, + ) + properties.investigations = AAZListType( + flags={"read_only": True}, + ) + properties.investigations_count = AAZIntType( + serialized_name="investigationsCount", + flags={"read_only": True}, + ) + properties.notifications = AAZObjectType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.severity = AAZStrType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + background = cls._schema_on_200.value.Element.properties.background + background.details = AAZListType() + background.text = AAZStrType() + background.type = AAZStrType() + + details = cls._schema_on_200.value.Element.properties.background.details + details.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.background.details.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + investigations = cls._schema_on_200.value.Element.properties.investigations + investigations.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.investigations.Element + _element.created_at = AAZStrType( + serialized_name="createdAt", + flags={"required": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + + notifications = cls._schema_on_200.value.Element.properties.notifications + notifications.action_group_ids = AAZListType( + serialized_name="actionGroupIds", + ) + notifications.exclude_default_action_groups = AAZBoolType( + serialized_name="excludeDefaultActionGroups", + ) + notifications.update_types = AAZListType( + serialized_name="updateTypes", + ) + + action_group_ids = cls._schema_on_200.value.Element.properties.notifications.action_group_ids + action_group_ids.Element = AAZStrType() + + update_types = cls._schema_on_200.value.Element.properties.notifications.update_types + update_types.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.notifications.update_types.Element + _element.update_type = AAZStrType( + serialized_name="updateType", + flags={"required": True}, + ) + + disc_time_based = cls._schema_on_200.value.Element.properties.notifications.update_types.Element.discriminate_by("update_type", "TimeBased") + disc_time_based.update_interval = AAZStrType( + serialized_name="updateInterval", + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py new file mode 100644 index 00000000000..5ffc7188a9c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py @@ -0,0 +1,238 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue list-alert", +) +class ListAlert(AAZCommand): + """List all alerts in the issue - this method uses pagination to return all alerts + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/listalerts", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.filter = AAZStrArg( + options=["--filter"], + arg_group="Body", + help="The filter to apply on the operation. For example, to filter by relevance, use \"$filter=relevance eq 'Relevant'\". Note: this property is currently a placeholder and is not in use.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueListAlerts(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 IssueListAlerts(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/listAlerts", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("filter", AAZStrType, ".filter") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.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.added_at = AAZStrType( + serialized_name="addedAt", + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + flags={"read_only": True}, + ) + _element.origin = AAZObjectType( + flags={"read_only": True}, + ) + _element.relevance = AAZStrType( + flags={"required": True}, + ) + + origin = cls._schema_on_200.value.Element.origin + origin.added_by = AAZStrType( + serialized_name="addedBy", + flags={"required": True}, + ) + origin.added_by_type = AAZStrType( + serialized_name="addedByType", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListAlertHelper: + """Helper class for ListAlert""" + + +__all__ = ["ListAlert"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py new file mode 100644 index 00000000000..c7fa662dd03 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py @@ -0,0 +1,238 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue list-resource", +) +class ListResource(AAZCommand): + """List all resources in the issue - this method uses pagination to return all resources + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/listresources", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.filter = AAZStrArg( + options=["--filter"], + arg_group="Body", + help="The filter to apply on the operation. For example, to filter by relevance, use \"$filter=relevance eq 'Relevant'\". Note: this property is currently a placeholder and is not in use.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueListResources(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 IssueListResources(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/listResources", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("filter", AAZStrType, ".filter") + + return self.serialize_content(_content_value) + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.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.added_at = AAZStrType( + serialized_name="addedAt", + flags={"read_only": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + _element.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + flags={"read_only": True}, + ) + _element.origin = AAZObjectType( + flags={"read_only": True}, + ) + _element.relevance = AAZStrType( + flags={"required": True}, + ) + + origin = cls._schema_on_200.value.Element.origin + origin.added_by = AAZStrType( + serialized_name="addedBy", + flags={"required": True}, + ) + origin.added_by_type = AAZStrType( + serialized_name="addedByType", + flags={"required": True}, + ) + + return cls._schema_on_200 + + +class _ListResourceHelper: + """Helper class for ListResource""" + + +__all__ = ["ListResource"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py new file mode 100644 index 00000000000..17d3d65d618 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py @@ -0,0 +1,176 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue set-background-visualization", +) +class SetBackgroundVisualization(AAZCommand): + """Set the background visualization for the issue + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}/setbackgroundvisualization", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Body" + + _args_schema = cls._args_schema + _args_schema.visualization = AAZStrArg( + options=["--visualization"], + arg_group="Body", + help="The background visualization content, in Adaptive Card format", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueSetBackgroundVisualization(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class IssueSetBackgroundVisualization(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 [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}/setBackgroundVisualization", + **self.url_parameters + ) + + @property + def method(self): + return "POST" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("visualization", AAZStrType, ".visualization", typ_kwargs={"flags": {"required": True}}) + + return self.serialize_content(_content_value) + + def on_204(self, session): + pass + + +class _SetBackgroundVisualizationHelper: + """Helper class for SetBackgroundVisualization""" + + +__all__ = ["SetBackgroundVisualization"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py new file mode 100644 index 00000000000..be4cdee32e1 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py @@ -0,0 +1,296 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue show", +) +class Show(AAZCommand): + """Get issue properties + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["-n", "--name", "--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueGet(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 IssueGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _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.background = AAZObjectType() + properties.impact_time = AAZStrType( + serialized_name="impactTime", + flags={"required": True}, + ) + properties.investigations = AAZListType( + flags={"read_only": True}, + ) + properties.investigations_count = AAZIntType( + serialized_name="investigationsCount", + flags={"read_only": True}, + ) + properties.notifications = AAZObjectType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.severity = AAZStrType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + background = cls._schema_on_200.properties.background + background.details = AAZListType() + background.text = AAZStrType() + background.type = AAZStrType() + + details = cls._schema_on_200.properties.background.details + details.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.background.details.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + investigations = cls._schema_on_200.properties.investigations + investigations.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.investigations.Element + _element.created_at = AAZStrType( + serialized_name="createdAt", + flags={"required": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + + notifications = cls._schema_on_200.properties.notifications + notifications.action_group_ids = AAZListType( + serialized_name="actionGroupIds", + ) + notifications.exclude_default_action_groups = AAZBoolType( + serialized_name="excludeDefaultActionGroups", + ) + notifications.update_types = AAZListType( + serialized_name="updateTypes", + ) + + action_group_ids = cls._schema_on_200.properties.notifications.action_group_ids + action_group_ids.Element = AAZStrType() + + update_types = cls._schema_on_200.properties.notifications.update_types + update_types.Element = AAZObjectType() + + _element = cls._schema_on_200.properties.notifications.update_types.Element + _element.update_type = AAZStrType( + serialized_name="updateType", + flags={"required": True}, + ) + + disc_time_based = cls._schema_on_200.properties.notifications.update_types.Element.discriminate_by("update_type", "TimeBased") + disc_time_based.update_interval = AAZStrType( + serialized_name="updateInterval", + 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/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py new file mode 100644 index 00000000000..67f803bf493 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py @@ -0,0 +1,630 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account issue update", +) +class Update(AAZCommand): + """Update a new issue or updates an existing one + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/issues/{}", "2025-10-03"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.issue_name = AAZStrArg( + options=["-n", "--name", "--issue-name"], + help="The name of the IssueResource", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.related = AAZStrArg( + options=["--related"], + help="Related resource or alert that is to be added to the issue (default: empty - the issue will be created without any related resources or alerts)", + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.background = AAZObjectArg( + options=["--background"], + arg_group="Properties", + help="The issue background information", + nullable=True, + ) + _args_schema.impact_time = AAZDateTimeArg( + options=["--impact-time"], + arg_group="Properties", + help="The issue impact time (in UTC)", + fmt=AAZDateTimeFormat( + protocol="iso", + ), + ) + _args_schema.notifications = AAZObjectArg( + options=["--notifications"], + arg_group="Properties", + help="The issue notification settings", + nullable=True, + ) + _args_schema.severity = AAZStrArg( + options=["--severity"], + arg_group="Properties", + help="The issue severity", + ) + _args_schema.status = AAZStrArg( + options=["--status"], + arg_group="Properties", + help="The issue status", + enum={"Canceled": "Canceled", "Closed": "Closed", "InProgress": "InProgress", "Mitigated": "Mitigated", "New": "New"}, + ) + _args_schema.title = AAZStrArg( + options=["--title"], + arg_group="Properties", + help="The issue title", + ) + + background = cls._args_schema.background + background.details = AAZListArg( + options=["details"], + help="The background details", + nullable=True, + ) + background.text = AAZStrArg( + options=["text"], + help="The background text", + nullable=True, + ) + background.type = AAZStrArg( + options=["type"], + help="The background type", + nullable=True, + ) + + details = cls._args_schema.background.details + details.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.background.details.Element + _element.name = AAZStrArg( + options=["name"], + help="The background details name", + ) + _element.value = AAZStrArg( + options=["value"], + help="The background details value", + ) + + notifications = cls._args_schema.notifications + notifications.action_group_ids = AAZListArg( + options=["action-group-ids"], + help="The action group IDs to notify", + nullable=True, + ) + notifications.exclude_default_action_groups = AAZBoolArg( + options=["exclude-default-action-groups"], + help="Whether to exclude default action groups from notifications", + nullable=True, + ) + notifications.update_types = AAZListArg( + options=["update-types"], + help="The types of updates that trigger notifications", + nullable=True, + ) + + action_group_ids = cls._args_schema.notifications.action_group_ids + action_group_ids.Element = AAZStrArg( + nullable=True, + ) + + update_types = cls._args_schema.notifications.update_types + update_types.Element = AAZObjectArg( + nullable=True, + ) + + _element = cls._args_schema.notifications.update_types.Element + _element.issue_creation = AAZObjectArg( + options=["issue-creation"], + blank={}, + ) + _element.on_change = AAZObjectArg( + options=["on-change"], + blank={}, + ) + _element.time_based = AAZObjectArg( + options=["time-based"], + ) + + time_based = cls._args_schema.notifications.update_types.Element.time_based + time_based.update_interval = AAZStrArg( + options=["update-interval"], + help="The interval between time-based updates", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.IssueGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.IssueCreate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class IssueGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _UpdateHelper._build_schema_issue_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class IssueCreate(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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/issues/{issueName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "issueName", self.ctx.args.issue_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "related", self.ctx.args.related, + ), + **self.serialize_query_param( + "api-version", "2025-10-03", + 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, + value=self.ctx.vars.instance, + ) + + 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() + _UpdateHelper._build_schema_issue_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("background", AAZObjectType, ".background") + properties.set_prop("impactTime", AAZStrType, ".impact_time", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("notifications", AAZObjectType, ".notifications") + properties.set_prop("severity", AAZStrType, ".severity", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("status", AAZStrType, ".status", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + + background = _builder.get(".properties.background") + if background is not None: + background.set_prop("details", AAZListType, ".details") + background.set_prop("text", AAZStrType, ".text") + background.set_prop("type", AAZStrType, ".type") + + details = _builder.get(".properties.background.details") + if details is not None: + details.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.background.details[]") + if _elements is not None: + _elements.set_prop("name", AAZStrType, ".name", typ_kwargs={"flags": {"required": True}}) + _elements.set_prop("value", AAZStrType, ".value", typ_kwargs={"flags": {"required": True}}) + + notifications = _builder.get(".properties.notifications") + if notifications is not None: + notifications.set_prop("actionGroupIds", AAZListType, ".action_group_ids") + notifications.set_prop("excludeDefaultActionGroups", AAZBoolType, ".exclude_default_action_groups") + notifications.set_prop("updateTypes", AAZListType, ".update_types") + + action_group_ids = _builder.get(".properties.notifications.actionGroupIds") + if action_group_ids is not None: + action_group_ids.set_elements(AAZStrType, ".") + + update_types = _builder.get(".properties.notifications.updateTypes") + if update_types is not None: + update_types.set_elements(AAZObjectType, ".") + + _elements = _builder.get(".properties.notifications.updateTypes[]") + if _elements is not None: + _elements.set_const("updateType", "IssueCreation", AAZStrType, ".issue_creation", typ_kwargs={"flags": {"required": True}}) + _elements.set_const("updateType", "OnChange", AAZStrType, ".on_change", typ_kwargs={"flags": {"required": True}}) + _elements.set_const("updateType", "TimeBased", AAZStrType, ".time_based", typ_kwargs={"flags": {"required": True}}) + _elements.discriminate_by("updateType", "IssueCreation") + _elements.discriminate_by("updateType", "OnChange") + _elements.discriminate_by("updateType", "TimeBased") + + disc_time_based = _builder.get(".properties.notifications.updateTypes[]{updateType:TimeBased}") + if disc_time_based is not None: + disc_time_based.set_prop("updateInterval", AAZStrType, ".time_based.update_interval", typ_kwargs={"flags": {"required": True}}) + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_issue_resource_read = None + + @classmethod + def _build_schema_issue_resource_read(cls, _schema): + if cls._schema_issue_resource_read is not None: + _schema.id = cls._schema_issue_resource_read.id + _schema.name = cls._schema_issue_resource_read.name + _schema.properties = cls._schema_issue_resource_read.properties + _schema.system_data = cls._schema_issue_resource_read.system_data + _schema.type = cls._schema_issue_resource_read.type + return + + cls._schema_issue_resource_read = _schema_issue_resource_read = AAZObjectType() + + issue_resource_read = _schema_issue_resource_read + issue_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + issue_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + issue_resource_read.properties = AAZObjectType() + issue_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + issue_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_issue_resource_read.properties + properties.background = AAZObjectType() + properties.impact_time = AAZStrType( + serialized_name="impactTime", + flags={"required": True}, + ) + properties.investigations = AAZListType( + flags={"read_only": True}, + ) + properties.investigations_count = AAZIntType( + serialized_name="investigationsCount", + flags={"read_only": True}, + ) + properties.notifications = AAZObjectType() + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.severity = AAZStrType( + flags={"required": True}, + ) + properties.status = AAZStrType( + flags={"required": True}, + ) + properties.title = AAZStrType( + flags={"required": True}, + ) + + background = _schema_issue_resource_read.properties.background + background.details = AAZListType() + background.text = AAZStrType() + background.type = AAZStrType() + + details = _schema_issue_resource_read.properties.background.details + details.Element = AAZObjectType() + + _element = _schema_issue_resource_read.properties.background.details.Element + _element.name = AAZStrType( + flags={"required": True}, + ) + _element.value = AAZStrType( + flags={"required": True}, + ) + + investigations = _schema_issue_resource_read.properties.investigations + investigations.Element = AAZObjectType() + + _element = _schema_issue_resource_read.properties.investigations.Element + _element.created_at = AAZStrType( + serialized_name="createdAt", + flags={"required": True}, + ) + _element.id = AAZStrType( + flags={"required": True}, + ) + + notifications = _schema_issue_resource_read.properties.notifications + notifications.action_group_ids = AAZListType( + serialized_name="actionGroupIds", + ) + notifications.exclude_default_action_groups = AAZBoolType( + serialized_name="excludeDefaultActionGroups", + ) + notifications.update_types = AAZListType( + serialized_name="updateTypes", + ) + + action_group_ids = _schema_issue_resource_read.properties.notifications.action_group_ids + action_group_ids.Element = AAZStrType() + + update_types = _schema_issue_resource_read.properties.notifications.update_types + update_types.Element = AAZObjectType() + + _element = _schema_issue_resource_read.properties.notifications.update_types.Element + _element.update_type = AAZStrType( + serialized_name="updateType", + flags={"required": True}, + ) + + disc_time_based = _schema_issue_resource_read.properties.notifications.update_types.Element.discriminate_by("update_type", "TimeBased") + disc_time_based.update_interval = AAZStrType( + serialized_name="updateInterval", + flags={"required": True}, + ) + + system_data = _schema_issue_resource_read.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", + ) + + _schema.id = cls._schema_issue_resource_read.id + _schema.name = cls._schema_issue_resource_read.name + _schema.properties = cls._schema_issue_resource_read.properties + _schema.system_data = cls._schema_issue_resource_read.system_data + _schema.type = cls._schema_issue_resource_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__cmd_group.py new file mode 100644 index 00000000000..53df237b6ef --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__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( + "monitor account metrics-container", +) +class __CMDGroup(AAZCommandGroup): + """Manage Metrics Container + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__init__.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__init__.py new file mode 100644 index 00000000000..464e9a9d209 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/__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 ._create import * +from ._list import * +from ._show import * +from ._update import * diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py new file mode 100644 index 00000000000..5be22320fa9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py @@ -0,0 +1,243 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor account metrics-container create", +) +class Create(AAZCommand): + """Create metrics container settings for a monitoring account. + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/metricscontainers/{}", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.metrics_container_name = AAZStrArg( + options=["-n", "--name", "--metrics-container-name"], + help="The name of the MetricsContainer", + required=True, + fmt=AAZStrArgFormat( + pattern="^default$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="Properties", + help="The version of Metrics Query Service that this AMW will use for all metric queries.", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricsContainersCreateOrUpdate(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 MetricsContainersCreateOrUpdate(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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "metricsContainerName", self.ctx.args.metrics_container_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("version", AAZStrType, ".version") + + 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() + _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}, + ) + properties.version = AAZStrType() + + 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 _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.py new file mode 100644 index 00000000000..c11acb61452 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.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( + "monitor account metrics-container list", +) +class List(AAZCommand): + """List metrics containers for a monitoring account. + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/metricscontainers", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricsContainersListByAzureMonitorWorkspace(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 MetricsContainersListByAzureMonitorWorkspace(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _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}, + ) + properties.version = AAZStrType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py new file mode 100644 index 00000000000..948bd458421 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py @@ -0,0 +1,218 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "monitor account metrics-container show", +) +class Show(AAZCommand): + """Get metrics container settings for a monitoring account. + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/metricscontainers/{}", "2025-10-03"], + ] + } + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.metrics_container_name = AAZStrArg( + options=["-n", "--name", "--metrics-container-name"], + help="The name of the MetricsContainer", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^default$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricsContainersGet(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 MetricsContainersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "metricsContainerName", self.ctx.args.metrics_container_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _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}, + ) + properties.version = AAZStrType() + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ShowHelper: + """Helper class for Show""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py new file mode 100644 index 00000000000..5b56f837375 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py @@ -0,0 +1,390 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "monitor account metrics-container update", +) +class Update(AAZCommand): + """Update metrics container settings for a monitoring account. + """ + + _aaz_info = { + "version": "2025-10-03", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.monitor/accounts/{}/metricscontainers/{}", "2025-10-03"], + ] + } + + AZ_SUPPORT_GENERIC_UPDATE = True + + 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.azure_monitor_workspace_name = AAZStrArg( + options=["--azure-monitor-workspace-name"], + help="The name of the Azure Monitor Workspace. The name is case insensitive", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^(?!-)[a-zA-Z0-9-]+[^-]$", + ), + ) + _args_schema.metrics_container_name = AAZStrArg( + options=["-n", "--name", "--metrics-container-name"], + help="The name of the MetricsContainer", + required=True, + id_part="child_name_1", + fmt=AAZStrArgFormat( + pattern="^default$", + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.version = AAZStrArg( + options=["--version"], + arg_group="Properties", + help="The version of Metrics Query Service that this AMW will use for all metric queries.", + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.MetricsContainersGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + self.MetricsContainersCreateOrUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class MetricsContainersGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "metricsContainerName", self.ctx.args.metrics_container_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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() + _UpdateHelper._build_schema_metrics_container_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class MetricsContainersCreateOrUpdate(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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/accounts/{azureMonitorWorkspaceName}/metricsContainers/{metricsContainerName}", + **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( + "azureMonitorWorkspaceName", self.ctx.args.azure_monitor_workspace_name, + required=True, + ), + **self.serialize_url_param( + "metricsContainerName", self.ctx.args.metrics_container_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-10-03", + 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, + value=self.ctx.vars.instance, + ) + + 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() + _UpdateHelper._build_schema_metrics_container_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("properties", AAZObjectType) + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("version", AAZStrType, ".version") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_metrics_container_resource_read = None + + @classmethod + def _build_schema_metrics_container_resource_read(cls, _schema): + if cls._schema_metrics_container_resource_read is not None: + _schema.id = cls._schema_metrics_container_resource_read.id + _schema.name = cls._schema_metrics_container_resource_read.name + _schema.properties = cls._schema_metrics_container_resource_read.properties + _schema.system_data = cls._schema_metrics_container_resource_read.system_data + _schema.type = cls._schema_metrics_container_resource_read.type + return + + cls._schema_metrics_container_resource_read = _schema_metrics_container_resource_read = AAZObjectType() + + metrics_container_resource_read = _schema_metrics_container_resource_read + metrics_container_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + metrics_container_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + metrics_container_resource_read.properties = AAZObjectType() + metrics_container_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + metrics_container_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_metrics_container_resource_read.properties + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.version = AAZStrType() + + system_data = _schema_metrics_container_resource_read.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", + ) + + _schema.id = cls._schema_metrics_container_resource_read.id + _schema.name = cls._schema_metrics_container_resource_read.name + _schema.properties = cls._schema_metrics_container_resource_read.properties + _schema.system_data = cls._schema_metrics_container_resource_read.system_data + _schema.type = cls._schema_metrics_container_resource_read.type + + +__all__ = ["Update"] From 9b930f6442d27573819f2f578b6642196944adab Mon Sep 17 00:00:00 2001 From: GokulPrasad KrishnaSwamy Date: Fri, 8 May 2026 11:28:24 -0700 Subject: [PATCH 3/5] {Monitor} Add tests for monitor account identity/metrics-container subgroup commands --- .../test_monitor_account_identity.yaml | 736 ++++++++++++++++++ .../test_monitor_account_issue.yaml | 171 ++++ ...est_monitor_account_metrics_container.yaml | 521 +++++++++++++ .../tests/latest/test_monitor_account.py | 85 ++ 4 files changed, 1513 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_identity.yaml create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_issue.yaml create mode 100644 src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_metrics_container.yaml diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_identity.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_identity.yaml new file mode 100644 index 00000000000..f30c94e8b20 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_identity.yaml @@ -0,0 +1,736 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001?api-version=2024-11-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001","name":"cli_test_monitor_account_id000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","test":"test_monitor_account_identity","date":"2026-05-08T18:26:31Z","module":"monitor"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '402' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:26:48 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: C118E17934554860BAD66EE32ECE254E Ref B: MWH011020808029 Ref C: 2026-05-08T18:26:48Z' + status: + code: 200 + message: OK +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"2400a5c2-0000-0700-0000-69fe2af60000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:26:50.071245Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1418' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:02 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/ac25a2b5-a303-469b-b562-759148ebbde6 + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: 5111D1F2239C4B878DA352295D031B35 Ref B: CO1AA3060814029 Ref C: 2026-05-08T18:26:49Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity assign + Connection: + - keep-alive + ParameterSetName: + - -n -g --system-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"2400a5c2-0000-0700-0000-69fe2af60000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:26:50.071245Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1418' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:03 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 77F7C7E4E28D49F8805C5C22CE83873B Ref B: CO1AA3060820054 Ref C: 2026-05-08T18:27:03Z' + status: + code: 200 + message: OK +- request: + body: '{"identity": {"type": "SystemAssigned"}, "location": "westus", "properties": + {"metrics": {"enableAccessUsingResourcePermissions": true}, "publicNetworkAccess": + "Enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity assign + Connection: + - keep-alive + Content-Length: + - '171' + Content-Type: + - application/json + ParameterSetName: + - -n -g --system-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","identity":{"type":"systemAssigned","principalId":"3d8f0b81-6413-4f35-9b35-01bf24f36bc2","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"2400dcc2-0000-0700-0000-69fe2b010000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:04.3886327Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1559' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:12 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/903aec34-e7fe-400f-930d-071da77630a8 + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: 2DAD28E12714451CAF1D13A5FD96014B Ref B: CO1AA3060815040 Ref C: 2026-05-08T18:27:04Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity show + Connection: + - keep-alive + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","identity":{"type":"systemAssigned","principalId":"3d8f0b81-6413-4f35-9b35-01bf24f36bc2","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"2400dcc2-0000-0700-0000-69fe2b010000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:04.3886327Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1559' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:14 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: F0089105796E4BC5A62AB7B081D1F56B Ref B: CO6AA3150220025 Ref C: 2026-05-08T18:27:14Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity remove + Connection: + - keep-alive + ParameterSetName: + - -n -g --system-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","identity":{"type":"systemAssigned","principalId":"3d8f0b81-6413-4f35-9b35-01bf24f36bc2","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"2400dcc2-0000-0700-0000-69fe2b010000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:04.3886327Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1559' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:15 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: BA507B0E18034DF181ADCE7ADE5C0CAC Ref B: CO6AA3150218039 Ref C: 2026-05-08T18:27:15Z' + status: + code: 200 + message: OK +- request: + body: '{"identity": {"type": "None"}, "location": "westus", "properties": {"metrics": + {"enableAccessUsingResourcePermissions": true}, "publicNetworkAccess": "Enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity remove + Connection: + - keep-alive + Content-Length: + - '161' + Content-Type: + - application/json + ParameterSetName: + - -n -g --system-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"24000fc3-0000-0700-0000-69fe2b0c0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:16.0220747Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1419' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:23 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/74304071-0618-4e2a-803f-7e4829d7eba8 + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: C1E5691AC23F4DDB956F910BD18C83CD Ref B: CO1AA3060816023 Ref C: 2026-05-08T18:27:15Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - identity create + Connection: + - keep-alive + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001?api-version=2024-11-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001","name":"cli_test_monitor_account_id000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","test":"test_monitor_account_identity","date":"2026-05-08T18:26:31Z","module":"monitor"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '402' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:24 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 391840FB10764354BA2344EBFDD7DF6B Ref B: CO1AA3060819040 Ref C: 2026-05-08T18:27:25Z' + status: + code: 200 + message: OK +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - identity create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.ManagedIdentity/userAssignedIdentities/amid000003?api-version=2024-11-30 + response: + body: + string: '{"location":"westus","tags":{},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/Microsoft.ManagedIdentity/userAssignedIdentities/amid000003","name":"amid000003","type":"Microsoft.ManagedIdentity/userAssignedIdentities","properties":{"isolationScope":"None","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","principalId":"3ee911d6-da4c-4b73-be08-82ac8e1a6193","clientId":"fdd3e417-35ca-403a-b8c7-5ee470a484de"}}' + headers: + cache-control: + - no-cache + content-length: + - '479' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:27 GMT + expires: + - '-1' + location: + - /subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/Microsoft.ManagedIdentity/userAssignedIdentities/amid000003 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/684673c0-6fa4-44bf-a19d-3559a48aa202 + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: B97D3F95F8494736AB03FF9DECDB61D6 Ref B: CO6AA3150218047 Ref C: 2026-05-08T18:27:25Z' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity assign + Connection: + - keep-alive + ParameterSetName: + - -n -g --user-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"24000fc3-0000-0700-0000-69fe2b0c0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:16.0220747Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1419' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:28 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 7DA1DA0585C3480E93B00D42233ED2EE Ref B: MWH011020806062 Ref C: 2026-05-08T18:27:28Z' + status: + code: 200 + message: OK +- request: + body: '{"identity": {"userAssignedIdentities": {"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/Microsoft.ManagedIdentity/userAssignedIdentities/amid000003": + {}}, "type": "UserAssigned"}, "location": "westus", "properties": {"metrics": + {"enableAccessUsingResourcePermissions": true}, "publicNetworkAccess": "Enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity assign + Connection: + - keep-alive + Content-Length: + - '375' + Content-Type: + - application/json + ParameterSetName: + - -n -g --user-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","identity":{"type":"userAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/Microsoft.ManagedIdentity/userAssignedIdentities/amid000003":{"principalId":"3ee911d6-da4c-4b73-be08-82ac8e1a6193","clientId":"fdd3e417-35ca-403a-b8c7-5ee470a484de"}}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"240057c3-0000-0700-0000-69fe2b1a0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:29.9630308Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1759' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:38 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/7c912e11-1600-410a-ae83-a06c8f105cf9 + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: 7EB2B33979F24107805105A3851AED57 Ref B: CO1AA3060819023 Ref C: 2026-05-08T18:27:29Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity remove + Connection: + - keep-alive + ParameterSetName: + - -n -g --user-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","identity":{"type":"userAssigned","userAssignedIdentities":{"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/Microsoft.ManagedIdentity/userAssignedIdentities/amid000003":{"principalId":"3ee911d6-da4c-4b73-be08-82ac8e1a6193","clientId":"fdd3e417-35ca-403a-b8c7-5ee470a484de"}}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"240057c3-0000-0700-0000-69fe2b1a0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:29.9630308Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1759' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:38 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 1CE0D5E649AB42BEA2603083F33BF79B Ref B: CO1AA3060813062 Ref C: 2026-05-08T18:27:39Z' + status: + code: 200 + message: OK +- request: + body: '{"identity": {"type": "None"}, "location": "westus", "properties": {"metrics": + {"enableAccessUsingResourcePermissions": true}, "publicNetworkAccess": "Enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account identity remove + Connection: + - keep-alive + Content-Length: + - '161' + Content-Type: + - application/json + ParameterSetName: + - -n -g --user-assigned + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_id000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"cee47e68-b44b-42fa-b5d9-5dee3fbaa511","metrics":{"prometheusQueryEndpoint":"https://ac000002-fhbxfhasf0ayehck.westus.prometheus.monitor.azure.com","internalId":"mac_cee47e68-b44b-42fa-b5d9-5dee3fbaa511","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-1162eaa2d296444aa6d25d15fd8205dc","ingestionEndpoints":{"metrics":"https://ac000002-ogsr.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_id000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"240099c3-0000-0700-0000-69fe2b230000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T18:26:50.071245Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T18:27:40.1358543Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1419' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 18:27:46 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/bf515f19-f9ad-4d96-8645-e273fa6a5b37 + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: 42F80EB7F7004187B54FD9764A8893F6 Ref B: CO1AA3060814023 Ref C: 2026-05-08T18:27:39Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_issue.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_issue.yaml new file mode 100644 index 00000000000..81d1348a7b0 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_issue.yaml @@ -0,0 +1,171 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_issue000001?api-version=2024-11-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_issue000001","name":"cli_test_monitor_account_issue000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","test":"test_monitor_account_issue","date":"2026-05-08T17:55:56Z","module":"monitor"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '405' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:55:59 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: CD25809B527C49F29CBD4D2146CD022A Ref B: CO6AA3150220025 Ref C: 2026-05-08T17:55:59Z' + status: + code: 200 + message: OK +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_issue000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"fdf16d14-840d-42c3-a45a-3256a8d15aed","metrics":{"prometheusQueryEndpoint":"https://ac000002-cqe5bxg5erfjhhew.westus.prometheus.monitor.azure.com","internalId":"mac_fdf16d14-840d-42c3-a45a-3256a8d15aed","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-8ac761dde6bd487090b75bee352e799f","ingestionEndpoints":{"metrics":"https://ac000002-9ire.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_issue000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"2400ae77-0000-0700-0000-69fe23bd0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T17:56:00.9917976Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T17:56:00.9917976Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1423' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:56:13 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus2/5224101e-7898-4783-9166-8f2bebd8d7ef + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: 63BD80BD9545492FAADC0EF573FE99F5 Ref B: CO6AA3150217023 Ref C: 2026-05-08T17:56:00Z' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"severity": "Low", "status": "New", "title": "Test Issue"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account issue create + Connection: + - keep-alive + Content-Length: + - '75' + Content-Type: + - application/json + ParameterSetName: + - --azure-monitor-workspace-name -g -n --title --severity --status + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_issue000001/providers/Microsoft.Monitor/accounts/ac000002/issues/issue000003?api-version=2025-10-03 + response: + body: + string: '{"error":{"code":"NoRegisteredProviderFound","message":"No registered + resource provider found for location ''westus'' and API version ''2025-10-03'' + for type ''accounts/issues''. The supported api-versions are ''2025-05-03-preview, + 2025-10-03-preview''. The supported locations are ''australiacentral, australiaeast, + australiasoutheast, brazilsouth, canadacentral, canadaeast, centralindia, + centralus, chilecentral, eastasia, eastus, eastus2, francecentral, germanywestcentral, + indonesiacentral, israelcentral, italynorth, japaneast, japanwest, koreacentral, + koreasouth, malaysiawest, mexicocentral, newzealandnorth, northcentralus, + northeurope, norwayeast, polandcentral, southafricanorth, southcentralus, + southindia, southeastasia, spaincentral, swedencentral, switzerlandnorth, + uaenorth, uksouth, ukwest, westcentralus, westeurope, westus, westus2, westus3, + eastus2euap, swedensouth''."}}' + headers: + cache-control: + - no-cache + content-length: + - '881' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:56:14 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + x-msedge-ref: + - 'Ref A: 3AE174978F5C42308CE2E1004FD78F9E Ref B: CO1AA3060815062 Ref C: 2026-05-08T17:56:14Z' + status: + code: 400 + message: Bad Request +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_metrics_container.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_metrics_container.yaml new file mode 100644 index 00000000000..eab5ca863dc --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_account_metrics_container.yaml @@ -0,0 +1,521 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_mc000001?api-version=2024-11-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001","name":"cli_test_monitor_account_mc000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","test":"test_monitor_account_metrics_container","date":"2026-05-08T17:58:16Z","module":"monitor"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '411' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:58:21 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: FCADCB5710E946CEA57E604EC9D1472F Ref B: CO6AA3150218037 Ref C: 2026-05-08T17:58:21Z' + status: + code: 200 + message: OK +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -n -g + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002?api-version=2025-10-03 + response: + body: + string: '{"properties":{"accountId":"14e21a3b-a68e-4626-873e-6539bd54fc63","metrics":{"prometheusQueryEndpoint":"https://ac000002-g2a5gpe2eecga6gf.westus.prometheus.monitor.azure.com","internalId":"mac_14e21a3b-a68e-4626-873e-6539bd54fc63","enableAccessUsingResourcePermissions":true},"provisioningState":"Succeeded","defaultIngestionSettings":{"dataCollectionRuleResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionRules/ac000002","dataCollectionEndpointResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MA_ac000002_westus_managed/providers/Microsoft.Insights/dataCollectionEndpoints/ac000002","dataCollectionRuleImmutableId":"dcr-9ef0dccd9267493699b55b77942fc26b","ingestionEndpoints":{"metrics":"https://ac000002-4yha.westus-1.metrics.ingest.monitor.azure.com"}},"publicNetworkAccess":"Enabled"},"location":"westus","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_mc000001/providers/microsoft.monitor/accounts/ac000002","name":"ac000002","type":"Microsoft.Monitor/accounts","etag":"\"24009d7b-0000-0700-0000-69fe244e0000\"","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T17:58:22.6069291Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T17:58:22.6069291Z"}}' + headers: + api-supported-versions: + - 2021-06-01-preview, 2021-06-03-preview, 2023-04-01, 2023-04-03, 2023-06-01-preview, + 2024-04-01-preview, 2024-04-03-preview, 2024-10-01-preview, 2024-10-03-preview, + 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '1420' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:58:38 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westcentralus/4deb1619-61d1-43a8-a8a0-8a9f238cad14 + x-ms-ratelimit-remaining-subscription-global-writes: + - '12000' + x-ms-ratelimit-remaining-subscription-writes: + - '800' + x-msedge-ref: + - 'Ref A: B64147E738D140E4BE1D66119E00072D Ref B: CO1AA3060818042 Ref C: 2026-05-08T17:58:21Z' + status: + code: 200 + message: OK +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account metrics-container create + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + ParameterSetName: + - --azure-monitor-workspace-name -g -n + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002/metricsContainers/default?api-version=2025-10-03 + response: + body: + string: '{"error":{"code":"DependencyFailure","message":"Failed to update the + Metrics Ingestion limits. Please follow the instructions here: https://go.microsoft.com/fwlink/?linkid=2270124"}}' + headers: + api-supported-versions: + - 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '182' + content-type: + - application/json + date: + - Fri, 08 May 2026 17:58:39 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/c404eaff-363d-4e68-a8b6-f8a3638dee66 + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 4A67D892BCCF4C799758E4410471BF73 Ref B: CO6AA3150219009 Ref C: 2026-05-08T17:58:39Z' + status: + code: 500 + message: Internal Server Error +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account metrics-container create + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + ParameterSetName: + - --azure-monitor-workspace-name -g -n + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002/metricsContainers/default?api-version=2025-10-03 + response: + body: + string: '{"error":{"code":"DependencyFailure","message":"Failed to update the + Metrics Ingestion limits. Please follow the instructions here: https://go.microsoft.com/fwlink/?linkid=2270124"}}' + headers: + api-supported-versions: + - 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '182' + content-type: + - application/json + date: + - Fri, 08 May 2026 17:58:40 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/73b4e29b-66dc-4c87-a605-5754e8dd19be + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 4A6043B19EF641B4B575F56853BC3B38 Ref B: CO6AA3150219039 Ref C: 2026-05-08T17:58:41Z' + status: + code: 500 + message: Internal Server Error +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account metrics-container create + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + ParameterSetName: + - --azure-monitor-workspace-name -g -n + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002/metricsContainers/default?api-version=2025-10-03 + response: + body: + string: '{"error":{"code":"DependencyFailure","message":"Failed to update the + Metrics Ingestion limits. Please follow the instructions here: https://go.microsoft.com/fwlink/?linkid=2270124"}}' + headers: + api-supported-versions: + - 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '182' + content-type: + - application/json + date: + - Fri, 08 May 2026 17:58:43 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/b53fcffb-551b-428f-8135-82cab62489c5 + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 78880A78BBFE4F1F86EFB7D0EA40C00A Ref B: CO1AA3060814042 Ref C: 2026-05-08T17:58:43Z' + status: + code: 500 + message: Internal Server Error +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account metrics-container create + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + ParameterSetName: + - --azure-monitor-workspace-name -g -n + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002/metricsContainers/default?api-version=2025-10-03 + response: + body: + string: '{"properties":{"version":"1.0"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_mc000001/providers/microsoft.monitor/accounts/ac000002/metricscontainers/default","name":"default","type":"Microsoft.Monitor/accounts/metricsContainers","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T17:58:49.0008255Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T17:58:49.0008255Z"}}' + headers: + api-supported-versions: + - 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '507' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:58:49 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/2a83dc62-818c-4088-abfd-4694cb9b8072 + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 18217992EAE7425CB12BD867DDB32CEE Ref B: CO1AA3060820029 Ref C: 2026-05-08T17:58:48Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account metrics-container show + Connection: + - keep-alive + ParameterSetName: + - --azure-monitor-workspace-name -g -n + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002/metricsContainers/default?api-version=2025-10-03 + response: + body: + string: '{"properties":{"version":"1.0"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_mc000001/providers/microsoft.monitor/accounts/ac000002/metricscontainers/default","name":"default","type":"Microsoft.Monitor/accounts/metricsContainers","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T17:58:49.0008255Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T17:58:49.0008255Z"}}' + headers: + api-supported-versions: + - 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '507' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:58:51 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/54ef2f86-748b-4b4d-bdc0-8d6ed789837a + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 5B749FDA6D8043F085600907BB0A761D Ref B: MWH011020806031 Ref C: 2026-05-08T17:58:51Z' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account metrics-container update + Connection: + - keep-alive + ParameterSetName: + - --azure-monitor-workspace-name -g -n + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002/metricsContainers/default?api-version=2025-10-03 + response: + body: + string: '{"properties":{"version":"1.0"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_mc000001/providers/microsoft.monitor/accounts/ac000002/metricscontainers/default","name":"default","type":"Microsoft.Monitor/accounts/metricsContainers","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T17:58:49.0008255Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T17:58:49.0008255Z"}}' + headers: + api-supported-versions: + - 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '507' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:58:51 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/a069eb74-8033-4c13-9533-75e837db6efe + x-ms-ratelimit-remaining-subscription-global-reads: + - '16499' + x-msedge-ref: + - 'Ref A: 48E6E2F5F3794BCE97DAF818337CC8D7 Ref B: CO1AA3060813031 Ref C: 2026-05-08T17:58:52Z' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"version": "1.0"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor account metrics-container update + Connection: + - keep-alive + Content-Length: + - '34' + Content-Type: + - application/json + ParameterSetName: + - --azure-monitor-workspace-name -g -n + User-Agent: + - AZURECLI/2.86.0 azsdk-python-core/1.39.0 Python/3.11.9 (Windows-10-10.0.26200-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor_account_mc000001/providers/Microsoft.Monitor/accounts/ac000002/metricsContainers/default?api-version=2025-10-03 + response: + body: + string: '{"properties":{"version":"1.0"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_monitor_account_mc000001/providers/microsoft.monitor/accounts/ac000002/metricscontainers/default","name":"default","type":"Microsoft.Monitor/accounts/metricsContainers","systemData":{"createdBy":"test@example.com","createdByType":"User","createdAt":"2026-05-08T17:58:49Z","lastModifiedBy":"test@example.com","lastModifiedByType":"User","lastModifiedAt":"2026-05-08T17:58:53.1970664Z"}}' + headers: + api-supported-versions: + - 2025-05-01-preview, 2025-05-03-preview, 2025-10-03-preview, 2025-10-03 + cache-control: + - no-cache + content-length: + - '499' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 May 2026 17:58:52 GMT + expires: + - '-1' + pragma: + - no-cache + request-context: + - appId=cid-v1:74683e7d-3ee8-4856-bfe7-e63c83b6737e + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-operation-identifier: + - tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47,objectId=1820de50-3eca-48a8-b72f-01a509abc8fe/westus/239c3f9b-dc0a-4a46-828e-212f6d3572ce + x-ms-ratelimit-remaining-subscription-global-writes: + - '11999' + x-ms-ratelimit-remaining-subscription-writes: + - '799' + x-msedge-ref: + - 'Ref A: 789AC1F4E95C4A65ACAE8138344A3E5A Ref B: CO6AA3150218017 Ref C: 2026-05-08T17:58:52Z' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py index ede1453badb..1b49f53f924 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_account.py @@ -3,6 +3,8 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +import unittest + from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer @@ -50,3 +52,86 @@ def test_monitor_account_new_params(self, resource_group): '--enable-access-using-resource-permissions false', checks=[ self.check('metrics.enableAccessUsingResourcePermissions', False) ]) + + @ResourceGroupPreparer(name_prefix='cli_test_monitor_account_id') + def test_monitor_account_identity(self, resource_group): + self.kwargs.update({ + 'account': self.create_random_name('ac', 10), + 'id_name': self.create_random_name('amid', 10) + }) + self.cmd('monitor account create -n {account} -g {rg}') + + # Assign system-assigned identity + self.cmd('monitor account identity assign -n {account} -g {rg} --system-assigned', checks=[ + self.check('type', 'systemAssigned') + ]) + self.cmd('monitor account identity show -n {account} -g {rg}', checks=[ + self.check('type', 'systemAssigned') + ]) + + # Remove system-assigned identity + self.cmd('monitor account identity remove -n {account} -g {rg} --system-assigned') + + # Assign user-assigned identity (AMW only supports one type at a time) + identity = self.cmd('identity create -n {id_name} -g {rg}').get_output_in_json() + self.kwargs['identity'] = identity['id'] + self.cmd('monitor account identity assign -n {account} -g {rg} --user-assigned {identity}', checks=[ + self.check('type', 'userAssigned'), + self.check('length(userAssignedIdentities)', 1) + ]) + + # Remove user-assigned identity + self.cmd('monitor account identity remove -n {account} -g {rg} --user-assigned {identity}') + + @ResourceGroupPreparer(name_prefix='cli_test_monitor_account_mc') + def test_monitor_account_metrics_container(self, resource_group): + self.kwargs.update({ + 'account': self.create_random_name('ac', 10) + }) + self.cmd('monitor account create -n {account} -g {rg}') + + # Create metrics container (name must be "default") + self.cmd('monitor account metrics-container create ' + '--azure-monitor-workspace-name {account} -g {rg} -n default', checks=[ + self.check('name', 'default') + ]) + self.cmd('monitor account metrics-container show ' + '--azure-monitor-workspace-name {account} -g {rg} -n default', checks=[ + self.check('name', 'default') + ]) + self.cmd('monitor account metrics-container update ' + '--azure-monitor-workspace-name {account} -g {rg} -n default', checks=[ + self.check('name', 'default') + ]) + + @unittest.skip('accounts/issues resource type requires preview API version (2025-10-03-preview), not supported in GA 2025-10-03') + @ResourceGroupPreparer(name_prefix='cli_test_monitor_account_issue') + def test_monitor_account_issue(self, resource_group): + self.kwargs.update({ + 'account': self.create_random_name('ac', 10), + 'issue': self.create_random_name('issue', 10) + }) + self.cmd('monitor account create -n {account} -g {rg}') + + # Create issue + self.cmd('monitor account issue create --azure-monitor-workspace-name {account} -g {rg} ' + '-n {issue} --title "Test Issue" --severity Low --status New', checks=[ + self.check('name', '{issue}'), + self.check('properties.title', 'Test Issue'), + self.check('properties.severity', 'Low'), + self.check('properties.status', 'New') + ]) + self.cmd('monitor account issue show --azure-monitor-workspace-name {account} -g {rg} ' + '-n {issue}', checks=[ + self.check('name', '{issue}') + ]) + self.cmd('monitor account issue list --azure-monitor-workspace-name {account} -g {rg}', checks=[ + self.check('length(@)', 1), + self.check('[0].name', '{issue}') + ]) + self.cmd('monitor account issue update --azure-monitor-workspace-name {account} -g {rg} ' + '-n {issue} --status InProgress', checks=[ + self.check('properties.status', 'InProgress') + ]) + self.cmd('monitor account issue delete --azure-monitor-workspace-name {account} -g {rg} ' + '-n {issue} -y') From a774af799c0b68f6caa55fe55b8b9abd9a96b117 Mon Sep 17 00:00:00 2001 From: GokulPrasad KrishnaSwamy Date: Fri, 8 May 2026 11:52:39 -0700 Subject: [PATCH 4/5] {Monitor} Fix linter errors: add short alias for --azure-monitor-workspace-name and add command examples --- .../monitor/aaz/latest/monitor/account/identity/_assign.py | 6 ++++++ .../monitor/account/issue/_add_investigation_result.py | 3 +++ .../latest/monitor/account/issue/_add_or_update_alert.py | 3 +++ .../latest/monitor/account/issue/_add_or_update_resource.py | 3 +++ .../monitor/aaz/latest/monitor/account/issue/_create.py | 3 +++ .../account/issue/_fetch_background_visualization.py | 3 +++ .../monitor/account/issue/_fetch_investigation_result.py | 3 +++ .../monitor/account/issue/_set_background_visualization.py | 3 +++ .../monitor/aaz/latest/monitor/account/issue/_update.py | 3 +++ .../aaz/latest/monitor/account/metrics_container/_create.py | 5 ++++- .../aaz/latest/monitor/account/metrics_container/_list.py | 2 +- .../aaz/latest/monitor/account/metrics_container/_show.py | 2 +- .../aaz/latest/monitor/account/metrics_container/_update.py | 5 ++++- 13 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py index ca3cc706bd9..b4265f43709 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/identity/_assign.py @@ -16,6 +16,12 @@ ) class Assign(AAZCommand): """Assign the user or system managed identities. + + :example: Assign a system-assigned managed identity to an Azure Monitor workspace + az monitor account identity assign -n myWorkspace -g myRG --system-assigned + + :example: Assign a user-assigned managed identity to an Azure Monitor workspace + az monitor account identity assign -n myWorkspace -g myRG --user-assigned /subscriptions/sub/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py index ef4a9de6daa..1b4fe81987a 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py @@ -16,6 +16,9 @@ ) class AddInvestigationResult(AAZCommand): """Adds investigation result + + :example: Add an investigation result to an issue + az monitor account issue add-investigation-result --azure-monitor-workspace-name myWorkspace -g myRG --issue-name myIssue --text "Investigation findings" --id 00000000-0000-0000-0000-000000000000 """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py index 4a742582b23..e80ecdaf9e0 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py @@ -16,6 +16,9 @@ ) class AddOrUpdateAlert(AAZCommand): """Add or update alerts in the issue + + :example: Add an alert to an issue + az monitor account issue add-or-update-alert --azure-monitor-workspace-name myWorkspace -g myRG --issue-name myIssue --value "[{\"id\": \"/subscriptions/sub/resourceGroups/rg/providers/Microsoft.AlertsManagement/alerts/alert1\"}]" """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py index a90e13488e6..0776436014d 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py @@ -16,6 +16,9 @@ ) class AddOrUpdateResource(AAZCommand): """Add or update resources in the issue + + :example: Add a resource to an issue + az monitor account issue add-or-update-resource --azure-monitor-workspace-name myWorkspace -g myRG --issue-name myIssue --value "[{\"id\": \"/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Compute/virtualMachines/vm1\"}]" """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py index bfe54b9655a..74c2d622cfb 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py @@ -16,6 +16,9 @@ ) class Create(AAZCommand): """Create a new issue or updates an existing one + + :example: Create a new issue in an Azure Monitor workspace + az monitor account issue create --azure-monitor-workspace-name myWorkspace -g myRG -n myIssue --title "My Issue" --severity High --status New """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py index 175b62aaca5..8a71f0818b4 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py @@ -16,6 +16,9 @@ ) class FetchBackgroundVisualization(AAZCommand): """Fetch the background visualization of the issue + + :example: Fetch the background visualization for an issue + az monitor account issue fetch-background-visualization --azure-monitor-workspace-name myWorkspace -g myRG --issue-name myIssue """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py index 37a76bb2deb..86b4b2d93e4 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py @@ -16,6 +16,9 @@ ) class FetchInvestigationResult(AAZCommand): """Fetch investigation result + + :example: Fetch the investigation result for an issue + az monitor account issue fetch-investigation-result --azure-monitor-workspace-name myWorkspace -g myRG --issue-name myIssue --investigation-id 00000000-0000-0000-0000-000000000000 """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py index 17d3d65d618..26e19ffaa67 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py @@ -16,6 +16,9 @@ ) class SetBackgroundVisualization(AAZCommand): """Set the background visualization for the issue + + :example: Set the background visualization for an issue + az monitor account issue set-background-visualization --azure-monitor-workspace-name myWorkspace -g myRG --issue-name myIssue --visualization "{\"type\":\"AdaptiveCard\"}" """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py index 67f803bf493..60622b626bf 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py @@ -16,6 +16,9 @@ ) class Update(AAZCommand): """Update a new issue or updates an existing one + + :example: Update the status and severity of an issue + az monitor account issue update --azure-monitor-workspace-name myWorkspace -g myRG -n myIssue --status InProgress --severity High """ _aaz_info = { diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py index 5be22320fa9..5a032c95dcd 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_create.py @@ -16,6 +16,9 @@ ) class Create(AAZCommand): """Create metrics container settings for a monitoring account. + + :example: Create the default metrics container for an Azure Monitor workspace + az monitor account metrics-container create -w myWorkspace -g myRG -n default """ _aaz_info = { @@ -42,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, fmt=AAZStrArgFormat( diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.py index c11acb61452..92232073500 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_list.py @@ -43,7 +43,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, fmt=AAZStrArgFormat( diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py index 948bd458421..df88e62f3b0 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_show.py @@ -42,7 +42,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py index 5b56f837375..28227e9aa2c 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/metrics_container/_update.py @@ -16,6 +16,9 @@ ) class Update(AAZCommand): """Update metrics container settings for a monitoring account. + + :example: Update the metrics container version for an Azure Monitor workspace + az monitor account metrics-container update -w myWorkspace -g myRG -n default --version 2 """ _aaz_info = { @@ -44,7 +47,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", From 94c0d2508af46bf478796df3fefdd233cb8f4d77 Mon Sep 17 00:00:00 2001 From: GokulPrasad KrishnaSwamy Date: Mon, 11 May 2026 12:11:07 -0700 Subject: [PATCH 5/5] {Monitor} Fix linter error: add -w short alias for --azure-monitor-workspace-name in issue commands --- .../latest/monitor/account/issue/_add_investigation_result.py | 2 +- .../aaz/latest/monitor/account/issue/_add_or_update_alert.py | 2 +- .../aaz/latest/monitor/account/issue/_add_or_update_resource.py | 2 +- .../monitor/aaz/latest/monitor/account/issue/_create.py | 2 +- .../monitor/aaz/latest/monitor/account/issue/_delete.py | 2 +- .../monitor/account/issue/_fetch_background_visualization.py | 2 +- .../latest/monitor/account/issue/_fetch_investigation_result.py | 2 +- .../monitor/aaz/latest/monitor/account/issue/_list.py | 2 +- .../monitor/aaz/latest/monitor/account/issue/_list_alert.py | 2 +- .../monitor/aaz/latest/monitor/account/issue/_list_resource.py | 2 +- .../monitor/account/issue/_set_background_visualization.py | 2 +- .../monitor/aaz/latest/monitor/account/issue/_show.py | 2 +- .../monitor/aaz/latest/monitor/account/issue/_update.py | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py index 1b4fe81987a..d5650b72522 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_investigation_result.py @@ -45,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py index e80ecdaf9e0..b44e1dbdd84 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_alert.py @@ -45,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py index 0776436014d..57f2d149358 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_add_or_update_resource.py @@ -45,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py index 74c2d622cfb..3cce3ef54cd 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_create.py @@ -45,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, fmt=AAZStrArgFormat( diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py index 497205e3427..a4673aa3c57 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_delete.py @@ -43,7 +43,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py index 8a71f0818b4..e15a6ad4532 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_background_visualization.py @@ -45,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py index 86b4b2d93e4..1312e26ce17 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_fetch_investigation_result.py @@ -45,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py index 0d2e59e933b..0b7e16f3dd7 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list.py @@ -43,7 +43,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, fmt=AAZStrArgFormat( diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py index 5ffc7188a9c..0271cf256ee 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_alert.py @@ -42,7 +42,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py index c7fa662dd03..1cbd009b99f 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_list_resource.py @@ -42,7 +42,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py index 26e19ffaa67..eebe2ac2e8b 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_set_background_visualization.py @@ -45,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py index be4cdee32e1..6b8edabe0a5 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_show.py @@ -42,7 +42,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name", diff --git a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py index 60622b626bf..0a557713bcb 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/account/issue/_update.py @@ -47,7 +47,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema = cls._args_schema _args_schema.azure_monitor_workspace_name = AAZStrArg( - options=["--azure-monitor-workspace-name"], + options=["-w", "--azure-monitor-workspace-name"], help="The name of the Azure Monitor Workspace. The name is case insensitive", required=True, id_part="name",