From b0f7e30cb0ddacc78beb450d14ad8880dc1b29d7 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 31 Dec 2019 14:43:55 +0800 Subject: [PATCH 01/41] Initial commit --- src/alertsmanagement/HISTORY.rst | 8 + src/alertsmanagement/README.rst | 5 + .../azext_alertsmanagement/__init__.py | 32 + .../azext_alertsmanagement/_client_factory.py | 30 + .../azext_alertsmanagement/_help.py | 238 +++ .../azext_alertsmanagement/_params.py | 162 ++ .../azext_alertsmanagement/_validators.py | 18 + .../azext_metadata.json | 5 + .../azext_alertsmanagement/commands.py | 64 + .../azext_alertsmanagement/custom.py | 235 +++ .../latest/test_alertsmanagement_scenario.py | 124 ++ .../alertsmanagement/__init__.py | 19 + .../_alerts_management_client.py | 68 + .../alertsmanagement/_configuration.py | 48 + .../alertsmanagement/models/__init__.py | 188 ++ .../models/_alerts_management_client_enums.py | 157 ++ .../alertsmanagement/models/_models.py | 1704 +++++++++++++++++ .../alertsmanagement/models/_models_py3.py | 1704 +++++++++++++++++ .../alertsmanagement/models/_paged_models.py | 79 + .../alertsmanagement/operations/__init__.py | 24 + .../operations/_action_rules_operations.py | 575 ++++++ .../operations/_alerts_operations.py | 582 ++++++ .../operations/_operations.py | 103 + .../_smart_detector_alert_rules_operations.py | 436 +++++ .../operations/_smart_groups_operations.py | 365 ++++ .../vendored_sdks/alertsmanagement/version.py | 13 + src/alertsmanagement/setup.cfg | 2 + src/alertsmanagement/setup.py | 60 + 28 files changed, 7048 insertions(+) create mode 100644 src/alertsmanagement/HISTORY.rst create mode 100644 src/alertsmanagement/README.rst create mode 100644 src/alertsmanagement/azext_alertsmanagement/__init__.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/_client_factory.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/_help.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/_params.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/_validators.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/azext_metadata.json create mode 100644 src/alertsmanagement/azext_alertsmanagement/commands.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/custom.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/__init__.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_alerts_management_client.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_configuration.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/__init__.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_alerts_management_client_enums.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models_py3.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_paged_models.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/__init__.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_action_rules_operations.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_alerts_operations.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_operations.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_detector_alert_rules_operations.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_groups_operations.py create mode 100644 src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/version.py create mode 100644 src/alertsmanagement/setup.cfg create mode 100644 src/alertsmanagement/setup.py diff --git a/src/alertsmanagement/HISTORY.rst b/src/alertsmanagement/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /dev/null +++ b/src/alertsmanagement/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/alertsmanagement/README.rst b/src/alertsmanagement/README.rst new file mode 100644 index 00000000000..6e0cde7f019 --- /dev/null +++ b/src/alertsmanagement/README.rst @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'alertsmanagement' Extension +========================================== + +This package is for the 'alertsmanagement' extension. +i.e. 'az alertsmanagement' diff --git a/src/alertsmanagement/azext_alertsmanagement/__init__.py b/src/alertsmanagement/azext_alertsmanagement/__init__.py new file mode 100644 index 00000000000..badfa0fcead --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/__init__.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader + +from azext_alertsmanagement._help import helps # pylint: disable=unused-import + + +class AlertsCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_alertsmanagement._client_factory import cf_alertsmanagement + alertsmanagement_custom = CliCommandType( + operations_tmpl='azext_alertsmanagement.custom#{}', + client_factory=cf_alertsmanagement) + super(AlertsCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=alertsmanagement_custom) + + def load_command_table(self, args): + from azext_alertsmanagement.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_alertsmanagement._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = AlertsCommandsLoader diff --git a/src/alertsmanagement/azext_alertsmanagement/_client_factory.py b/src/alertsmanagement/azext_alertsmanagement/_client_factory.py new file mode 100644 index 00000000000..b7baf9f6e79 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/_client_factory.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def cf_alertsmanagement(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from .vendored_sdks.alertsmanagement import AlertsManagementClient + return get_mgmt_service_client(cli_ctx, AlertsManagementClient) + + +def cf_operations(cli_ctx, *_): + return cf_alertsmanagement(cli_ctx).operations + + +def cf_alerts(cli_ctx, *_): + return cf_alertsmanagement(cli_ctx).alerts + + +def cf_smart_groups(cli_ctx, *_): + return cf_alertsmanagement(cli_ctx).smart_groups + + +def cf_action_rules(cli_ctx, *_): + return cf_alertsmanagement(cli_ctx).action_rules + + +def cf_smart_detector_alert_rules(cli_ctx, *_): + return cf_alertsmanagement(cli_ctx).smart_detector_alert_rules diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py new file mode 100644 index 00000000000..0ae885224a2 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -0,0 +1,238 @@ +# coding=utf-8 +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=line-too-long +from knack.help_files import helps # pylint: disable=unused-import + + +helps['alertsmanagement'] = """ + type: group + short-summary: Commands to manage alertsmanagement. +""" + +helps['alertsmanagement list'] = """ + type: command + short-summary: List all operations available through Azure Alerts Management Resource Provider. +""" + +helps['alertsmanagement changestate'] = """ + type: group + short-summary: Commands to manage alertsmanagement changestate. +""" + +helps['alertsmanagement changestate change_state'] = """ + type: command + short-summary: Change the state of an alert. + examples: + - name: Resolve + text: |- + az alertsmanagement changestate change_state --alert-id \\ + "66114d64-d9d9-478b-95c9-b789d6502100" --new-state "Acknowledged" +""" + +helps['alertsmanagement changestate meta_data'] = """ + type: command + short-summary: List alerts meta data information based on value of identifier parameter. + examples: + - name: MonService + text: |- + az alertsmanagement changestate meta_data --identifier "MonitorServiceList" +""" + +helps['alertsmanagement changestate get_all'] = """ + type: command + short-summary: List all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. time range). The results can then be sorted on the basis specific fields, with the default being lastModifiedDateTime. + examples: + - name: ListAlerts + text: |- + az alertsmanagement changestate get_all +""" + +helps['alertsmanagement changestate get_by_id'] = """ + type: command + short-summary: Get information related to a specific alert + examples: + - name: GetById + text: |- + az alertsmanagement changestate get_by_id --alert-id \\ + "66114d64-d9d9-478b-95c9-b789d6502100" +""" + +helps['alertsmanagement changestate get_history'] = """ + type: command + short-summary: Get the history of an alert, which captures any monitor condition changes (Fired/Resolved) and alert state changes (New/Acknowledged/Closed). + examples: + - name: Resolve + text: |- + az alertsmanagement changestate get_history --alert-id \\ + "66114d64-d9d9-478b-95c9-b789d6502100" +""" + +helps['alertsmanagement changestate get_summary'] = """ + type: command + short-summary: Get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns the count of alerts for each severity). + examples: + - name: Summary + text: |- + az alertsmanagement changestate get_summary --groupby "severity,alertState" +""" + +helps['alertsmanagement change-state'] = """ + type: group + short-summary: Commands to manage alertsmanagement change state. +""" + +helps['alertsmanagement change-state change_state'] = """ + type: command + short-summary: Change the state of a Smart Group. + examples: + - name: changestate + text: |- + az alertsmanagement change-state change_state --smart-group-id \\ + "a808445e-bb38-4751-85c2-1b109ccc1059" --new-state "Acknowledged" +""" + +helps['alertsmanagement change-state get_all'] = """ + type: command + short-summary: List all the Smart Groups within a specified subscription. + examples: + - name: List + text: |- + az alertsmanagement change-state get_all +""" + +helps['alertsmanagement change-state get_by_id'] = """ + type: command + short-summary: Get information related to a specific Smart Group. + examples: + - name: Get + text: |- + az alertsmanagement change-state get_by_id --smart-group-id \\ + "603675da-9851-4b26-854a-49fc53d32715" +""" + +helps['alertsmanagement change-state get_history'] = """ + type: command + short-summary: Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) . + examples: + - name: Resolve + text: |- + az alertsmanagement change-state get_history --smart-group-id \\ + "a808445e-bb38-4751-85c2-1b109ccc1059" +""" + +helps['alertsmanagement'] = """ + type: group + short-summary: Commands to manage alertsmanagement. +""" + +helps['alertsmanagement create'] = """ + type: command + short-summary: Creates/Updates a specific action rule + examples: + - name: PutActionRule + text: |- + az alertsmanagement create --resource-group "alertscorrelationrg" --name \\ + "DailySuppression" --location "Global" --status "Enabled" +""" + +helps['alertsmanagement update'] = """ + type: command + short-summary: Creates/Updates a specific action rule + examples: + - name: PatchActionRule + text: |- + az alertsmanagement update --resource-group "alertscorrelationrg" --name \\ + "WeeklySuppression" --status "Disabled" +""" + +helps['alertsmanagement delete'] = """ + type: command + short-summary: Deletes a given action rule + examples: + - name: DeleteActionRule + text: |- + az alertsmanagement delete --resource-group "alertscorrelationrg" --name \\ + "DailySuppression" +""" + +helps['alertsmanagement show'] = """ + type: command + short-summary: Get a specific action rule + examples: + - name: GetActionRuleById + text: |- + az alertsmanagement show --resource-group "alertscorrelationrg" --name "DailySuppression" +""" + +helps['alertsmanagement list'] = """ + type: command + short-summary: List all action rules of the subscription, created in given resource group and given input filters + examples: + - name: GetActionRulesSubscriptionWide + text: |- + az alertsmanagement list + - name: GetActionRulesResourceGroupWide + text: |- + az alertsmanagement list --resource-group "alertscorrelationrg" +""" + +helps['alertsmanagement'] = """ + type: group + short-summary: Commands to manage alertsmanagement. +""" + +helps['alertsmanagement create'] = """ + type: command + short-summary: Create or update a Smart Detector alert rule. + examples: + - name: Create or update a Smart Detector alert rule + text: |- + az alertsmanagement create --resource-group "MyAlertRules" --name "MyAlertRule" \\ + --description "Sample smart detector alert rule description" --state "Enabled" --severity \\ + "Sev3" --frequency "PT5M" +""" + +helps['alertsmanagement update'] = """ + type: command + short-summary: Create or update a Smart Detector alert rule. + examples: + - name: Patch alert rules + text: |- + az alertsmanagement update --resource-group "MyAlertRules" --name "MyAlertRule" \\ + --description "New description for patching" --frequency "PT1M" +""" + +helps['alertsmanagement delete'] = """ + type: command + short-summary: Delete an existing Smart Detector alert rule. + examples: + - name: Delete a Smart Detector alert rule + text: |- + az alertsmanagement delete --resource-group "MyAlertRules" --name "MyAlertRule" +""" + +helps['alertsmanagement show'] = """ + type: command + short-summary: Get a specific Smart Detector alert rule. + examples: + - name: Get a Smart Detector alert rule + text: |- + az alertsmanagement show --resource-group "MyAlertRules" --name "MyAlertRule" +""" + +helps['alertsmanagement list'] = """ + type: command + short-summary: List all the existing Smart Detector alert rules within the subscription and resource group. + examples: + - name: List Smart Detector alert rules + text: |- + az alertsmanagement list --resource-group "MyAlertRules" + - name: List alert rules + text: |- + az alertsmanagement list --resource-group "MyAlertRules" +""" diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py new file mode 100644 index 00000000000..f08e5bfe4ac --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -0,0 +1,162 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=line-too-long +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + tags_type, + get_three_state_flag, + get_enum_type, + resource_group_name_type, + get_location_type +) + + +def load_arguments(self, _): + + with self.argument_context('alertsmanagement list') as c: + pass + + with self.argument_context('alertsmanagement changestate change_state') as c: + c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') + c.argument('new_state', id_part=None, help='New state of the alert.') + + with self.argument_context('alertsmanagement changestate meta_data') as c: + c.argument('identifier', id_part=None, help='Identification of the information to be retrieved by API call.') + + with self.argument_context('alertsmanagement changestate get_all') as c: + c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') + c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') + c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') + c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') + c.argument('monitor_condition', id_part=None, help='Filter by monitor condition which is either \'Fired\' or \'Resolved\'. Default value is to select all.') + c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') + c.argument('alert_state', id_part=None, help='Filter by state of the alert instance. Default value is to select all.') + c.argument('alert_rule', id_part=None, help='Filter by specific alert rule. Default value is to select all.') + c.argument('smart_group_id', id_part=None, help='Filter the alerts list by the Smart Group Id. Default value is none.') + c.argument('include_context', arg_type=get_three_state_flag(), id_part=None, help='Include context which has contextual data specific to the monitor service. Default value is false\'') + c.argument('include_egress_config', arg_type=get_three_state_flag(), id_part=None, help='Include egress config which would be used for displaying the content in portal. Default value is \'false\'.') + c.argument('page_count', id_part=None, help='Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25.') + c.argument('sort_by', id_part=None, help='Sort the query results by input field, Default value is \'lastModifiedDateTime\'.') + c.argument('sort_order', id_part=None, help='Sort the query results order in either ascending or descending. Default value is \'desc\' for time fields and \'asc\' for others.') + c.argument('select', id_part=None, help='This filter allows to selection of the fields(comma separated) which would be part of the essential section. This would allow to project only the required fields rather than getting entire content. Default is to fetch all the fields in the essentials section.') + c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') + c.argument('custom_time_range', id_part=None, help='Filter by custom time range in the format / where time is in (ISO-8601 format)\'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none.') + + with self.argument_context('alertsmanagement changestate get_by_id') as c: + c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') + + with self.argument_context('alertsmanagement changestate get_history') as c: + c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') + + with self.argument_context('alertsmanagement changestate get_summary') as c: + c.argument('groupby', id_part=None, help='This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). For example, groupby=severity or groupby=severity,alertstate.') + c.argument('include_smart_groups_count', arg_type=get_three_state_flag(), id_part=None, help='Include count of the SmartGroups as part of the summary. Default value is \'false\'.') + c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') + c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') + c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') + c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') + c.argument('monitor_condition', id_part=None, help='Filter by monitor condition which is either \'Fired\' or \'Resolved\'. Default value is to select all.') + c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') + c.argument('alert_state', id_part=None, help='Filter by state of the alert instance. Default value is to select all.') + c.argument('alert_rule', id_part=None, help='Filter by specific alert rule. Default value is to select all.') + c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') + c.argument('custom_time_range', id_part=None, help='Filter by custom time range in the format / where time is in (ISO-8601 format)\'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none.') + + with self.argument_context('alertsmanagement change-state change_state') as c: + c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') + c.argument('new_state', id_part=None, help='New state of the alert.') + + with self.argument_context('alertsmanagement change-state get_all') as c: + c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') + c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') + c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') + c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') + c.argument('monitor_condition', id_part=None, help='Filter by monitor condition which is either \'Fired\' or \'Resolved\'. Default value is to select all.') + c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') + c.argument('smart_group_state', id_part=None, help='Filter by state of the smart group. Default value is to select all.') + c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') + c.argument('page_count', id_part=None, help='Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25.') + c.argument('sort_by', id_part=None, help='Sort the query results by input field. Default value is sort by \'lastModifiedDateTime\'.') + c.argument('sort_order', id_part=None, help='Sort the query results order in either ascending or descending. Default value is \'desc\' for time fields and \'asc\' for others.') + + with self.argument_context('alertsmanagement change-state get_by_id') as c: + c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') + + with self.argument_context('alertsmanagement change-state get_history') as c: + c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') + + with self.argument_context('alertsmanagement create') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name that needs to be updated') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('tags', tags_type) + c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') + + with self.argument_context('alertsmanagement update') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name that needs to be updated') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('tags', tags_type) + c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') + + with self.argument_context('alertsmanagement delete') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name that needs to be updated') + + with self.argument_context('alertsmanagement show') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name that needs to be updated') + + with self.argument_context('alertsmanagement list') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') + c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') + c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') + c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') + c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') + c.argument('impacted_scope', id_part=None, help='filter by impacted/target scope (provide comma separated list for multiple scopes). The value should be an well constructed ARM id of the scope.') + c.argument('description', id_part=None, help='filter by alert rule description') + c.argument('alert_rule_id', id_part=None, help='filter by alert rule id') + c.argument('action_group', id_part=None, help='filter by action group configured as part of action rule') + c.argument('name', id_part=None, help='filter by action rule name') + + with self.argument_context('alertsmanagement create') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the alert rule.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('tags', tags_type) + c.argument('description', id_part=None, help='The alert rule description.') + c.argument('state', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='The alert rule state.') + c.argument('severity', arg_type=get_enum_type(['Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4']), id_part=None, help='The alert rule severity.') + c.argument('frequency', id_part=None, help='The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.') + c.argument('action_groups', id_part=None, help='The alert rule actions.') + c.argument('throttling', id_part=None, help='The alert rule throttling information.') + + with self.argument_context('alertsmanagement update') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the alert rule.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('tags', tags_type) + c.argument('description', id_part=None, help='The alert rule description.') + c.argument('state', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='The alert rule state.') + c.argument('severity', arg_type=get_enum_type(['Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4']), id_part=None, help='The alert rule severity.') + c.argument('frequency', id_part=None, help='The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.') + c.argument('action_groups', id_part=None, help='The alert rule actions.') + c.argument('throttling', id_part=None, help='The alert rule throttling information.') + + with self.argument_context('alertsmanagement delete') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the alert rule.') + + with self.argument_context('alertsmanagement show') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the alert rule.') + c.argument('expand_detector', arg_type=get_three_state_flag(), id_part=None, help='Indicates if Smart Detector should be expanded.') + + with self.argument_context('alertsmanagement list') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('expand_detector', arg_type=get_three_state_flag(), id_part=None, help='Indicates if Smart Detector should be expanded.') diff --git a/src/alertsmanagement/azext_alertsmanagement/_validators.py b/src/alertsmanagement/azext_alertsmanagement/_validators.py new file mode 100644 index 00000000000..01e8fe71d5a --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/_validators.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json new file mode 100644 index 00000000000..4060dd78264 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json @@ -0,0 +1,5 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.0.67", + "azext.maxCliCoreVersion": "2.1.0" +} \ No newline at end of file diff --git a/src/alertsmanagement/azext_alertsmanagement/commands.py b/src/alertsmanagement/azext_alertsmanagement/commands.py new file mode 100644 index 00000000000..3067e4d56b2 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/commands.py @@ -0,0 +1,64 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from ._client_factory import cf_operations + alertsmanagement_operations = CliCommandType( + operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._operations_operations#OperationsOperations.{}', + client_factory=cf_operations) + with self.command_group('alertsmanagement', alertsmanagement_operations, client_factory=cf_operations) as g: + g.custom_command('list', 'list_alertsmanagement') + + from ._client_factory import cf_alerts + alertsmanagement_alerts = CliCommandType( + operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._alerts_operations#AlertsOperations.{}', + client_factory=cf_alerts) + with self.command_group('alertsmanagement changestate', alertsmanagement_alerts, client_factory=cf_alerts) as g: + g.custom_command('change_state', 'change_state_alertsmanagement_changestate') + g.custom_command('meta_data', 'meta_data_alertsmanagement_changestate') + g.custom_command('get_all', 'get_all_alertsmanagement_changestate') + g.custom_command('get_by_id', 'get_by_id_alertsmanagement_changestate') + g.custom_command('get_history', 'get_history_alertsmanagement_changestate') + g.custom_command('get_summary', 'get_summary_alertsmanagement_changestate') + + from ._client_factory import cf_smart_groups + alertsmanagement_smart_groups = CliCommandType( + operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._smart_groups_operations#SmartGroupsOperations.{}', + client_factory=cf_smart_groups) + with self.command_group('alertsmanagement change-state', alertsmanagement_smart_groups, client_factory=cf_smart_groups) as g: + g.custom_command('change_state', 'change_state_alertsmanagement_change_state') + g.custom_command('get_all', 'get_all_alertsmanagement_change_state') + g.custom_command('get_by_id', 'get_by_id_alertsmanagement_change_state') + g.custom_command('get_history', 'get_history_alertsmanagement_change_state') + + from ._client_factory import cf_action_rules + alertsmanagement_action_rules = CliCommandType( + operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._action_rules_operations#ActionRulesOperations.{}', + client_factory=cf_action_rules) + with self.command_group('alertsmanagement', alertsmanagement_action_rules, client_factory=cf_action_rules) as g: + g.custom_command('create', 'create_alertsmanagement') + g.custom_command('update', 'update_alertsmanagement') + g.custom_command('delete', 'delete_alertsmanagement') + g.custom_command('show', 'get_alertsmanagement') + g.custom_command('list', 'list_alertsmanagement') + + from ._client_factory import cf_smart_detector_alert_rules + alertsmanagement_smart_detector_alert_rules = CliCommandType( + operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._smart_detector_alert_rules_operations#SmartDetectorAlertRulesOperations.{}', + client_factory=cf_smart_detector_alert_rules) + with self.command_group('alertsmanagement', alertsmanagement_smart_detector_alert_rules, client_factory=cf_smart_detector_alert_rules) as g: + g.custom_command('create', 'create_alertsmanagement') + g.custom_command('update', 'update_alertsmanagement') + g.custom_command('delete', 'delete_alertsmanagement') + g.custom_command('show', 'get_alertsmanagement') + g.custom_command('list', 'list_alertsmanagement') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py new file mode 100644 index 00000000000..685dc27518a --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -0,0 +1,235 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=line-too-long +# pylint: disable=too-many-statements +# pylint: disable=too-many-lines +# pylint: disable=too-many-locals +# pylint: disable=unused-argument + + +def list_alertsmanagement(cmd, client): + return client.list() + + +def change_state_alertsmanagement_changestate(cmd, client, + alert_id, + new_state=None): + return client.change_state(alert_id=alert_id, new_state=new_state) + + +def meta_data_alertsmanagement_changestate(cmd, client, + identifier=None): + return client.meta_data(identifier=identifier) + + +def get_all_alertsmanagement_changestate(cmd, client, + target_resource=None, + target_resource_type=None, + target_resource_group=None, + monitor_service=None, + monitor_condition=None, + severity=None, + alert_state=None, + alert_rule=None, + smart_group_id=None, + include_context=None, + include_egress_config=None, + page_count=None, + sort_by=None, + sort_order=None, + select=None, + time_range=None, + custom_time_range=None): + return client.get_all(target_resource=target_resource, target_resource_type=target_resource_type, target_resource_group=target_resource_group, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, alert_rule=alert_rule, smart_group_id=smart_group_id, include_context=include_context, include_egress_config=include_egress_config, page_count=page_count, sort_by=sort_by, sort_order=sort_order, select=select, time_range=time_range, custom_time_range=custom_time_range) + + +def get_by_id_alertsmanagement_changestate(cmd, client, + alert_id): + return client.get_by_id(alert_id=alert_id) + + +def get_history_alertsmanagement_changestate(cmd, client, + alert_id): + return client.get_history(alert_id=alert_id) + + +def get_summary_alertsmanagement_changestate(cmd, client, + groupby=None, + include_smart_groups_count=None, + target_resource=None, + target_resource_type=None, + target_resource_group=None, + monitor_service=None, + monitor_condition=None, + severity=None, + alert_state=None, + alert_rule=None, + time_range=None, + custom_time_range=None): + return client.get_summary(groupby=groupby, include_smart_groups_count=include_smart_groups_count, target_resource=target_resource, target_resource_type=target_resource_type, target_resource_group=target_resource_group, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, alert_rule=alert_rule, time_range=time_range, custom_time_range=custom_time_range) + + +def change_state_alertsmanagement_change_state(cmd, client, + smart_group_id, + new_state=None): + return client.change_state(smart_group_id=smart_group_id, new_state=new_state) + + +def get_all_alertsmanagement_change_state(cmd, client, + target_resource=None, + target_resource_group=None, + target_resource_type=None, + monitor_service=None, + monitor_condition=None, + severity=None, + smart_group_state=None, + time_range=None, + page_count=None, + sort_by=None, + sort_order=None): + return client.get_all(target_resource=target_resource, target_resource_group=target_resource_group, target_resource_type=target_resource_type, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, smart_group_state=smart_group_state, time_range=time_range, page_count=page_count, sort_by=sort_by, sort_order=sort_order) + + +def get_by_id_alertsmanagement_change_state(cmd, client, + smart_group_id): + return client.get_by_id(smart_group_id=smart_group_id) + + +def get_history_alertsmanagement_change_state(cmd, client, + smart_group_id): + return client.get_history(smart_group_id=smart_group_id) + + +def create_alertsmanagement(cmd, client, + resource_group, + name, + location, + tags=None, + status=None): + body = {} + body['location'] = location # str + body['tags'] = tags # unknown-primary[object] + body['status'] = status # str + return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) + + +def update_alertsmanagement(cmd, client, + resource_group, + name, + location=None, + tags=None, + status=None): + body = client.get_by_name(resource_group_name=resource_group, action_rule_name=name).as_dict() + if location is not None: + body['location'] = location # str + if tags is not None: + body['tags'] = tags # unknown-primary[object] + if status is not None: + body['status'] = status # str + return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) + + +def delete_alertsmanagement(cmd, client, + resource_group, + name): + return client.delete(resource_group_name=resource_group, action_rule_name=name) + + +def get_alertsmanagement(cmd, client, + resource_group, + name): + return client.get_by_name(resource_group_name=resource_group, action_rule_name=name) + + +def list_alertsmanagement(cmd, client, + resource_group, + target_resource_group=None, + target_resource_type=None, + target_resource=None, + severity=None, + monitor_service=None, + impacted_scope=None, + description=None, + alert_rule_id=None, + action_group=None, + name=None): + if resource_group is not None and target_resource_group is not None and target_resource_type is not None and target_resource is not None and severity is not None and monitor_service is not None and impacted_scope is not None and description is not None and alert_rule_id is not None and action_group is not None and name is not None: + return client.list_by_resource_group(resource_group_name=resource_group, target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) + return client.list_by_subscription(target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) + + +def create_alertsmanagement(cmd, client, + resource_group, + name, + location=None, + tags=None, + description=None, + state=None, + severity=None, + frequency=None, + action_groups=None, + throttling=None): + body = {} + body['location'] = location # str + body['tags'] = tags # unknown-primary[object] + body['description'] = description # str + body['state'] = state # str + body['severity'] = severity # str + body['frequency'] = frequency # unknown-primary[timeSpan] + body['action_groups'] = json.loads(action_groups) if isinstance(action_groups, str) else action_groups + body['throttling'] = json.loads(throttling) if isinstance(throttling, str) else throttling + return client.create_or_update(resource_group_name=resource_group, alert_rule_name=name, parameters=body) + + +def update_alertsmanagement(cmd, client, + resource_group, + name, + location=None, + tags=None, + description=None, + state=None, + severity=None, + frequency=None, + action_groups=None, + throttling=None): + body = client.get(resource_group_name=resource_group, alert_rule_name=name, expand_detector=expand_detector).as_dict() + if location is not None: + body['location'] = location # str + if tags is not None: + body['tags'] = tags # unknown-primary[object] + if description is not None: + body['description'] = description # str + if state is not None: + body['state'] = state # str + if severity is not None: + body['severity'] = severity # str + if frequency is not None: + body['frequency'] = frequency # unknown-primary[timeSpan] + if action_groups is not None: + body['action_groups'] = json.loads(action_groups) if isinstance(action_groups, str) else action_groups + if throttling is not None: + body['throttling'] = json.loads(throttling) if isinstance(throttling, str) else throttling + return client.create_or_update(resource_group_name=resource_group, alert_rule_name=name, parameters=body) + + +def delete_alertsmanagement(cmd, client, + resource_group, + name): + return client.delete(resource_group_name=resource_group, alert_rule_name=name) + + +def get_alertsmanagement(cmd, client, + resource_group, + name, + expand_detector=None): + return client.get(resource_group_name=resource_group, alert_rule_name=name, expand_detector=expand_detector) + + +def list_alertsmanagement(cmd, client, + resource_group, + expand_detector=None): + if resource_group is not None and expand_detector is not None: + return client.list_by_resource_group(resource_group_name=resource_group, expand_detector=expand_detector) + return client.list(expand_detector=expand_detector) diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py new file mode 100644 index 00000000000..28fc5b76b5c --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -0,0 +1,124 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import unittest + +from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +class AlertsScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement') + def test_alertsmanagement(self, resource_group): + + self.kwargs.update({ + 'name': 'test1' + }) + + self.cmd('az alertsmanagement create ' + '--resource-group {rg} ' + '--name "DailySuppression" ' + '--location "Global" ' + '--status "Enabled"', + checks=[]) + + self.cmd('az alertsmanagement create ' + '--resource-group {rg} ' + '--name "MyAlertRule" ' + '--description "Sample smart detector alert rule description" ' + '--state "Enabled" ' + '--severity "Sev3" ' + '--frequency "PT5M"', + checks=[]) + + self.cmd('az alertsmanagement show ' + '--resource-group {rg} ' + '--name "MyAlertRule"', + checks=[]) + + self.cmd('az alertsmanagement show ' + '--resource-group {rg} ' + '--name "DailySuppression"', + checks=[]) + + self.cmd('az alertsmanagement list ' + '--resource-group {rg}', + checks=[]) + + self.cmd('az alertsmanagement list ' + '--resource-group {rg}', + checks=[]) + + self.cmd('az alertsmanagement changestate get_history ' + '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + checks=[]) + + self.cmd('az alertsmanagement change-state get_by_id ' + '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', + checks=[]) + + self.cmd('az alertsmanagement changestate get_history ' + '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + checks=[]) + + self.cmd('az alertsmanagement list ' + '--resource-group {rg}', + checks=[]) + + self.cmd('az alertsmanagement changestate get_by_id ' + '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + checks=[]) + + self.cmd('az alertsmanagement changestate get_summary', + checks=[]) + + self.cmd('az alertsmanagement change-state get_all', + checks=[]) + + self.cmd('az alertsmanagement list', + checks=[]) + + self.cmd('az alertsmanagement changestate get_all', + checks=[]) + + self.cmd('az alertsmanagement changestate meta_data', + checks=[]) + + self.cmd('az alertsmanagement update ' + '--resource-group {rg} ' + '--name "MyAlertRule" ' + '--description "New description for patching" ' + '--frequency "PT1M"', + checks=[]) + + self.cmd('az alertsmanagement update ' + '--resource-group {rg} ' + '--name "WeeklySuppression" ' + '--status "Disabled"', + checks=[]) + + self.cmd('az alertsmanagement change-state change_state ' + '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' + '--new-state "Acknowledged"', + checks=[]) + + self.cmd('az alertsmanagement changestate get_history ' + '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + checks=[]) + + self.cmd('az alertsmanagement delete ' + '--resource-group {rg} ' + '--name "MyAlertRule"', + checks=[]) + + self.cmd('az alertsmanagement delete ' + '--resource-group {rg} ' + '--name "DailySuppression"', + checks=[]) diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/__init__.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/__init__.py new file mode 100644 index 00000000000..97a96941bfd --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from ._configuration import AlertsManagementClientConfiguration +from ._alerts_management_client import AlertsManagementClient +__all__ = ['AlertsManagementClient', 'AlertsManagementClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_alerts_management_client.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_alerts_management_client.py new file mode 100644 index 00000000000..af7ad075b8c --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_alerts_management_client.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import AlertsManagementClientConfiguration +from .operations import Operations +from .operations import AlertsOperations +from .operations import SmartGroupsOperations +from .operations import ActionRulesOperations +from .operations import SmartDetectorAlertRulesOperations +from . import models + + +class AlertsManagementClient(SDKClient): + """AlertsManagement Client + + :ivar config: Configuration for client. + :vartype config: AlertsManagementClientConfiguration + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.alertsmanagement.operations.Operations + :ivar alerts: Alerts operations + :vartype alerts: azure.mgmt.alertsmanagement.operations.AlertsOperations + :ivar smart_groups: SmartGroups operations + :vartype smart_groups: azure.mgmt.alertsmanagement.operations.SmartGroupsOperations + :ivar action_rules: ActionRules operations + :vartype action_rules: azure.mgmt.alertsmanagement.operations.ActionRulesOperations + :ivar smart_detector_alert_rules: SmartDetectorAlertRules operations + :vartype smart_detector_alert_rules: azure.mgmt.alertsmanagement.operations.SmartDetectorAlertRulesOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = AlertsManagementClientConfiguration(credentials, subscription_id, base_url) + super(AlertsManagementClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) + self.alerts = AlertsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.smart_groups = SmartGroupsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.action_rules = ActionRulesOperations( + self._client, self.config, self._serialize, self._deserialize) + self.smart_detector_alert_rules = SmartDetectorAlertRulesOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_configuration.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_configuration.py new file mode 100644 index 00000000000..c42d0ce4b9c --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/_configuration.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from msrestazure import AzureConfiguration + +from .version import VERSION + + +class AlertsManagementClientConfiguration(AzureConfiguration): + """Configuration for AlertsManagementClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(AlertsManagementClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-mgmt-alertsmanagement/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/__init__.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/__init__.py new file mode 100644 index 00000000000..84870cf01aa --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/__init__.py @@ -0,0 +1,188 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ActionGroup + from ._models_py3 import ActionGroupsInformation + from ._models_py3 import ActionRule + from ._models_py3 import ActionRuleProperties + from ._models_py3 import Alert + from ._models_py3 import AlertModification + from ._models_py3 import AlertModificationItem + from ._models_py3 import AlertModificationProperties + from ._models_py3 import AlertProperties + from ._models_py3 import AlertRule + from ._models_py3 import AlertRulePatchObject + from ._models_py3 import AlertsMetaData + from ._models_py3 import AlertsMetaDataProperties + from ._models_py3 import AlertsSummary + from ._models_py3 import AlertsSummaryGroup + from ._models_py3 import AlertsSummaryGroupItem + from ._models_py3 import AzureResource + from ._models_py3 import Condition + from ._models_py3 import Conditions + from ._models_py3 import Detector + from ._models_py3 import Diagnostics + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse1, ErrorResponse1Exception + from ._models_py3 import ErrorResponseBody + from ._models_py3 import Essentials + from ._models_py3 import ManagedResource + from ._models_py3 import MonitorServiceDetails + from ._models_py3 import MonitorServiceList + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import PatchObject + from ._models_py3 import Resource + from ._models_py3 import Scope + from ._models_py3 import SmartGroup + from ._models_py3 import SmartGroupAggregatedProperty + from ._models_py3 import SmartGroupModification + from ._models_py3 import SmartGroupModificationItem + from ._models_py3 import SmartGroupModificationProperties + from ._models_py3 import Suppression + from ._models_py3 import SuppressionConfig + from ._models_py3 import SuppressionSchedule + from ._models_py3 import ThrottlingInformation +except (SyntaxError, ImportError): + from ._models import ActionGroup + from ._models import ActionGroupsInformation + from ._models import ActionRule + from ._models import ActionRuleProperties + from ._models import Alert + from ._models import AlertModification + from ._models import AlertModificationItem + from ._models import AlertModificationProperties + from ._models import AlertProperties + from ._models import AlertRule + from ._models import AlertRulePatchObject + from ._models import AlertsMetaData + from ._models import AlertsMetaDataProperties + from ._models import AlertsSummary + from ._models import AlertsSummaryGroup + from ._models import AlertsSummaryGroupItem + from ._models import AzureResource + from ._models import Condition + from ._models import Conditions + from ._models import Detector + from ._models import Diagnostics + from ._models import ErrorResponse, ErrorResponseException + from ._models import ErrorResponse1, ErrorResponse1Exception + from ._models import ErrorResponseBody + from ._models import Essentials + from ._models import ManagedResource + from ._models import MonitorServiceDetails + from ._models import MonitorServiceList + from ._models import Operation + from ._models import OperationDisplay + from ._models import PatchObject + from ._models import Resource + from ._models import Scope + from ._models import SmartGroup + from ._models import SmartGroupAggregatedProperty + from ._models import SmartGroupModification + from ._models import SmartGroupModificationItem + from ._models import SmartGroupModificationProperties + from ._models import Suppression + from ._models import SuppressionConfig + from ._models import SuppressionSchedule + from ._models import ThrottlingInformation +from ._paged_models import ActionRulePaged +from ._paged_models import AlertPaged +from ._paged_models import AlertRulePaged +from ._paged_models import OperationPaged +from ._paged_models import SmartGroupPaged +from ._alerts_management_client_enums import ( + Severity, + SignalType, + AlertState, + MonitorCondition, + MonitorService, + AlertModificationEvent, + SmartGroupModificationEvent, + State, + ScopeType, + Operator, + SuppressionType, + ActionRuleStatus, + AlertRuleState, + TimeRange, + AlertsSortByFields, + AlertsSummaryGroupByFields, + SmartGroupsSortByFields, +) + +__all__ = [ + 'ActionGroup', + 'ActionGroupsInformation', + 'ActionRule', + 'ActionRuleProperties', + 'Alert', + 'AlertModification', + 'AlertModificationItem', + 'AlertModificationProperties', + 'AlertProperties', + 'AlertRule', + 'AlertRulePatchObject', + 'AlertsMetaData', + 'AlertsMetaDataProperties', + 'AlertsSummary', + 'AlertsSummaryGroup', + 'AlertsSummaryGroupItem', + 'AzureResource', + 'Condition', + 'Conditions', + 'Detector', + 'Diagnostics', + 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse1', 'ErrorResponse1Exception', + 'ErrorResponseBody', + 'Essentials', + 'ManagedResource', + 'MonitorServiceDetails', + 'MonitorServiceList', + 'Operation', + 'OperationDisplay', + 'PatchObject', + 'Resource', + 'Scope', + 'SmartGroup', + 'SmartGroupAggregatedProperty', + 'SmartGroupModification', + 'SmartGroupModificationItem', + 'SmartGroupModificationProperties', + 'Suppression', + 'SuppressionConfig', + 'SuppressionSchedule', + 'ThrottlingInformation', + 'OperationPaged', + 'AlertPaged', + 'SmartGroupPaged', + 'ActionRulePaged', + 'AlertRulePaged', + 'Severity', + 'SignalType', + 'AlertState', + 'MonitorCondition', + 'MonitorService', + 'AlertModificationEvent', + 'SmartGroupModificationEvent', + 'State', + 'ScopeType', + 'Operator', + 'SuppressionType', + 'ActionRuleStatus', + 'AlertRuleState', + 'TimeRange', + 'AlertsSortByFields', + 'AlertsSummaryGroupByFields', + 'SmartGroupsSortByFields', +] diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_alerts_management_client_enums.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_alerts_management_client_enums.py new file mode 100644 index 00000000000..2d9334e583c --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_alerts_management_client_enums.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class Severity(str, Enum): + + sev0 = "Sev0" + sev1 = "Sev1" + sev2 = "Sev2" + sev3 = "Sev3" + sev4 = "Sev4" + + +class SignalType(str, Enum): + + metric = "Metric" + log = "Log" + unknown = "Unknown" + + +class AlertState(str, Enum): + + new = "New" + acknowledged = "Acknowledged" + closed = "Closed" + + +class MonitorCondition(str, Enum): + + fired = "Fired" + resolved = "Resolved" + + +class MonitorService(str, Enum): + + application_insights = "Application Insights" + activity_log_administrative = "ActivityLog Administrative" + activity_log_security = "ActivityLog Security" + activity_log_recommendation = "ActivityLog Recommendation" + activity_log_policy = "ActivityLog Policy" + activity_log_autoscale = "ActivityLog Autoscale" + log_analytics = "Log Analytics" + nagios = "Nagios" + platform = "Platform" + scom = "SCOM" + service_health = "ServiceHealth" + smart_detector = "SmartDetector" + vm_insights = "VM Insights" + zabbix = "Zabbix" + + +class AlertModificationEvent(str, Enum): + + alert_created = "AlertCreated" + state_change = "StateChange" + monitor_condition_change = "MonitorConditionChange" + + +class SmartGroupModificationEvent(str, Enum): + + smart_group_created = "SmartGroupCreated" + state_change = "StateChange" + alert_added = "AlertAdded" + alert_removed = "AlertRemoved" + + +class State(str, Enum): + + new = "New" + acknowledged = "Acknowledged" + closed = "Closed" + + +class ScopeType(str, Enum): + + resource_group = "ResourceGroup" + resource = "Resource" + + +class Operator(str, Enum): + + equals = "Equals" + not_equals = "NotEquals" + contains = "Contains" + does_not_contain = "DoesNotContain" + + +class SuppressionType(str, Enum): + + always = "Always" + once = "Once" + daily = "Daily" + weekly = "Weekly" + monthly = "Monthly" + + +class ActionRuleStatus(str, Enum): + + enabled = "Enabled" + disabled = "Disabled" + + +class AlertRuleState(str, Enum): + + enabled = "Enabled" + disabled = "Disabled" + + +class TimeRange(str, Enum): + + oneh = "1h" + oned = "1d" + sevend = "7d" + three_zerod = "30d" + + +class AlertsSortByFields(str, Enum): + + name = "name" + severity = "severity" + alert_state = "alertState" + monitor_condition = "monitorCondition" + target_resource = "targetResource" + target_resource_name = "targetResourceName" + target_resource_group = "targetResourceGroup" + target_resource_type = "targetResourceType" + start_date_time = "startDateTime" + last_modified_date_time = "lastModifiedDateTime" + + +class AlertsSummaryGroupByFields(str, Enum): + + severity = "severity" + alert_state = "alertState" + monitor_condition = "monitorCondition" + monitor_service = "monitorService" + signal_type = "signalType" + alert_rule = "alertRule" + + +class SmartGroupsSortByFields(str, Enum): + + alerts_count = "alertsCount" + state = "state" + severity = "severity" + start_date_time = "startDateTime" + last_modified_date_time = "lastModifiedDateTime" diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models.py new file mode 100644 index 00000000000..a602fe2c934 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models.py @@ -0,0 +1,1704 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class ActionRuleProperties(Model): + """Action rule properties defining scope, conditions, suppression logic for + action rule. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: Suppression, ActionGroup, Diagnostics + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'Suppression': 'Suppression', 'ActionGroup': 'ActionGroup', 'Diagnostics': 'Diagnostics'} + } + + def __init__(self, **kwargs): + super(ActionRuleProperties, self).__init__(**kwargs) + self.scope = kwargs.get('scope', None) + self.conditions = kwargs.get('conditions', None) + self.description = kwargs.get('description', None) + self.created_at = None + self.last_modified_at = None + self.created_by = None + self.last_modified_by = None + self.status = kwargs.get('status', None) + self.type = None + + +class ActionGroup(ActionRuleProperties): + """Action Group based Action Rule. + + Action rule with action group configuration. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + :param action_group_id: Required. Action group to trigger if action rule + matches + :type action_group_id: str + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + 'action_group_id': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ActionGroup, self).__init__(**kwargs) + self.action_group_id = kwargs.get('action_group_id', None) + self.type = 'ActionGroup' + + +class ActionGroupsInformation(Model): + """The Action Groups information, used by the alert rule. + + All required parameters must be populated in order to send to Azure. + + :param custom_email_subject: An optional custom email subject to use in + email notifications. + :type custom_email_subject: str + :param custom_webhook_payload: An optional custom web-hook payload to use + in web-hook notifications. + :type custom_webhook_payload: str + :param group_ids: Required. The Action Group resource IDs. + :type group_ids: list[str] + """ + + _validation = { + 'group_ids': {'required': True}, + } + + _attribute_map = { + 'custom_email_subject': {'key': 'customEmailSubject', 'type': 'str'}, + 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, + 'group_ids': {'key': 'groupIds', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(ActionGroupsInformation, self).__init__(**kwargs) + self.custom_email_subject = kwargs.get('custom_email_subject', None) + self.custom_webhook_payload = kwargs.get('custom_webhook_payload', None) + self.group_ids = kwargs.get('group_ids', None) + + +class Resource(Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Resource, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + + +class ManagedResource(Resource): + """An azure managed resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(ManagedResource, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.tags = kwargs.get('tags', None) + + +class ActionRule(ManagedResource): + """Action rule object containing target scope, conditions and suppression + logic. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + :param properties: action rule properties + :type properties: ~azure.mgmt.alertsmanagement.models.ActionRuleProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'properties': {'key': 'properties', 'type': 'ActionRuleProperties'}, + } + + def __init__(self, **kwargs): + super(ActionRule, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class Alert(Resource): + """An alert created in alert management service. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: ~azure.mgmt.alertsmanagement.models.AlertProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'AlertProperties'}, + } + + def __init__(self, **kwargs): + super(Alert, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class AlertModification(Resource): + """Alert Modification details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: + ~azure.mgmt.alertsmanagement.models.AlertModificationProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'AlertModificationProperties'}, + } + + def __init__(self, **kwargs): + super(AlertModification, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class AlertModificationItem(Model): + """Alert modification item. + + :param modification_event: Reason for the modification. Possible values + include: 'AlertCreated', 'StateChange', 'MonitorConditionChange' + :type modification_event: str or + ~azure.mgmt.alertsmanagement.models.AlertModificationEvent + :param old_value: Old value + :type old_value: str + :param new_value: New value + :type new_value: str + :param modified_at: Modified date and time + :type modified_at: str + :param modified_by: Modified user details (Principal client name) + :type modified_by: str + :param comments: Modification comments + :type comments: str + :param description: Description of the modification + :type description: str + """ + + _attribute_map = { + 'modification_event': {'key': 'modificationEvent', 'type': 'AlertModificationEvent'}, + 'old_value': {'key': 'oldValue', 'type': 'str'}, + 'new_value': {'key': 'newValue', 'type': 'str'}, + 'modified_at': {'key': 'modifiedAt', 'type': 'str'}, + 'modified_by': {'key': 'modifiedBy', 'type': 'str'}, + 'comments': {'key': 'comments', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AlertModificationItem, self).__init__(**kwargs) + self.modification_event = kwargs.get('modification_event', None) + self.old_value = kwargs.get('old_value', None) + self.new_value = kwargs.get('new_value', None) + self.modified_at = kwargs.get('modified_at', None) + self.modified_by = kwargs.get('modified_by', None) + self.comments = kwargs.get('comments', None) + self.description = kwargs.get('description', None) + + +class AlertModificationProperties(Model): + """Properties of the alert modification item. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar alert_id: Unique Id of the alert for which the history is being + retrieved + :vartype alert_id: str + :param modifications: Modification details + :type modifications: + list[~azure.mgmt.alertsmanagement.models.AlertModificationItem] + """ + + _validation = { + 'alert_id': {'readonly': True}, + } + + _attribute_map = { + 'alert_id': {'key': 'alertId', 'type': 'str'}, + 'modifications': {'key': 'modifications', 'type': '[AlertModificationItem]'}, + } + + def __init__(self, **kwargs): + super(AlertModificationProperties, self).__init__(**kwargs) + self.alert_id = None + self.modifications = kwargs.get('modifications', None) + + +class AlertProperties(Model): + """Alert property bag. + + :param essentials: + :type essentials: ~azure.mgmt.alertsmanagement.models.Essentials + :param context: + :type context: object + :param egress_config: + :type egress_config: object + """ + + _attribute_map = { + 'essentials': {'key': 'essentials', 'type': 'Essentials'}, + 'context': {'key': 'context', 'type': 'object'}, + 'egress_config': {'key': 'egressConfig', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(AlertProperties, self).__init__(**kwargs) + self.essentials = kwargs.get('essentials', None) + self.context = kwargs.get('context', None) + self.egress_config = kwargs.get('egress_config', None) + + +class AzureResource(Model): + """An Azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar type: The resource type. + :vartype type: str + :ivar name: The resource name. + :vartype name: str + :param location: The resource location. Default value: "global" . + :type location: str + :param tags: The resource tags. + :type tags: object + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(AzureResource, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.location = kwargs.get('location', "global") + self.tags = kwargs.get('tags', None) + + +class AlertRule(AzureResource): + """The alert rule information. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource ID. + :vartype id: str + :ivar type: The resource type. + :vartype type: str + :ivar name: The resource name. + :vartype name: str + :param location: The resource location. Default value: "global" . + :type location: str + :param tags: The resource tags. + :type tags: object + :param description: The alert rule description. + :type description: str + :param state: Required. The alert rule state. Possible values include: + 'Enabled', 'Disabled' + :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState + :param severity: Required. The alert rule severity. Possible values + include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param frequency: Required. The alert rule frequency in ISO8601 format. + The time granularity must be in minutes and minimum value is 5 minutes. + :type frequency: timedelta + :param detector: Required. The alert rule's detector. + :type detector: ~azure.mgmt.alertsmanagement.models.Detector + :param scope: Required. The alert rule resources scope. + :type scope: list[str] + :param action_groups: Required. The alert rule actions. + :type action_groups: + ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation + :param throttling: The alert rule throttling information. + :type throttling: + ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'state': {'required': True}, + 'severity': {'required': True}, + 'frequency': {'required': True}, + 'detector': {'required': True}, + 'scope': {'required': True}, + 'action_groups': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'str'}, + 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, + 'detector': {'key': 'properties.detector', 'type': 'Detector'}, + 'scope': {'key': 'properties.scope', 'type': '[str]'}, + 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, + 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + } + + def __init__(self, **kwargs): + super(AlertRule, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.state = kwargs.get('state', None) + self.severity = kwargs.get('severity', None) + self.frequency = kwargs.get('frequency', None) + self.detector = kwargs.get('detector', None) + self.scope = kwargs.get('scope', None) + self.action_groups = kwargs.get('action_groups', None) + self.throttling = kwargs.get('throttling', None) + + +class AlertRulePatchObject(Model): + """The alert rule patch information. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar type: The resource type. + :vartype type: str + :ivar name: The resource name. + :vartype name: str + :param tags: The resource tags. + :type tags: object + :param description: The alert rule description. + :type description: str + :param state: The alert rule state. Possible values include: 'Enabled', + 'Disabled' + :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState + :param severity: The alert rule severity. Possible values include: 'Sev0', + 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param frequency: The alert rule frequency in ISO8601 format. The time + granularity must be in minutes and minimum value is 5 minutes. + :type frequency: timedelta + :param action_groups: The alert rule actions. + :type action_groups: + ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation + :param throttling: The alert rule throttling information. + :type throttling: + ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'str'}, + 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, + 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, + 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + } + + def __init__(self, **kwargs): + super(AlertRulePatchObject, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.tags = kwargs.get('tags', None) + self.description = kwargs.get('description', None) + self.state = kwargs.get('state', None) + self.severity = kwargs.get('severity', None) + self.frequency = kwargs.get('frequency', None) + self.action_groups = kwargs.get('action_groups', None) + self.throttling = kwargs.get('throttling', None) + + +class AlertsMetaData(Model): + """alert meta data information. + + :param properties: + :type properties: + ~azure.mgmt.alertsmanagement.models.AlertsMetaDataProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'AlertsMetaDataProperties'}, + } + + def __init__(self, **kwargs): + super(AlertsMetaData, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class AlertsMetaDataProperties(Model): + """alert meta data property bag. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: MonitorServiceList + + All required parameters must be populated in order to send to Azure. + + :param metadata_identifier: Required. Constant filled by server. + :type metadata_identifier: str + """ + + _validation = { + 'metadata_identifier': {'required': True}, + } + + _attribute_map = { + 'metadata_identifier': {'key': 'metadataIdentifier', 'type': 'str'}, + } + + _subtype_map = { + 'metadata_identifier': {'MonitorServiceList': 'MonitorServiceList'} + } + + def __init__(self, **kwargs): + super(AlertsMetaDataProperties, self).__init__(**kwargs) + self.metadata_identifier = None + + +class AlertsSummary(Resource): + """Summary of alerts based on the input filters and 'groupby' parameters. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroup + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'AlertsSummaryGroup'}, + } + + def __init__(self, **kwargs): + super(AlertsSummary, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class AlertsSummaryGroup(Model): + """Group the result set. + + :param total: Total count of the result set. + :type total: int + :param smart_groups_count: Total count of the smart groups. + :type smart_groups_count: int + :param groupedby: Name of the field aggregated + :type groupedby: str + :param values: List of the items + :type values: + list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + """ + + _attribute_map = { + 'total': {'key': 'total', 'type': 'int'}, + 'smart_groups_count': {'key': 'smartGroupsCount', 'type': 'int'}, + 'groupedby': {'key': 'groupedby', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, + } + + def __init__(self, **kwargs): + super(AlertsSummaryGroup, self).__init__(**kwargs) + self.total = kwargs.get('total', None) + self.smart_groups_count = kwargs.get('smart_groups_count', None) + self.groupedby = kwargs.get('groupedby', None) + self.values = kwargs.get('values', None) + + +class AlertsSummaryGroupItem(Model): + """Alerts summary group item. + + :param name: Value of the aggregated field + :type name: str + :param count: Count of the aggregated field + :type count: int + :param groupedby: Name of the field aggregated + :type groupedby: str + :param values: List of the items + :type values: + list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'int'}, + 'groupedby': {'key': 'groupedby', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, + } + + def __init__(self, **kwargs): + super(AlertsSummaryGroupItem, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.count = kwargs.get('count', None) + self.groupedby = kwargs.get('groupedby', None) + self.values = kwargs.get('values', None) + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class Condition(Model): + """condition to trigger an action rule. + + :param operator: operator for a given condition. Possible values include: + 'Equals', 'NotEquals', 'Contains', 'DoesNotContain' + :type operator: str or ~azure.mgmt.alertsmanagement.models.Operator + :param values: list of values to match for a given condition. + :type values: list[str] + """ + + _attribute_map = { + 'operator': {'key': 'operator', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(Condition, self).__init__(**kwargs) + self.operator = kwargs.get('operator', None) + self.values = kwargs.get('values', None) + + +class Conditions(Model): + """Conditions in alert instance to be matched for a given action rule. Default + value is all. Multiple values could be provided with comma separation. + + :param severity: filter alerts by severity + :type severity: ~azure.mgmt.alertsmanagement.models.Condition + :param monitor_service: filter alerts by monitor service + :type monitor_service: ~azure.mgmt.alertsmanagement.models.Condition + :param monitor_condition: filter alerts by monitor condition + :type monitor_condition: ~azure.mgmt.alertsmanagement.models.Condition + :param target_resource_type: filter alerts by target resource type + :type target_resource_type: ~azure.mgmt.alertsmanagement.models.Condition + :param alert_rule_id: filter alerts by alert rule id + :type alert_rule_id: ~azure.mgmt.alertsmanagement.models.Condition + :param description: filter alerts by alert rule description + :type description: ~azure.mgmt.alertsmanagement.models.Condition + :param alert_context: filter alerts by alert context (payload) + :type alert_context: ~azure.mgmt.alertsmanagement.models.Condition + """ + + _attribute_map = { + 'severity': {'key': 'severity', 'type': 'Condition'}, + 'monitor_service': {'key': 'monitorService', 'type': 'Condition'}, + 'monitor_condition': {'key': 'monitorCondition', 'type': 'Condition'}, + 'target_resource_type': {'key': 'targetResourceType', 'type': 'Condition'}, + 'alert_rule_id': {'key': 'alertRuleId', 'type': 'Condition'}, + 'description': {'key': 'description', 'type': 'Condition'}, + 'alert_context': {'key': 'alertContext', 'type': 'Condition'}, + } + + def __init__(self, **kwargs): + super(Conditions, self).__init__(**kwargs) + self.severity = kwargs.get('severity', None) + self.monitor_service = kwargs.get('monitor_service', None) + self.monitor_condition = kwargs.get('monitor_condition', None) + self.target_resource_type = kwargs.get('target_resource_type', None) + self.alert_rule_id = kwargs.get('alert_rule_id', None) + self.description = kwargs.get('description', None) + self.alert_context = kwargs.get('alert_context', None) + + +class Detector(Model): + """The detector information. By default this is not populated, unless it's + specified in expandDetector. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. The detector id. + :type id: str + :param parameters: The detector's parameters.' + :type parameters: dict[str, object] + :param name: The Smart Detector name. By default this is not populated, + unless it's specified in expandDetector + :type name: str + :param description: The Smart Detector description. By default this is not + populated, unless it's specified in expandDetector + :type description: str + :param supported_resource_types: The Smart Detector supported resource + types. By default this is not populated, unless it's specified in + expandDetector + :type supported_resource_types: list[str] + :param image_paths: The Smart Detector image path. By default this is not + populated, unless it's specified in expandDetector + :type image_paths: list[str] + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{object}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'supported_resource_types': {'key': 'supportedResourceTypes', 'type': '[str]'}, + 'image_paths': {'key': 'imagePaths', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(Detector, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.parameters = kwargs.get('parameters', None) + self.name = kwargs.get('name', None) + self.description = kwargs.get('description', None) + self.supported_resource_types = kwargs.get('supported_resource_types', None) + self.image_paths = kwargs.get('image_paths', None) + + +class Diagnostics(ActionRuleProperties): + """Diagnostics based Action Rule. + + Action rule with diagnostics configuration. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Diagnostics, self).__init__(**kwargs) + self.type = 'Diagnostics' + + +class ErrorResponse(Model): + """An error response from the service. + + :param error: + :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class ErrorResponse1(Model): + """Describe the format of an Error response. + + :param code: Error code + :type code: str + :param message: Error message indicating why the operation failed. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse1, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class ErrorResponse1Exception(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse1'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponse1Exception, self).__init__(deserialize, response, 'ErrorResponse1', *args) + + +class ErrorResponseBody(Model): + """Details of error response. + + :param code: Error code, intended to be consumed programmatically. + :type code: str + :param message: Description of the error, intended for display in user + interface. + :type message: str + :param target: Target of the particular error, for example name of the + property. + :type target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorResponseBody]'}, + } + + def __init__(self, **kwargs): + super(ErrorResponseBody, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + + +class Essentials(Model): + """This object contains consistent fields across different monitor services. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar severity: Severity of alert Sev0 being highest and Sev4 being + lowest. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :vartype severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :ivar signal_type: The type of signal the alert is based on, which could + be metrics, logs or activity logs. Possible values include: 'Metric', + 'Log', 'Unknown' + :vartype signal_type: str or + ~azure.mgmt.alertsmanagement.models.SignalType + :ivar alert_state: Alert object state, which can be modified by the user. + Possible values include: 'New', 'Acknowledged', 'Closed' + :vartype alert_state: str or + ~azure.mgmt.alertsmanagement.models.AlertState + :ivar monitor_condition: Condition of the rule at the monitor service. It + represents whether the underlying conditions have crossed the defined + alert rule thresholds. Possible values include: 'Fired', 'Resolved' + :vartype monitor_condition: str or + ~azure.mgmt.alertsmanagement.models.MonitorCondition + :param target_resource: Target ARM resource, on which alert got created. + :type target_resource: str + :param target_resource_name: Name of the target ARM resource name, on + which alert got created. + :type target_resource_name: str + :param target_resource_group: Resource group of target ARM resource, on + which alert got created. + :type target_resource_group: str + :param target_resource_type: Resource type of target ARM resource, on + which alert got created. + :type target_resource_type: str + :ivar monitor_service: Monitor service on which the rule(monitor) is set. + Possible values include: 'Application Insights', 'ActivityLog + Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', + 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', + 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', + 'Zabbix' + :vartype monitor_service: str or + ~azure.mgmt.alertsmanagement.models.MonitorService + :ivar alert_rule: Rule(monitor) which fired alert instance. Depending on + the monitor service, this would be ARM id or name of the rule. + :vartype alert_rule: str + :ivar source_created_id: Unique Id created by monitor service for each + alert instance. This could be used to track the issue at the monitor + service, in case of Nagios, Zabbix, SCOM etc. + :vartype source_created_id: str + :ivar smart_group_id: Unique Id of the smart group + :vartype smart_group_id: str + :ivar smart_grouping_reason: Verbose reason describing the reason why this + alert instance is added to a smart group + :vartype smart_grouping_reason: str + :ivar start_date_time: Creation time(ISO-8601 format) of alert instance. + :vartype start_date_time: datetime + :ivar last_modified_date_time: Last modification time(ISO-8601 format) of + alert instance. + :vartype last_modified_date_time: datetime + :ivar monitor_condition_resolved_date_time: Resolved time(ISO-8601 format) + of alert instance. This will be updated when monitor service resolves the + alert instance because the rule condition is no longer met. + :vartype monitor_condition_resolved_date_time: datetime + :ivar last_modified_user_name: User who last modified the alert, in case + of monitor service updates user would be 'system', otherwise name of the + user. + :vartype last_modified_user_name: str + """ + + _validation = { + 'severity': {'readonly': True}, + 'signal_type': {'readonly': True}, + 'alert_state': {'readonly': True}, + 'monitor_condition': {'readonly': True}, + 'monitor_service': {'readonly': True}, + 'alert_rule': {'readonly': True}, + 'source_created_id': {'readonly': True}, + 'smart_group_id': {'readonly': True}, + 'smart_grouping_reason': {'readonly': True}, + 'start_date_time': {'readonly': True}, + 'last_modified_date_time': {'readonly': True}, + 'monitor_condition_resolved_date_time': {'readonly': True}, + 'last_modified_user_name': {'readonly': True}, + } + + _attribute_map = { + 'severity': {'key': 'severity', 'type': 'str'}, + 'signal_type': {'key': 'signalType', 'type': 'str'}, + 'alert_state': {'key': 'alertState', 'type': 'str'}, + 'monitor_condition': {'key': 'monitorCondition', 'type': 'str'}, + 'target_resource': {'key': 'targetResource', 'type': 'str'}, + 'target_resource_name': {'key': 'targetResourceName', 'type': 'str'}, + 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + 'target_resource_type': {'key': 'targetResourceType', 'type': 'str'}, + 'monitor_service': {'key': 'monitorService', 'type': 'str'}, + 'alert_rule': {'key': 'alertRule', 'type': 'str'}, + 'source_created_id': {'key': 'sourceCreatedId', 'type': 'str'}, + 'smart_group_id': {'key': 'smartGroupId', 'type': 'str'}, + 'smart_grouping_reason': {'key': 'smartGroupingReason', 'type': 'str'}, + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, + 'monitor_condition_resolved_date_time': {'key': 'monitorConditionResolvedDateTime', 'type': 'iso-8601'}, + 'last_modified_user_name': {'key': 'lastModifiedUserName', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Essentials, self).__init__(**kwargs) + self.severity = None + self.signal_type = None + self.alert_state = None + self.monitor_condition = None + self.target_resource = kwargs.get('target_resource', None) + self.target_resource_name = kwargs.get('target_resource_name', None) + self.target_resource_group = kwargs.get('target_resource_group', None) + self.target_resource_type = kwargs.get('target_resource_type', None) + self.monitor_service = None + self.alert_rule = None + self.source_created_id = None + self.smart_group_id = None + self.smart_grouping_reason = None + self.start_date_time = None + self.last_modified_date_time = None + self.monitor_condition_resolved_date_time = None + self.last_modified_user_name = None + + +class MonitorServiceDetails(Model): + """Details of a monitor service. + + :param name: Monitor service name + :type name: str + :param display_name: Monitor service display name + :type display_name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(MonitorServiceDetails, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display_name = kwargs.get('display_name', None) + + +class MonitorServiceList(AlertsMetaDataProperties): + """Monitor service details. + + Monitor service details. + + All required parameters must be populated in order to send to Azure. + + :param metadata_identifier: Required. Constant filled by server. + :type metadata_identifier: str + :param data: Required. Array of operations + :type data: + list[~azure.mgmt.alertsmanagement.models.MonitorServiceDetails] + """ + + _validation = { + 'metadata_identifier': {'required': True}, + 'data': {'required': True}, + } + + _attribute_map = { + 'metadata_identifier': {'key': 'metadataIdentifier', 'type': 'str'}, + 'data': {'key': 'data', 'type': '[MonitorServiceDetails]'}, + } + + def __init__(self, **kwargs): + super(MonitorServiceList, self).__init__(**kwargs) + self.data = kwargs.get('data', None) + self.metadata_identifier = 'MonitorServiceList' + + +class Operation(Model): + """Operation provided by provider. + + :param name: Name of the operation + :type name: str + :param display: Properties of the operation + :type display: ~azure.mgmt.alertsmanagement.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__(self, **kwargs): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class OperationDisplay(Model): + """Properties of the operation. + + :param provider: Provider name + :type provider: str + :param resource: Resource name + :type resource: str + :param operation: Operation name + :type operation: str + :param description: Description of the operation + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class PatchObject(Model): + """Data contract for patch. + + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param tags: tags to be updated + :type tags: object + """ + + _attribute_map = { + 'status': {'key': 'properties.status', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + } + + def __init__(self, **kwargs): + super(PatchObject, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.tags = kwargs.get('tags', None) + + +class Scope(Model): + """Target scope for a given action rule. By default scope will be the + subscription. User can also provide list of resource groups or list of + resources from the scope subscription as well. + + :param scope_type: type of target scope. Possible values include: + 'ResourceGroup', 'Resource' + :type scope_type: str or ~azure.mgmt.alertsmanagement.models.ScopeType + :param values: list of ARM IDs of the given scope type which will be the + target of the given action rule. + :type values: list[str] + """ + + _attribute_map = { + 'scope_type': {'key': 'scopeType', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(Scope, self).__init__(**kwargs) + self.scope_type = kwargs.get('scope_type', None) + self.values = kwargs.get('values', None) + + +class SmartGroup(Resource): + """Set of related alerts grouped together smartly by AMS. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param alerts_count: Total number of alerts in smart group + :type alerts_count: int + :ivar smart_group_state: Smart group state. Possible values include: + 'New', 'Acknowledged', 'Closed' + :vartype smart_group_state: str or + ~azure.mgmt.alertsmanagement.models.State + :ivar severity: Severity of smart group is the highest(Sev0 >... > Sev4) + severity of all the alerts in the group. Possible values include: 'Sev0', + 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :vartype severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :ivar start_date_time: Creation time of smart group. Date-Time in ISO-8601 + format. + :vartype start_date_time: datetime + :ivar last_modified_date_time: Last updated time of smart group. Date-Time + in ISO-8601 format. + :vartype last_modified_date_time: datetime + :ivar last_modified_user_name: Last modified by user name. + :vartype last_modified_user_name: str + :param resources: Summary of target resources in the smart group + :type resources: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param resource_types: Summary of target resource types in the smart group + :type resource_types: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param resource_groups: Summary of target resource groups in the smart + group + :type resource_groups: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param monitor_services: Summary of monitorServices in the smart group + :type monitor_services: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param monitor_conditions: Summary of monitorConditions in the smart group + :type monitor_conditions: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param alert_states: Summary of alertStates in the smart group + :type alert_states: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param alert_severities: Summary of alertSeverities in the smart group + :type alert_severities: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param next_link: The URI to fetch the next page of alerts. Call + ListNext() with this URI to fetch the next page alerts. + :type next_link: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'smart_group_state': {'readonly': True}, + 'severity': {'readonly': True}, + 'start_date_time': {'readonly': True}, + 'last_modified_date_time': {'readonly': True}, + 'last_modified_user_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'alerts_count': {'key': 'properties.alertsCount', 'type': 'int'}, + 'smart_group_state': {'key': 'properties.smartGroupState', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'str'}, + 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, + 'last_modified_date_time': {'key': 'properties.lastModifiedDateTime', 'type': 'iso-8601'}, + 'last_modified_user_name': {'key': 'properties.lastModifiedUserName', 'type': 'str'}, + 'resources': {'key': 'properties.resources', 'type': '[SmartGroupAggregatedProperty]'}, + 'resource_types': {'key': 'properties.resourceTypes', 'type': '[SmartGroupAggregatedProperty]'}, + 'resource_groups': {'key': 'properties.resourceGroups', 'type': '[SmartGroupAggregatedProperty]'}, + 'monitor_services': {'key': 'properties.monitorServices', 'type': '[SmartGroupAggregatedProperty]'}, + 'monitor_conditions': {'key': 'properties.monitorConditions', 'type': '[SmartGroupAggregatedProperty]'}, + 'alert_states': {'key': 'properties.alertStates', 'type': '[SmartGroupAggregatedProperty]'}, + 'alert_severities': {'key': 'properties.alertSeverities', 'type': '[SmartGroupAggregatedProperty]'}, + 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SmartGroup, self).__init__(**kwargs) + self.alerts_count = kwargs.get('alerts_count', None) + self.smart_group_state = None + self.severity = None + self.start_date_time = None + self.last_modified_date_time = None + self.last_modified_user_name = None + self.resources = kwargs.get('resources', None) + self.resource_types = kwargs.get('resource_types', None) + self.resource_groups = kwargs.get('resource_groups', None) + self.monitor_services = kwargs.get('monitor_services', None) + self.monitor_conditions = kwargs.get('monitor_conditions', None) + self.alert_states = kwargs.get('alert_states', None) + self.alert_severities = kwargs.get('alert_severities', None) + self.next_link = kwargs.get('next_link', None) + + +class SmartGroupAggregatedProperty(Model): + """Aggregated property of each type. + + :param name: Name of the type. + :type name: str + :param count: Total number of items of type. + :type count: int + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(SmartGroupAggregatedProperty, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.count = kwargs.get('count', None) + + +class SmartGroupModification(Resource): + """Alert Modification details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: + ~azure.mgmt.alertsmanagement.models.SmartGroupModificationProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'SmartGroupModificationProperties'}, + } + + def __init__(self, **kwargs): + super(SmartGroupModification, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class SmartGroupModificationItem(Model): + """smartGroup modification item. + + :param modification_event: Reason for the modification. Possible values + include: 'SmartGroupCreated', 'StateChange', 'AlertAdded', 'AlertRemoved' + :type modification_event: str or + ~azure.mgmt.alertsmanagement.models.SmartGroupModificationEvent + :param old_value: Old value + :type old_value: str + :param new_value: New value + :type new_value: str + :param modified_at: Modified date and time + :type modified_at: str + :param modified_by: Modified user details (Principal client name) + :type modified_by: str + :param comments: Modification comments + :type comments: str + :param description: Description of the modification + :type description: str + """ + + _attribute_map = { + 'modification_event': {'key': 'modificationEvent', 'type': 'SmartGroupModificationEvent'}, + 'old_value': {'key': 'oldValue', 'type': 'str'}, + 'new_value': {'key': 'newValue', 'type': 'str'}, + 'modified_at': {'key': 'modifiedAt', 'type': 'str'}, + 'modified_by': {'key': 'modifiedBy', 'type': 'str'}, + 'comments': {'key': 'comments', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SmartGroupModificationItem, self).__init__(**kwargs) + self.modification_event = kwargs.get('modification_event', None) + self.old_value = kwargs.get('old_value', None) + self.new_value = kwargs.get('new_value', None) + self.modified_at = kwargs.get('modified_at', None) + self.modified_by = kwargs.get('modified_by', None) + self.comments = kwargs.get('comments', None) + self.description = kwargs.get('description', None) + + +class SmartGroupModificationProperties(Model): + """Properties of the smartGroup modification item. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar smart_group_id: Unique Id of the smartGroup for which the history is + being retrieved + :vartype smart_group_id: str + :param modifications: Modification details + :type modifications: + list[~azure.mgmt.alertsmanagement.models.SmartGroupModificationItem] + :param next_link: URL to fetch the next set of results. + :type next_link: str + """ + + _validation = { + 'smart_group_id': {'readonly': True}, + } + + _attribute_map = { + 'smart_group_id': {'key': 'smartGroupId', 'type': 'str'}, + 'modifications': {'key': 'modifications', 'type': '[SmartGroupModificationItem]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SmartGroupModificationProperties, self).__init__(**kwargs) + self.smart_group_id = None + self.modifications = kwargs.get('modifications', None) + self.next_link = kwargs.get('next_link', None) + + +class Suppression(ActionRuleProperties): + """Suppression based Action Rule. + + Action rule with suppression configuration. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + :param suppression_config: Required. suppression configuration for the + action rule + :type suppression_config: + ~azure.mgmt.alertsmanagement.models.SuppressionConfig + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + 'suppression_config': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'suppression_config': {'key': 'suppressionConfig', 'type': 'SuppressionConfig'}, + } + + def __init__(self, **kwargs): + super(Suppression, self).__init__(**kwargs) + self.suppression_config = kwargs.get('suppression_config', None) + self.type = 'Suppression' + + +class SuppressionConfig(Model): + """Suppression logic for a given action rule. + + All required parameters must be populated in order to send to Azure. + + :param recurrence_type: Required. Specifies when the suppression should be + applied. Possible values include: 'Always', 'Once', 'Daily', 'Weekly', + 'Monthly' + :type recurrence_type: str or + ~azure.mgmt.alertsmanagement.models.SuppressionType + :param schedule: suppression schedule configuration + :type schedule: ~azure.mgmt.alertsmanagement.models.SuppressionSchedule + """ + + _validation = { + 'recurrence_type': {'required': True}, + } + + _attribute_map = { + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'schedule': {'key': 'schedule', 'type': 'SuppressionSchedule'}, + } + + def __init__(self, **kwargs): + super(SuppressionConfig, self).__init__(**kwargs) + self.recurrence_type = kwargs.get('recurrence_type', None) + self.schedule = kwargs.get('schedule', None) + + +class SuppressionSchedule(Model): + """Schedule for a given suppression configuration. + + :param start_date: Start date for suppression + :type start_date: str + :param end_date: End date for suppression + :type end_date: str + :param start_time: Start time for suppression + :type start_time: str + :param end_time: End date for suppression + :type end_time: str + :param recurrence_values: Specifies the values for recurrence pattern + :type recurrence_values: list[int] + """ + + _attribute_map = { + 'start_date': {'key': 'startDate', 'type': 'str'}, + 'end_date': {'key': 'endDate', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + 'recurrence_values': {'key': 'recurrenceValues', 'type': '[int]'}, + } + + def __init__(self, **kwargs): + super(SuppressionSchedule, self).__init__(**kwargs) + self.start_date = kwargs.get('start_date', None) + self.end_date = kwargs.get('end_date', None) + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + self.recurrence_values = kwargs.get('recurrence_values', None) + + +class ThrottlingInformation(Model): + """Optional throttling information for the alert rule. + + :param duration: The required duration (in ISO8601 format) to wait before + notifying on the alert rule again. The time granularity must be in minutes + and minimum value is 0 minutes + :type duration: timedelta + """ + + _attribute_map = { + 'duration': {'key': 'duration', 'type': 'duration'}, + } + + def __init__(self, **kwargs): + super(ThrottlingInformation, self).__init__(**kwargs) + self.duration = kwargs.get('duration', None) diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models_py3.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models_py3.py new file mode 100644 index 00000000000..635be9d76f8 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_models_py3.py @@ -0,0 +1,1704 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class ActionRuleProperties(Model): + """Action rule properties defining scope, conditions, suppression logic for + action rule. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: Suppression, ActionGroup, Diagnostics + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'Suppression': 'Suppression', 'ActionGroup': 'ActionGroup', 'Diagnostics': 'Diagnostics'} + } + + def __init__(self, *, scope=None, conditions=None, description: str=None, status=None, **kwargs) -> None: + super(ActionRuleProperties, self).__init__(**kwargs) + self.scope = scope + self.conditions = conditions + self.description = description + self.created_at = None + self.last_modified_at = None + self.created_by = None + self.last_modified_by = None + self.status = status + self.type = None + + +class ActionGroup(ActionRuleProperties): + """Action Group based Action Rule. + + Action rule with action group configuration. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + :param action_group_id: Required. Action group to trigger if action rule + matches + :type action_group_id: str + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + 'action_group_id': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + } + + def __init__(self, *, action_group_id: str, scope=None, conditions=None, description: str=None, status=None, **kwargs) -> None: + super(ActionGroup, self).__init__(scope=scope, conditions=conditions, description=description, status=status, **kwargs) + self.action_group_id = action_group_id + self.type = 'ActionGroup' + + +class ActionGroupsInformation(Model): + """The Action Groups information, used by the alert rule. + + All required parameters must be populated in order to send to Azure. + + :param custom_email_subject: An optional custom email subject to use in + email notifications. + :type custom_email_subject: str + :param custom_webhook_payload: An optional custom web-hook payload to use + in web-hook notifications. + :type custom_webhook_payload: str + :param group_ids: Required. The Action Group resource IDs. + :type group_ids: list[str] + """ + + _validation = { + 'group_ids': {'required': True}, + } + + _attribute_map = { + 'custom_email_subject': {'key': 'customEmailSubject', 'type': 'str'}, + 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, + 'group_ids': {'key': 'groupIds', 'type': '[str]'}, + } + + def __init__(self, *, group_ids, custom_email_subject: str=None, custom_webhook_payload: str=None, **kwargs) -> None: + super(ActionGroupsInformation, self).__init__(**kwargs) + self.custom_email_subject = custom_email_subject + self.custom_webhook_payload = custom_webhook_payload + self.group_ids = group_ids + + +class Resource(Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(Resource, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + + +class ManagedResource(Resource): + """An azure managed resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, *, location: str, tags=None, **kwargs) -> None: + super(ManagedResource, self).__init__(**kwargs) + self.location = location + self.tags = tags + + +class ActionRule(ManagedResource): + """Action rule object containing target scope, conditions and suppression + logic. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + :param properties: action rule properties + :type properties: ~azure.mgmt.alertsmanagement.models.ActionRuleProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'properties': {'key': 'properties', 'type': 'ActionRuleProperties'}, + } + + def __init__(self, *, location: str, tags=None, properties=None, **kwargs) -> None: + super(ActionRule, self).__init__(location=location, tags=tags, **kwargs) + self.properties = properties + + +class Alert(Resource): + """An alert created in alert management service. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: ~azure.mgmt.alertsmanagement.models.AlertProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'AlertProperties'}, + } + + def __init__(self, *, properties=None, **kwargs) -> None: + super(Alert, self).__init__(**kwargs) + self.properties = properties + + +class AlertModification(Resource): + """Alert Modification details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: + ~azure.mgmt.alertsmanagement.models.AlertModificationProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'AlertModificationProperties'}, + } + + def __init__(self, *, properties=None, **kwargs) -> None: + super(AlertModification, self).__init__(**kwargs) + self.properties = properties + + +class AlertModificationItem(Model): + """Alert modification item. + + :param modification_event: Reason for the modification. Possible values + include: 'AlertCreated', 'StateChange', 'MonitorConditionChange' + :type modification_event: str or + ~azure.mgmt.alertsmanagement.models.AlertModificationEvent + :param old_value: Old value + :type old_value: str + :param new_value: New value + :type new_value: str + :param modified_at: Modified date and time + :type modified_at: str + :param modified_by: Modified user details (Principal client name) + :type modified_by: str + :param comments: Modification comments + :type comments: str + :param description: Description of the modification + :type description: str + """ + + _attribute_map = { + 'modification_event': {'key': 'modificationEvent', 'type': 'AlertModificationEvent'}, + 'old_value': {'key': 'oldValue', 'type': 'str'}, + 'new_value': {'key': 'newValue', 'type': 'str'}, + 'modified_at': {'key': 'modifiedAt', 'type': 'str'}, + 'modified_by': {'key': 'modifiedBy', 'type': 'str'}, + 'comments': {'key': 'comments', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, modification_event=None, old_value: str=None, new_value: str=None, modified_at: str=None, modified_by: str=None, comments: str=None, description: str=None, **kwargs) -> None: + super(AlertModificationItem, self).__init__(**kwargs) + self.modification_event = modification_event + self.old_value = old_value + self.new_value = new_value + self.modified_at = modified_at + self.modified_by = modified_by + self.comments = comments + self.description = description + + +class AlertModificationProperties(Model): + """Properties of the alert modification item. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar alert_id: Unique Id of the alert for which the history is being + retrieved + :vartype alert_id: str + :param modifications: Modification details + :type modifications: + list[~azure.mgmt.alertsmanagement.models.AlertModificationItem] + """ + + _validation = { + 'alert_id': {'readonly': True}, + } + + _attribute_map = { + 'alert_id': {'key': 'alertId', 'type': 'str'}, + 'modifications': {'key': 'modifications', 'type': '[AlertModificationItem]'}, + } + + def __init__(self, *, modifications=None, **kwargs) -> None: + super(AlertModificationProperties, self).__init__(**kwargs) + self.alert_id = None + self.modifications = modifications + + +class AlertProperties(Model): + """Alert property bag. + + :param essentials: + :type essentials: ~azure.mgmt.alertsmanagement.models.Essentials + :param context: + :type context: object + :param egress_config: + :type egress_config: object + """ + + _attribute_map = { + 'essentials': {'key': 'essentials', 'type': 'Essentials'}, + 'context': {'key': 'context', 'type': 'object'}, + 'egress_config': {'key': 'egressConfig', 'type': 'object'}, + } + + def __init__(self, *, essentials=None, context=None, egress_config=None, **kwargs) -> None: + super(AlertProperties, self).__init__(**kwargs) + self.essentials = essentials + self.context = context + self.egress_config = egress_config + + +class AzureResource(Model): + """An Azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar type: The resource type. + :vartype type: str + :ivar name: The resource name. + :vartype name: str + :param location: The resource location. Default value: "global" . + :type location: str + :param tags: The resource tags. + :type tags: object + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + } + + def __init__(self, *, location: str="global", tags=None, **kwargs) -> None: + super(AzureResource, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.location = location + self.tags = tags + + +class AlertRule(AzureResource): + """The alert rule information. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource ID. + :vartype id: str + :ivar type: The resource type. + :vartype type: str + :ivar name: The resource name. + :vartype name: str + :param location: The resource location. Default value: "global" . + :type location: str + :param tags: The resource tags. + :type tags: object + :param description: The alert rule description. + :type description: str + :param state: Required. The alert rule state. Possible values include: + 'Enabled', 'Disabled' + :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState + :param severity: Required. The alert rule severity. Possible values + include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param frequency: Required. The alert rule frequency in ISO8601 format. + The time granularity must be in minutes and minimum value is 5 minutes. + :type frequency: timedelta + :param detector: Required. The alert rule's detector. + :type detector: ~azure.mgmt.alertsmanagement.models.Detector + :param scope: Required. The alert rule resources scope. + :type scope: list[str] + :param action_groups: Required. The alert rule actions. + :type action_groups: + ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation + :param throttling: The alert rule throttling information. + :type throttling: + ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'state': {'required': True}, + 'severity': {'required': True}, + 'frequency': {'required': True}, + 'detector': {'required': True}, + 'scope': {'required': True}, + 'action_groups': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'str'}, + 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, + 'detector': {'key': 'properties.detector', 'type': 'Detector'}, + 'scope': {'key': 'properties.scope', 'type': '[str]'}, + 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, + 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + } + + def __init__(self, *, state, severity, frequency, detector, scope, action_groups, location: str="global", tags=None, description: str=None, throttling=None, **kwargs) -> None: + super(AlertRule, self).__init__(location=location, tags=tags, **kwargs) + self.description = description + self.state = state + self.severity = severity + self.frequency = frequency + self.detector = detector + self.scope = scope + self.action_groups = action_groups + self.throttling = throttling + + +class AlertRulePatchObject(Model): + """The alert rule patch information. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar type: The resource type. + :vartype type: str + :ivar name: The resource name. + :vartype name: str + :param tags: The resource tags. + :type tags: object + :param description: The alert rule description. + :type description: str + :param state: The alert rule state. Possible values include: 'Enabled', + 'Disabled' + :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState + :param severity: The alert rule severity. Possible values include: 'Sev0', + 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param frequency: The alert rule frequency in ISO8601 format. The time + granularity must be in minutes and minimum value is 5 minutes. + :type frequency: timedelta + :param action_groups: The alert rule actions. + :type action_groups: + ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation + :param throttling: The alert rule throttling information. + :type throttling: + ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'str'}, + 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, + 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, + 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + } + + def __init__(self, *, tags=None, description: str=None, state=None, severity=None, frequency=None, action_groups=None, throttling=None, **kwargs) -> None: + super(AlertRulePatchObject, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.tags = tags + self.description = description + self.state = state + self.severity = severity + self.frequency = frequency + self.action_groups = action_groups + self.throttling = throttling + + +class AlertsMetaData(Model): + """alert meta data information. + + :param properties: + :type properties: + ~azure.mgmt.alertsmanagement.models.AlertsMetaDataProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'AlertsMetaDataProperties'}, + } + + def __init__(self, *, properties=None, **kwargs) -> None: + super(AlertsMetaData, self).__init__(**kwargs) + self.properties = properties + + +class AlertsMetaDataProperties(Model): + """alert meta data property bag. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: MonitorServiceList + + All required parameters must be populated in order to send to Azure. + + :param metadata_identifier: Required. Constant filled by server. + :type metadata_identifier: str + """ + + _validation = { + 'metadata_identifier': {'required': True}, + } + + _attribute_map = { + 'metadata_identifier': {'key': 'metadataIdentifier', 'type': 'str'}, + } + + _subtype_map = { + 'metadata_identifier': {'MonitorServiceList': 'MonitorServiceList'} + } + + def __init__(self, **kwargs) -> None: + super(AlertsMetaDataProperties, self).__init__(**kwargs) + self.metadata_identifier = None + + +class AlertsSummary(Resource): + """Summary of alerts based on the input filters and 'groupby' parameters. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroup + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'AlertsSummaryGroup'}, + } + + def __init__(self, *, properties=None, **kwargs) -> None: + super(AlertsSummary, self).__init__(**kwargs) + self.properties = properties + + +class AlertsSummaryGroup(Model): + """Group the result set. + + :param total: Total count of the result set. + :type total: int + :param smart_groups_count: Total count of the smart groups. + :type smart_groups_count: int + :param groupedby: Name of the field aggregated + :type groupedby: str + :param values: List of the items + :type values: + list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + """ + + _attribute_map = { + 'total': {'key': 'total', 'type': 'int'}, + 'smart_groups_count': {'key': 'smartGroupsCount', 'type': 'int'}, + 'groupedby': {'key': 'groupedby', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, + } + + def __init__(self, *, total: int=None, smart_groups_count: int=None, groupedby: str=None, values=None, **kwargs) -> None: + super(AlertsSummaryGroup, self).__init__(**kwargs) + self.total = total + self.smart_groups_count = smart_groups_count + self.groupedby = groupedby + self.values = values + + +class AlertsSummaryGroupItem(Model): + """Alerts summary group item. + + :param name: Value of the aggregated field + :type name: str + :param count: Count of the aggregated field + :type count: int + :param groupedby: Name of the field aggregated + :type groupedby: str + :param values: List of the items + :type values: + list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'int'}, + 'groupedby': {'key': 'groupedby', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, + } + + def __init__(self, *, name: str=None, count: int=None, groupedby: str=None, values=None, **kwargs) -> None: + super(AlertsSummaryGroupItem, self).__init__(**kwargs) + self.name = name + self.count = count + self.groupedby = groupedby + self.values = values + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class Condition(Model): + """condition to trigger an action rule. + + :param operator: operator for a given condition. Possible values include: + 'Equals', 'NotEquals', 'Contains', 'DoesNotContain' + :type operator: str or ~azure.mgmt.alertsmanagement.models.Operator + :param values: list of values to match for a given condition. + :type values: list[str] + """ + + _attribute_map = { + 'operator': {'key': 'operator', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__(self, *, operator=None, values=None, **kwargs) -> None: + super(Condition, self).__init__(**kwargs) + self.operator = operator + self.values = values + + +class Conditions(Model): + """Conditions in alert instance to be matched for a given action rule. Default + value is all. Multiple values could be provided with comma separation. + + :param severity: filter alerts by severity + :type severity: ~azure.mgmt.alertsmanagement.models.Condition + :param monitor_service: filter alerts by monitor service + :type monitor_service: ~azure.mgmt.alertsmanagement.models.Condition + :param monitor_condition: filter alerts by monitor condition + :type monitor_condition: ~azure.mgmt.alertsmanagement.models.Condition + :param target_resource_type: filter alerts by target resource type + :type target_resource_type: ~azure.mgmt.alertsmanagement.models.Condition + :param alert_rule_id: filter alerts by alert rule id + :type alert_rule_id: ~azure.mgmt.alertsmanagement.models.Condition + :param description: filter alerts by alert rule description + :type description: ~azure.mgmt.alertsmanagement.models.Condition + :param alert_context: filter alerts by alert context (payload) + :type alert_context: ~azure.mgmt.alertsmanagement.models.Condition + """ + + _attribute_map = { + 'severity': {'key': 'severity', 'type': 'Condition'}, + 'monitor_service': {'key': 'monitorService', 'type': 'Condition'}, + 'monitor_condition': {'key': 'monitorCondition', 'type': 'Condition'}, + 'target_resource_type': {'key': 'targetResourceType', 'type': 'Condition'}, + 'alert_rule_id': {'key': 'alertRuleId', 'type': 'Condition'}, + 'description': {'key': 'description', 'type': 'Condition'}, + 'alert_context': {'key': 'alertContext', 'type': 'Condition'}, + } + + def __init__(self, *, severity=None, monitor_service=None, monitor_condition=None, target_resource_type=None, alert_rule_id=None, description=None, alert_context=None, **kwargs) -> None: + super(Conditions, self).__init__(**kwargs) + self.severity = severity + self.monitor_service = monitor_service + self.monitor_condition = monitor_condition + self.target_resource_type = target_resource_type + self.alert_rule_id = alert_rule_id + self.description = description + self.alert_context = alert_context + + +class Detector(Model): + """The detector information. By default this is not populated, unless it's + specified in expandDetector. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. The detector id. + :type id: str + :param parameters: The detector's parameters.' + :type parameters: dict[str, object] + :param name: The Smart Detector name. By default this is not populated, + unless it's specified in expandDetector + :type name: str + :param description: The Smart Detector description. By default this is not + populated, unless it's specified in expandDetector + :type description: str + :param supported_resource_types: The Smart Detector supported resource + types. By default this is not populated, unless it's specified in + expandDetector + :type supported_resource_types: list[str] + :param image_paths: The Smart Detector image path. By default this is not + populated, unless it's specified in expandDetector + :type image_paths: list[str] + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{object}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'supported_resource_types': {'key': 'supportedResourceTypes', 'type': '[str]'}, + 'image_paths': {'key': 'imagePaths', 'type': '[str]'}, + } + + def __init__(self, *, id: str, parameters=None, name: str=None, description: str=None, supported_resource_types=None, image_paths=None, **kwargs) -> None: + super(Detector, self).__init__(**kwargs) + self.id = id + self.parameters = parameters + self.name = name + self.description = description + self.supported_resource_types = supported_resource_types + self.image_paths = image_paths + + +class Diagnostics(ActionRuleProperties): + """Diagnostics based Action Rule. + + Action rule with diagnostics configuration. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, *, scope=None, conditions=None, description: str=None, status=None, **kwargs) -> None: + super(Diagnostics, self).__init__(scope=scope, conditions=conditions, description=description, status=status, **kwargs) + self.type = 'Diagnostics' + + +class ErrorResponse(Model): + """An error response from the service. + + :param error: + :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + } + + def __init__(self, *, error=None, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class ErrorResponse1(Model): + """Describe the format of an Error response. + + :param code: Error code + :type code: str + :param message: Error message indicating why the operation failed. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code: str=None, message: str=None, **kwargs) -> None: + super(ErrorResponse1, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ErrorResponse1Exception(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse1'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponse1Exception, self).__init__(deserialize, response, 'ErrorResponse1', *args) + + +class ErrorResponseBody(Model): + """Details of error response. + + :param code: Error code, intended to be consumed programmatically. + :type code: str + :param message: Description of the error, intended for display in user + interface. + :type message: str + :param target: Target of the particular error, for example name of the + property. + :type target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorResponseBody]'}, + } + + def __init__(self, *, code: str=None, message: str=None, target: str=None, details=None, **kwargs) -> None: + super(ErrorResponseBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class Essentials(Model): + """This object contains consistent fields across different monitor services. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar severity: Severity of alert Sev0 being highest and Sev4 being + lowest. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :vartype severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :ivar signal_type: The type of signal the alert is based on, which could + be metrics, logs or activity logs. Possible values include: 'Metric', + 'Log', 'Unknown' + :vartype signal_type: str or + ~azure.mgmt.alertsmanagement.models.SignalType + :ivar alert_state: Alert object state, which can be modified by the user. + Possible values include: 'New', 'Acknowledged', 'Closed' + :vartype alert_state: str or + ~azure.mgmt.alertsmanagement.models.AlertState + :ivar monitor_condition: Condition of the rule at the monitor service. It + represents whether the underlying conditions have crossed the defined + alert rule thresholds. Possible values include: 'Fired', 'Resolved' + :vartype monitor_condition: str or + ~azure.mgmt.alertsmanagement.models.MonitorCondition + :param target_resource: Target ARM resource, on which alert got created. + :type target_resource: str + :param target_resource_name: Name of the target ARM resource name, on + which alert got created. + :type target_resource_name: str + :param target_resource_group: Resource group of target ARM resource, on + which alert got created. + :type target_resource_group: str + :param target_resource_type: Resource type of target ARM resource, on + which alert got created. + :type target_resource_type: str + :ivar monitor_service: Monitor service on which the rule(monitor) is set. + Possible values include: 'Application Insights', 'ActivityLog + Administrative', 'ActivityLog Security', 'ActivityLog Recommendation', + 'ActivityLog Policy', 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', + 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', + 'Zabbix' + :vartype monitor_service: str or + ~azure.mgmt.alertsmanagement.models.MonitorService + :ivar alert_rule: Rule(monitor) which fired alert instance. Depending on + the monitor service, this would be ARM id or name of the rule. + :vartype alert_rule: str + :ivar source_created_id: Unique Id created by monitor service for each + alert instance. This could be used to track the issue at the monitor + service, in case of Nagios, Zabbix, SCOM etc. + :vartype source_created_id: str + :ivar smart_group_id: Unique Id of the smart group + :vartype smart_group_id: str + :ivar smart_grouping_reason: Verbose reason describing the reason why this + alert instance is added to a smart group + :vartype smart_grouping_reason: str + :ivar start_date_time: Creation time(ISO-8601 format) of alert instance. + :vartype start_date_time: datetime + :ivar last_modified_date_time: Last modification time(ISO-8601 format) of + alert instance. + :vartype last_modified_date_time: datetime + :ivar monitor_condition_resolved_date_time: Resolved time(ISO-8601 format) + of alert instance. This will be updated when monitor service resolves the + alert instance because the rule condition is no longer met. + :vartype monitor_condition_resolved_date_time: datetime + :ivar last_modified_user_name: User who last modified the alert, in case + of monitor service updates user would be 'system', otherwise name of the + user. + :vartype last_modified_user_name: str + """ + + _validation = { + 'severity': {'readonly': True}, + 'signal_type': {'readonly': True}, + 'alert_state': {'readonly': True}, + 'monitor_condition': {'readonly': True}, + 'monitor_service': {'readonly': True}, + 'alert_rule': {'readonly': True}, + 'source_created_id': {'readonly': True}, + 'smart_group_id': {'readonly': True}, + 'smart_grouping_reason': {'readonly': True}, + 'start_date_time': {'readonly': True}, + 'last_modified_date_time': {'readonly': True}, + 'monitor_condition_resolved_date_time': {'readonly': True}, + 'last_modified_user_name': {'readonly': True}, + } + + _attribute_map = { + 'severity': {'key': 'severity', 'type': 'str'}, + 'signal_type': {'key': 'signalType', 'type': 'str'}, + 'alert_state': {'key': 'alertState', 'type': 'str'}, + 'monitor_condition': {'key': 'monitorCondition', 'type': 'str'}, + 'target_resource': {'key': 'targetResource', 'type': 'str'}, + 'target_resource_name': {'key': 'targetResourceName', 'type': 'str'}, + 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, + 'target_resource_type': {'key': 'targetResourceType', 'type': 'str'}, + 'monitor_service': {'key': 'monitorService', 'type': 'str'}, + 'alert_rule': {'key': 'alertRule', 'type': 'str'}, + 'source_created_id': {'key': 'sourceCreatedId', 'type': 'str'}, + 'smart_group_id': {'key': 'smartGroupId', 'type': 'str'}, + 'smart_grouping_reason': {'key': 'smartGroupingReason', 'type': 'str'}, + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, + 'monitor_condition_resolved_date_time': {'key': 'monitorConditionResolvedDateTime', 'type': 'iso-8601'}, + 'last_modified_user_name': {'key': 'lastModifiedUserName', 'type': 'str'}, + } + + def __init__(self, *, target_resource: str=None, target_resource_name: str=None, target_resource_group: str=None, target_resource_type: str=None, **kwargs) -> None: + super(Essentials, self).__init__(**kwargs) + self.severity = None + self.signal_type = None + self.alert_state = None + self.monitor_condition = None + self.target_resource = target_resource + self.target_resource_name = target_resource_name + self.target_resource_group = target_resource_group + self.target_resource_type = target_resource_type + self.monitor_service = None + self.alert_rule = None + self.source_created_id = None + self.smart_group_id = None + self.smart_grouping_reason = None + self.start_date_time = None + self.last_modified_date_time = None + self.monitor_condition_resolved_date_time = None + self.last_modified_user_name = None + + +class MonitorServiceDetails(Model): + """Details of a monitor service. + + :param name: Monitor service name + :type name: str + :param display_name: Monitor service display name + :type display_name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__(self, *, name: str=None, display_name: str=None, **kwargs) -> None: + super(MonitorServiceDetails, self).__init__(**kwargs) + self.name = name + self.display_name = display_name + + +class MonitorServiceList(AlertsMetaDataProperties): + """Monitor service details. + + Monitor service details. + + All required parameters must be populated in order to send to Azure. + + :param metadata_identifier: Required. Constant filled by server. + :type metadata_identifier: str + :param data: Required. Array of operations + :type data: + list[~azure.mgmt.alertsmanagement.models.MonitorServiceDetails] + """ + + _validation = { + 'metadata_identifier': {'required': True}, + 'data': {'required': True}, + } + + _attribute_map = { + 'metadata_identifier': {'key': 'metadataIdentifier', 'type': 'str'}, + 'data': {'key': 'data', 'type': '[MonitorServiceDetails]'}, + } + + def __init__(self, *, data, **kwargs) -> None: + super(MonitorServiceList, self).__init__(**kwargs) + self.data = data + self.metadata_identifier = 'MonitorServiceList' + + +class Operation(Model): + """Operation provided by provider. + + :param name: Name of the operation + :type name: str + :param display: Properties of the operation + :type display: ~azure.mgmt.alertsmanagement.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + + +class OperationDisplay(Model): + """Properties of the operation. + + :param provider: Provider name + :type provider: str + :param resource: Resource name + :type resource: str + :param operation: Operation name + :type operation: str + :param description: Description of the operation + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class PatchObject(Model): + """Data contract for patch. + + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param tags: tags to be updated + :type tags: object + """ + + _attribute_map = { + 'status': {'key': 'properties.status', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'object'}, + } + + def __init__(self, *, status=None, tags=None, **kwargs) -> None: + super(PatchObject, self).__init__(**kwargs) + self.status = status + self.tags = tags + + +class Scope(Model): + """Target scope for a given action rule. By default scope will be the + subscription. User can also provide list of resource groups or list of + resources from the scope subscription as well. + + :param scope_type: type of target scope. Possible values include: + 'ResourceGroup', 'Resource' + :type scope_type: str or ~azure.mgmt.alertsmanagement.models.ScopeType + :param values: list of ARM IDs of the given scope type which will be the + target of the given action rule. + :type values: list[str] + """ + + _attribute_map = { + 'scope_type': {'key': 'scopeType', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__(self, *, scope_type=None, values=None, **kwargs) -> None: + super(Scope, self).__init__(**kwargs) + self.scope_type = scope_type + self.values = values + + +class SmartGroup(Resource): + """Set of related alerts grouped together smartly by AMS. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param alerts_count: Total number of alerts in smart group + :type alerts_count: int + :ivar smart_group_state: Smart group state. Possible values include: + 'New', 'Acknowledged', 'Closed' + :vartype smart_group_state: str or + ~azure.mgmt.alertsmanagement.models.State + :ivar severity: Severity of smart group is the highest(Sev0 >... > Sev4) + severity of all the alerts in the group. Possible values include: 'Sev0', + 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :vartype severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :ivar start_date_time: Creation time of smart group. Date-Time in ISO-8601 + format. + :vartype start_date_time: datetime + :ivar last_modified_date_time: Last updated time of smart group. Date-Time + in ISO-8601 format. + :vartype last_modified_date_time: datetime + :ivar last_modified_user_name: Last modified by user name. + :vartype last_modified_user_name: str + :param resources: Summary of target resources in the smart group + :type resources: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param resource_types: Summary of target resource types in the smart group + :type resource_types: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param resource_groups: Summary of target resource groups in the smart + group + :type resource_groups: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param monitor_services: Summary of monitorServices in the smart group + :type monitor_services: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param monitor_conditions: Summary of monitorConditions in the smart group + :type monitor_conditions: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param alert_states: Summary of alertStates in the smart group + :type alert_states: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param alert_severities: Summary of alertSeverities in the smart group + :type alert_severities: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :param next_link: The URI to fetch the next page of alerts. Call + ListNext() with this URI to fetch the next page alerts. + :type next_link: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'smart_group_state': {'readonly': True}, + 'severity': {'readonly': True}, + 'start_date_time': {'readonly': True}, + 'last_modified_date_time': {'readonly': True}, + 'last_modified_user_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'alerts_count': {'key': 'properties.alertsCount', 'type': 'int'}, + 'smart_group_state': {'key': 'properties.smartGroupState', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'str'}, + 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, + 'last_modified_date_time': {'key': 'properties.lastModifiedDateTime', 'type': 'iso-8601'}, + 'last_modified_user_name': {'key': 'properties.lastModifiedUserName', 'type': 'str'}, + 'resources': {'key': 'properties.resources', 'type': '[SmartGroupAggregatedProperty]'}, + 'resource_types': {'key': 'properties.resourceTypes', 'type': '[SmartGroupAggregatedProperty]'}, + 'resource_groups': {'key': 'properties.resourceGroups', 'type': '[SmartGroupAggregatedProperty]'}, + 'monitor_services': {'key': 'properties.monitorServices', 'type': '[SmartGroupAggregatedProperty]'}, + 'monitor_conditions': {'key': 'properties.monitorConditions', 'type': '[SmartGroupAggregatedProperty]'}, + 'alert_states': {'key': 'properties.alertStates', 'type': '[SmartGroupAggregatedProperty]'}, + 'alert_severities': {'key': 'properties.alertSeverities', 'type': '[SmartGroupAggregatedProperty]'}, + 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + } + + def __init__(self, *, alerts_count: int=None, resources=None, resource_types=None, resource_groups=None, monitor_services=None, monitor_conditions=None, alert_states=None, alert_severities=None, next_link: str=None, **kwargs) -> None: + super(SmartGroup, self).__init__(**kwargs) + self.alerts_count = alerts_count + self.smart_group_state = None + self.severity = None + self.start_date_time = None + self.last_modified_date_time = None + self.last_modified_user_name = None + self.resources = resources + self.resource_types = resource_types + self.resource_groups = resource_groups + self.monitor_services = monitor_services + self.monitor_conditions = monitor_conditions + self.alert_states = alert_states + self.alert_severities = alert_severities + self.next_link = next_link + + +class SmartGroupAggregatedProperty(Model): + """Aggregated property of each type. + + :param name: Name of the type. + :type name: str + :param count: Total number of items of type. + :type count: int + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'int'}, + } + + def __init__(self, *, name: str=None, count: int=None, **kwargs) -> None: + super(SmartGroupAggregatedProperty, self).__init__(**kwargs) + self.name = name + self.count = count + + +class SmartGroupModification(Resource): + """Alert Modification details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param properties: + :type properties: + ~azure.mgmt.alertsmanagement.models.SmartGroupModificationProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'SmartGroupModificationProperties'}, + } + + def __init__(self, *, properties=None, **kwargs) -> None: + super(SmartGroupModification, self).__init__(**kwargs) + self.properties = properties + + +class SmartGroupModificationItem(Model): + """smartGroup modification item. + + :param modification_event: Reason for the modification. Possible values + include: 'SmartGroupCreated', 'StateChange', 'AlertAdded', 'AlertRemoved' + :type modification_event: str or + ~azure.mgmt.alertsmanagement.models.SmartGroupModificationEvent + :param old_value: Old value + :type old_value: str + :param new_value: New value + :type new_value: str + :param modified_at: Modified date and time + :type modified_at: str + :param modified_by: Modified user details (Principal client name) + :type modified_by: str + :param comments: Modification comments + :type comments: str + :param description: Description of the modification + :type description: str + """ + + _attribute_map = { + 'modification_event': {'key': 'modificationEvent', 'type': 'SmartGroupModificationEvent'}, + 'old_value': {'key': 'oldValue', 'type': 'str'}, + 'new_value': {'key': 'newValue', 'type': 'str'}, + 'modified_at': {'key': 'modifiedAt', 'type': 'str'}, + 'modified_by': {'key': 'modifiedBy', 'type': 'str'}, + 'comments': {'key': 'comments', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, modification_event=None, old_value: str=None, new_value: str=None, modified_at: str=None, modified_by: str=None, comments: str=None, description: str=None, **kwargs) -> None: + super(SmartGroupModificationItem, self).__init__(**kwargs) + self.modification_event = modification_event + self.old_value = old_value + self.new_value = new_value + self.modified_at = modified_at + self.modified_by = modified_by + self.comments = comments + self.description = description + + +class SmartGroupModificationProperties(Model): + """Properties of the smartGroup modification item. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar smart_group_id: Unique Id of the smartGroup for which the history is + being retrieved + :vartype smart_group_id: str + :param modifications: Modification details + :type modifications: + list[~azure.mgmt.alertsmanagement.models.SmartGroupModificationItem] + :param next_link: URL to fetch the next set of results. + :type next_link: str + """ + + _validation = { + 'smart_group_id': {'readonly': True}, + } + + _attribute_map = { + 'smart_group_id': {'key': 'smartGroupId', 'type': 'str'}, + 'modifications': {'key': 'modifications', 'type': '[SmartGroupModificationItem]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__(self, *, modifications=None, next_link: str=None, **kwargs) -> None: + super(SmartGroupModificationProperties, self).__init__(**kwargs) + self.smart_group_id = None + self.modifications = modifications + self.next_link = next_link + + +class Suppression(ActionRuleProperties): + """Suppression based Action Rule. + + Action rule with suppression configuration. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param scope: scope on which action rule will apply + :type scope: ~azure.mgmt.alertsmanagement.models.Scope + :param conditions: conditions on which alerts will be filtered + :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions + :param description: Description of action rule + :type description: str + :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 + format. + :vartype created_at: datetime + :ivar last_modified_at: Last updated time of action rule. Date-Time in + ISO-8601 format. + :vartype last_modified_at: datetime + :ivar created_by: Created by user name. + :vartype created_by: str + :ivar last_modified_by: Last modified by user name. + :vartype last_modified_by: str + :param status: Indicates if the given action rule is enabled or disabled. + Possible values include: 'Enabled', 'Disabled' + :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param type: Required. Constant filled by server. + :type type: str + :param suppression_config: Required. suppression configuration for the + action rule + :type suppression_config: + ~azure.mgmt.alertsmanagement.models.SuppressionConfig + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + 'created_by': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'type': {'required': True}, + 'suppression_config': {'required': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'Scope'}, + 'conditions': {'key': 'conditions', 'type': 'Conditions'}, + 'description': {'key': 'description', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'suppression_config': {'key': 'suppressionConfig', 'type': 'SuppressionConfig'}, + } + + def __init__(self, *, suppression_config, scope=None, conditions=None, description: str=None, status=None, **kwargs) -> None: + super(Suppression, self).__init__(scope=scope, conditions=conditions, description=description, status=status, **kwargs) + self.suppression_config = suppression_config + self.type = 'Suppression' + + +class SuppressionConfig(Model): + """Suppression logic for a given action rule. + + All required parameters must be populated in order to send to Azure. + + :param recurrence_type: Required. Specifies when the suppression should be + applied. Possible values include: 'Always', 'Once', 'Daily', 'Weekly', + 'Monthly' + :type recurrence_type: str or + ~azure.mgmt.alertsmanagement.models.SuppressionType + :param schedule: suppression schedule configuration + :type schedule: ~azure.mgmt.alertsmanagement.models.SuppressionSchedule + """ + + _validation = { + 'recurrence_type': {'required': True}, + } + + _attribute_map = { + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'schedule': {'key': 'schedule', 'type': 'SuppressionSchedule'}, + } + + def __init__(self, *, recurrence_type, schedule=None, **kwargs) -> None: + super(SuppressionConfig, self).__init__(**kwargs) + self.recurrence_type = recurrence_type + self.schedule = schedule + + +class SuppressionSchedule(Model): + """Schedule for a given suppression configuration. + + :param start_date: Start date for suppression + :type start_date: str + :param end_date: End date for suppression + :type end_date: str + :param start_time: Start time for suppression + :type start_time: str + :param end_time: End date for suppression + :type end_time: str + :param recurrence_values: Specifies the values for recurrence pattern + :type recurrence_values: list[int] + """ + + _attribute_map = { + 'start_date': {'key': 'startDate', 'type': 'str'}, + 'end_date': {'key': 'endDate', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + 'recurrence_values': {'key': 'recurrenceValues', 'type': '[int]'}, + } + + def __init__(self, *, start_date: str=None, end_date: str=None, start_time: str=None, end_time: str=None, recurrence_values=None, **kwargs) -> None: + super(SuppressionSchedule, self).__init__(**kwargs) + self.start_date = start_date + self.end_date = end_date + self.start_time = start_time + self.end_time = end_time + self.recurrence_values = recurrence_values + + +class ThrottlingInformation(Model): + """Optional throttling information for the alert rule. + + :param duration: The required duration (in ISO8601 format) to wait before + notifying on the alert rule again. The time granularity must be in minutes + and minimum value is 0 minutes + :type duration: timedelta + """ + + _attribute_map = { + 'duration': {'key': 'duration', 'type': 'duration'}, + } + + def __init__(self, *, duration=None, **kwargs) -> None: + super(ThrottlingInformation, self).__init__(**kwargs) + self.duration = duration diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_paged_models.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_paged_models.py new file mode 100644 index 00000000000..aece7093df7 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/models/_paged_models.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class OperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`Operation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Operation]'} + } + + def __init__(self, *args, **kwargs): + + super(OperationPaged, self).__init__(*args, **kwargs) +class AlertPaged(Paged): + """ + A paging container for iterating over a list of :class:`Alert ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Alert]'} + } + + def __init__(self, *args, **kwargs): + + super(AlertPaged, self).__init__(*args, **kwargs) +class SmartGroupPaged(Paged): + """ + A paging container for iterating over a list of :class:`SmartGroup ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[SmartGroup]'} + } + + def __init__(self, *args, **kwargs): + + super(SmartGroupPaged, self).__init__(*args, **kwargs) +class ActionRulePaged(Paged): + """ + A paging container for iterating over a list of :class:`ActionRule ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ActionRule]'} + } + + def __init__(self, *args, **kwargs): + + super(ActionRulePaged, self).__init__(*args, **kwargs) +class AlertRulePaged(Paged): + """ + A paging container for iterating over a list of :class:`AlertRule ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[AlertRule]'} + } + + def __init__(self, *args, **kwargs): + + super(AlertRulePaged, self).__init__(*args, **kwargs) diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/__init__.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/__init__.py new file mode 100644 index 00000000000..946b389ce5f --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._alerts_operations import AlertsOperations +from ._smart_groups_operations import SmartGroupsOperations +from ._action_rules_operations import ActionRulesOperations +from ._smart_detector_alert_rules_operations import SmartDetectorAlertRulesOperations + +__all__ = [ + 'Operations', + 'AlertsOperations', + 'SmartGroupsOperations', + 'ActionRulesOperations', + 'SmartDetectorAlertRulesOperations', +] diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_action_rules_operations.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_action_rules_operations.py new file mode 100644 index 00000000000..d07e0fd19b7 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_action_rules_operations.py @@ -0,0 +1,575 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class ActionRulesOperations(object): + """ActionRulesOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: client API version. Constant value: "2019-05-05-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-05-05-preview" + + self.config = config + + def list_by_subscription( + self, target_resource_group=None, target_resource_type=None, target_resource=None, severity=None, monitor_service=None, impacted_scope=None, description=None, alert_rule_id=None, action_group=None, name=None, custom_headers=None, raw=False, **operation_config): + """Get all action rule in a given subscription. + + List all action rules of the subscription and given input filters. + + :param target_resource_group: Filter by target resource group name. + Default value is select all. + :type target_resource_group: str + :param target_resource_type: Filter by target resource type. Default + value is select all. + :type target_resource_type: str + :param target_resource: Filter by target resource( which is full ARM + ID) Default value is select all. + :type target_resource: str + :param severity: Filter by severity. Default value is select all. + Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param monitor_service: Filter by monitor service which generates the + alert instance. Default value is select all. Possible values include: + 'Application Insights', 'ActivityLog Administrative', 'ActivityLog + Security', 'ActivityLog Recommendation', 'ActivityLog Policy', + 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', + 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' + :type monitor_service: str or + ~azure.mgmt.alertsmanagement.models.MonitorService + :param impacted_scope: filter by impacted/target scope (provide comma + separated list for multiple scopes). The value should be an well + constructed ARM id of the scope. + :type impacted_scope: str + :param description: filter by alert rule description + :type description: str + :param alert_rule_id: filter by alert rule id + :type alert_rule_id: str + :param action_group: filter by action group configured as part of + action rule + :type action_group: str + :param name: filter by action rule name + :type name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ActionRule + :rtype: + ~azure.mgmt.alertsmanagement.models.ActionRulePaged[~azure.mgmt.alertsmanagement.models.ActionRule] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') + if target_resource is not None: + query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') + if severity is not None: + query_parameters['severity'] = self._serialize.query("severity", severity, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') + if impacted_scope is not None: + query_parameters['impactedScope'] = self._serialize.query("impacted_scope", impacted_scope, 'str') + if description is not None: + query_parameters['description'] = self._serialize.query("description", description, 'str') + if alert_rule_id is not None: + query_parameters['alertRuleId'] = self._serialize.query("alert_rule_id", alert_rule_id, 'str') + if action_group is not None: + query_parameters['actionGroup'] = self._serialize.query("action_group", action_group, 'str') + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ActionRulePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/actionRules'} + + def list_by_resource_group( + self, resource_group_name, target_resource_group=None, target_resource_type=None, target_resource=None, severity=None, monitor_service=None, impacted_scope=None, description=None, alert_rule_id=None, action_group=None, name=None, custom_headers=None, raw=False, **operation_config): + """Get all action rules created in a resource group. + + List all action rules of the subscription, created in given resource + group and given input filters. + + :param resource_group_name: Resource group name where the resource is + created. + :type resource_group_name: str + :param target_resource_group: Filter by target resource group name. + Default value is select all. + :type target_resource_group: str + :param target_resource_type: Filter by target resource type. Default + value is select all. + :type target_resource_type: str + :param target_resource: Filter by target resource( which is full ARM + ID) Default value is select all. + :type target_resource: str + :param severity: Filter by severity. Default value is select all. + Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param monitor_service: Filter by monitor service which generates the + alert instance. Default value is select all. Possible values include: + 'Application Insights', 'ActivityLog Administrative', 'ActivityLog + Security', 'ActivityLog Recommendation', 'ActivityLog Policy', + 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', + 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' + :type monitor_service: str or + ~azure.mgmt.alertsmanagement.models.MonitorService + :param impacted_scope: filter by impacted/target scope (provide comma + separated list for multiple scopes). The value should be an well + constructed ARM id of the scope. + :type impacted_scope: str + :param description: filter by alert rule description + :type description: str + :param alert_rule_id: filter by alert rule id + :type alert_rule_id: str + :param action_group: filter by action group configured as part of + action rule + :type action_group: str + :param name: filter by action rule name + :type name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ActionRule + :rtype: + ~azure.mgmt.alertsmanagement.models.ActionRulePaged[~azure.mgmt.alertsmanagement.models.ActionRule] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') + if target_resource is not None: + query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') + if severity is not None: + query_parameters['severity'] = self._serialize.query("severity", severity, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') + if impacted_scope is not None: + query_parameters['impactedScope'] = self._serialize.query("impacted_scope", impacted_scope, 'str') + if description is not None: + query_parameters['description'] = self._serialize.query("description", description, 'str') + if alert_rule_id is not None: + query_parameters['alertRuleId'] = self._serialize.query("alert_rule_id", alert_rule_id, 'str') + if action_group is not None: + query_parameters['actionGroup'] = self._serialize.query("action_group", action_group, 'str') + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ActionRulePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules'} + + def get_by_name( + self, resource_group_name, action_rule_name, custom_headers=None, raw=False, **operation_config): + """Get action rule by name. + + Get a specific action rule. + + :param resource_group_name: Resource group name where the resource is + created. + :type resource_group_name: str + :param action_rule_name: The name of action rule that needs to be + fetched + :type action_rule_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ActionRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_by_name.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ActionRule', response) + header_dict = { + 'x-ms-request-id': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} + + def create_update( + self, resource_group_name, action_rule_name, action_rule, custom_headers=None, raw=False, **operation_config): + """Create/update an action rule. + + Creates/Updates a specific action rule. + + :param resource_group_name: Resource group name where the resource is + created. + :type resource_group_name: str + :param action_rule_name: The name of action rule that needs to be + created/updated + :type action_rule_name: str + :param action_rule: action rule to be created/updated + :type action_rule: ~azure.mgmt.alertsmanagement.models.ActionRule + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ActionRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create_update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(action_rule, 'ActionRule') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ActionRule', response) + header_dict = { + 'x-ms-request-id': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + create_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} + + def delete( + self, resource_group_name, action_rule_name, custom_headers=None, raw=False, **operation_config): + """Delete action rule. + + Deletes a given action rule. + + :param resource_group_name: Resource group name where the resource is + created. + :type resource_group_name: str + :param action_rule_name: The name that needs to be deleted + :type action_rule_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: bool or ClientRawResponse if raw=true + :rtype: bool or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('bool', response) + header_dict = { + 'x-ms-request-id': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} + + def update( + self, resource_group_name, action_rule_name, status=None, tags=None, custom_headers=None, raw=False, **operation_config): + """Patch action rule. + + Update enabled flag and/or tags for the given action rule. + + :param resource_group_name: Resource group name where the resource is + created. + :type resource_group_name: str + :param action_rule_name: The name that needs to be updated + :type action_rule_name: str + :param status: Indicates if the given action rule is enabled or + disabled. Possible values include: 'Enabled', 'Disabled' + :type status: str or + ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param tags: tags to be updated + :type tags: object + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ActionRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + action_rule_patch = models.PatchObject(status=status, tags=tags) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(action_rule_patch, 'PatchObject') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ActionRule', response) + header_dict = { + 'x-ms-request-id': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_alerts_operations.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_alerts_operations.py new file mode 100644 index 00000000000..da6c76c07ff --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_alerts_operations.py @@ -0,0 +1,582 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class AlertsOperations(object): + """AlertsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: client API version. Constant value: "2019-05-05-preview". + :ivar identifier: Identification of the information to be retrieved by API call. Constant value: "MonitorServiceList". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-05-05-preview" + self.identifier = "MonitorServiceList" + + self.config = config + + def meta_data( + self, custom_headers=None, raw=False, **operation_config): + """List alerts meta data information based on value of identifier + parameter. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AlertsMetaData or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.AlertsMetaData or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.meta_data.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['identifier'] = self._serialize.query("self.identifier", self.identifier, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AlertsMetaData', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + meta_data.metadata = {'url': '/providers/Microsoft.AlertsManagement/alertsMetaData'} + + def get_all( + self, target_resource=None, target_resource_type=None, target_resource_group=None, monitor_service=None, monitor_condition=None, severity=None, alert_state=None, alert_rule=None, smart_group_id=None, include_context=None, include_egress_config=None, page_count=None, sort_by=None, sort_order=None, select=None, time_range=None, custom_time_range=None, custom_headers=None, raw=False, **operation_config): + """List all existing alerts, where the results can be filtered on the + basis of multiple parameters (e.g. time range). The results can then be + sorted on the basis specific fields, with the default being + lastModifiedDateTime. . + + :param target_resource: Filter by target resource( which is full ARM + ID) Default value is select all. + :type target_resource: str + :param target_resource_type: Filter by target resource type. Default + value is select all. + :type target_resource_type: str + :param target_resource_group: Filter by target resource group name. + Default value is select all. + :type target_resource_group: str + :param monitor_service: Filter by monitor service which generates the + alert instance. Default value is select all. Possible values include: + 'Application Insights', 'ActivityLog Administrative', 'ActivityLog + Security', 'ActivityLog Recommendation', 'ActivityLog Policy', + 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', + 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' + :type monitor_service: str or + ~azure.mgmt.alertsmanagement.models.MonitorService + :param monitor_condition: Filter by monitor condition which is either + 'Fired' or 'Resolved'. Default value is to select all. Possible values + include: 'Fired', 'Resolved' + :type monitor_condition: str or + ~azure.mgmt.alertsmanagement.models.MonitorCondition + :param severity: Filter by severity. Default value is select all. + Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param alert_state: Filter by state of the alert instance. Default + value is to select all. Possible values include: 'New', + 'Acknowledged', 'Closed' + :type alert_state: str or + ~azure.mgmt.alertsmanagement.models.AlertState + :param alert_rule: Filter by specific alert rule. Default value is to + select all. + :type alert_rule: str + :param smart_group_id: Filter the alerts list by the Smart Group Id. + Default value is none. + :type smart_group_id: str + :param include_context: Include context which has contextual data + specific to the monitor service. Default value is false' + :type include_context: bool + :param include_egress_config: Include egress config which would be + used for displaying the content in portal. Default value is 'false'. + :type include_egress_config: bool + :param page_count: Determines number of alerts returned per page in + response. Permissible value is between 1 to 250. When the + "includeContent" filter is selected, maximum value allowed is 25. + Default value is 25. + :type page_count: int + :param sort_by: Sort the query results by input field, Default value + is 'lastModifiedDateTime'. Possible values include: 'name', + 'severity', 'alertState', 'monitorCondition', 'targetResource', + 'targetResourceName', 'targetResourceGroup', 'targetResourceType', + 'startDateTime', 'lastModifiedDateTime' + :type sort_by: str or + ~azure.mgmt.alertsmanagement.models.AlertsSortByFields + :param sort_order: Sort the query results order in either ascending or + descending. Default value is 'desc' for time fields and 'asc' for + others. Possible values include: 'asc', 'desc' + :type sort_order: str + :param select: This filter allows to selection of the fields(comma + separated) which would be part of the essential section. This would + allow to project only the required fields rather than getting entire + content. Default is to fetch all the fields in the essentials + section. + :type select: str + :param time_range: Filter by time range by below listed values. + Default value is 1 day. Possible values include: '1h', '1d', '7d', + '30d' + :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange + :param custom_time_range: Filter by custom time range in the format + / where time is in (ISO-8601 format)'. + Permissible values is within 30 days from query time. Either + timeRange or customTimeRange could be used but not both. Default is + none. + :type custom_time_range: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Alert + :rtype: + ~azure.mgmt.alertsmanagement.models.AlertPaged[~azure.mgmt.alertsmanagement.models.Alert] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.get_all.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if target_resource is not None: + query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') + if monitor_condition is not None: + query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') + if severity is not None: + query_parameters['severity'] = self._serialize.query("severity", severity, 'str') + if alert_state is not None: + query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') + if alert_rule is not None: + query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') + if smart_group_id is not None: + query_parameters['smartGroupId'] = self._serialize.query("smart_group_id", smart_group_id, 'str') + if include_context is not None: + query_parameters['includeContext'] = self._serialize.query("include_context", include_context, 'bool') + if include_egress_config is not None: + query_parameters['includeEgressConfig'] = self._serialize.query("include_egress_config", include_egress_config, 'bool') + if page_count is not None: + query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') + if sort_by is not None: + query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') + if sort_order is not None: + query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') + if select is not None: + query_parameters['select'] = self._serialize.query("select", select, 'str') + if time_range is not None: + query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') + if custom_time_range is not None: + query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.AlertPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + get_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts'} + + def get_by_id( + self, alert_id, custom_headers=None, raw=False, **operation_config): + """Get a specific alert. + + Get information related to a specific alert. + + :param alert_id: Unique ID of an alert instance. + :type alert_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Alert or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.Alert or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_by_id.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'alertId': self._serialize.url("alert_id", alert_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Alert', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}'} + + def change_state( + self, alert_id, new_state, custom_headers=None, raw=False, **operation_config): + """Change the state of an alert. + + :param alert_id: Unique ID of an alert instance. + :type alert_id: str + :param new_state: New state of the alert. Possible values include: + 'New', 'Acknowledged', 'Closed' + :type new_state: str or ~azure.mgmt.alertsmanagement.models.AlertState + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Alert or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.Alert or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.change_state.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'alertId': self._serialize.url("alert_id", alert_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['newState'] = self._serialize.query("new_state", new_state, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Alert', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + change_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate'} + + def get_history( + self, alert_id, custom_headers=None, raw=False, **operation_config): + """Get the history of an alert, which captures any monitor condition + changes (Fired/Resolved) and alert state changes + (New/Acknowledged/Closed). + + :param alert_id: Unique ID of an alert instance. + :type alert_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AlertModification or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.AlertModification or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_history.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'alertId': self._serialize.url("alert_id", alert_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AlertModification', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_history.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history'} + + def get_summary( + self, groupby, include_smart_groups_count=None, target_resource=None, target_resource_type=None, target_resource_group=None, monitor_service=None, monitor_condition=None, severity=None, alert_state=None, alert_rule=None, time_range=None, custom_time_range=None, custom_headers=None, raw=False, **operation_config): + """Get a summarized count of your alerts grouped by various parameters + (e.g. grouping by 'Severity' returns the count of alerts for each + severity). + + :param groupby: This parameter allows the result set to be grouped by + input fields (Maximum 2 comma separated fields supported). For + example, groupby=severity or groupby=severity,alertstate. Possible + values include: 'severity', 'alertState', 'monitorCondition', + 'monitorService', 'signalType', 'alertRule' + :type groupby: str or + ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupByFields + :param include_smart_groups_count: Include count of the SmartGroups as + part of the summary. Default value is 'false'. + :type include_smart_groups_count: bool + :param target_resource: Filter by target resource( which is full ARM + ID) Default value is select all. + :type target_resource: str + :param target_resource_type: Filter by target resource type. Default + value is select all. + :type target_resource_type: str + :param target_resource_group: Filter by target resource group name. + Default value is select all. + :type target_resource_group: str + :param monitor_service: Filter by monitor service which generates the + alert instance. Default value is select all. Possible values include: + 'Application Insights', 'ActivityLog Administrative', 'ActivityLog + Security', 'ActivityLog Recommendation', 'ActivityLog Policy', + 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', + 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' + :type monitor_service: str or + ~azure.mgmt.alertsmanagement.models.MonitorService + :param monitor_condition: Filter by monitor condition which is either + 'Fired' or 'Resolved'. Default value is to select all. Possible values + include: 'Fired', 'Resolved' + :type monitor_condition: str or + ~azure.mgmt.alertsmanagement.models.MonitorCondition + :param severity: Filter by severity. Default value is select all. + Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param alert_state: Filter by state of the alert instance. Default + value is to select all. Possible values include: 'New', + 'Acknowledged', 'Closed' + :type alert_state: str or + ~azure.mgmt.alertsmanagement.models.AlertState + :param alert_rule: Filter by specific alert rule. Default value is to + select all. + :type alert_rule: str + :param time_range: Filter by time range by below listed values. + Default value is 1 day. Possible values include: '1h', '1d', '7d', + '30d' + :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange + :param custom_time_range: Filter by custom time range in the format + / where time is in (ISO-8601 format)'. + Permissible values is within 30 days from query time. Either + timeRange or customTimeRange could be used but not both. Default is + none. + :type custom_time_range: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AlertsSummary or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.AlertsSummary or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_summary.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['groupby'] = self._serialize.query("groupby", groupby, 'str') + if include_smart_groups_count is not None: + query_parameters['includeSmartGroupsCount'] = self._serialize.query("include_smart_groups_count", include_smart_groups_count, 'bool') + if target_resource is not None: + query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') + if monitor_condition is not None: + query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') + if severity is not None: + query_parameters['severity'] = self._serialize.query("severity", severity, 'str') + if alert_state is not None: + query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') + if alert_rule is not None: + query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') + if time_range is not None: + query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') + if custom_time_range is not None: + query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AlertsSummary', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_summary.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertsSummary'} diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_operations.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_operations.py new file mode 100644 index 00000000000..057900f678f --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_operations.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class Operations(object): + """Operations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: client API version. Constant value: "2019-05-05-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-05-05-preview" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """List all operations available through Azure Alerts Management Resource + Provider. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Operation + :rtype: + ~azure.mgmt.alertsmanagement.models.OperationPaged[~azure.mgmt.alertsmanagement.models.Operation] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.AlertsManagement/operations'} diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_detector_alert_rules_operations.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_detector_alert_rules_operations.py new file mode 100644 index 00000000000..8119e32986f --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_detector_alert_rules_operations.py @@ -0,0 +1,436 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class SmartDetectorAlertRulesOperations(object): + """SmartDetectorAlertRulesOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Client Api Version. Constant value: "2019-06-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-06-01" + + self.config = config + + def list( + self, expand_detector=None, custom_headers=None, raw=False, **operation_config): + """List all the existing Smart Detector alert rules within the + subscription. + + :param expand_detector: Indicates if Smart Detector should be + expanded. + :type expand_detector: bool + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of AlertRule + :rtype: + ~azure.mgmt.alertsmanagement.models.AlertRulePaged[~azure.mgmt.alertsmanagement.models.AlertRule] + :raises: + :class:`ErrorResponse1Exception` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if expand_detector is not None: + query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponse1Exception(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.AlertRulePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} + + def list_by_resource_group( + self, resource_group_name, expand_detector=None, custom_headers=None, raw=False, **operation_config): + """List all the existing Smart Detector alert rules within the + subscription and resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param expand_detector: Indicates if Smart Detector should be + expanded. + :type expand_detector: bool + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of AlertRule + :rtype: + ~azure.mgmt.alertsmanagement.models.AlertRulePaged[~azure.mgmt.alertsmanagement.models.AlertRule] + :raises: + :class:`ErrorResponse1Exception` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if expand_detector is not None: + query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponse1Exception(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.AlertRulePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} + + def get( + self, resource_group_name, alert_rule_name, expand_detector=None, custom_headers=None, raw=False, **operation_config): + """Get a specific Smart Detector alert rule. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param alert_rule_name: The name of the alert rule. + :type alert_rule_name: str + :param expand_detector: Indicates if Smart Detector should be + expanded. + :type expand_detector: bool + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AlertRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponse1Exception` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if expand_detector is not None: + query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponse1Exception(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AlertRule', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} + + def create_or_update( + self, resource_group_name, alert_rule_name, parameters, custom_headers=None, raw=False, **operation_config): + """Create or update a Smart Detector alert rule. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param alert_rule_name: The name of the alert rule. + :type alert_rule_name: str + :param parameters: Parameters supplied to the operation. + :type parameters: ~azure.mgmt.alertsmanagement.models.AlertRule + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AlertRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponse1Exception` + """ + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'AlertRule') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponse1Exception(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AlertRule', response) + if response.status_code == 201: + deserialized = self._deserialize('AlertRule', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} + + def patch( + self, resource_group_name, alert_rule_name, parameters, custom_headers=None, raw=False, **operation_config): + """Patch a specific Smart Detector alert rule. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param alert_rule_name: The name of the alert rule. + :type alert_rule_name: str + :param parameters: Parameters supplied to the operation. + :type parameters: + ~azure.mgmt.alertsmanagement.models.AlertRulePatchObject + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AlertRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponse1Exception` + """ + # Construct URL + url = self.patch.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'AlertRulePatchObject') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponse1Exception(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('AlertRule', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} + + def delete( + self, resource_group_name, alert_rule_name, custom_headers=None, raw=False, **operation_config): + """Delete an existing Smart Detector alert rule. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param alert_rule_name: The name of the alert rule. + :type alert_rule_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponse1Exception` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 204]: + raise models.ErrorResponse1Exception(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_groups_operations.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_groups_operations.py new file mode 100644 index 00000000000..c797322bad4 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/operations/_smart_groups_operations.py @@ -0,0 +1,365 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class SmartGroupsOperations(object): + """SmartGroupsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: client API version. Constant value: "2019-05-05-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-05-05-preview" + + self.config = config + + def get_all( + self, target_resource=None, target_resource_group=None, target_resource_type=None, monitor_service=None, monitor_condition=None, severity=None, smart_group_state=None, time_range=None, page_count=None, sort_by=None, sort_order=None, custom_headers=None, raw=False, **operation_config): + """Get all Smart Groups within a specified subscription. + + List all the Smart Groups within a specified subscription. . + + :param target_resource: Filter by target resource( which is full ARM + ID) Default value is select all. + :type target_resource: str + :param target_resource_group: Filter by target resource group name. + Default value is select all. + :type target_resource_group: str + :param target_resource_type: Filter by target resource type. Default + value is select all. + :type target_resource_type: str + :param monitor_service: Filter by monitor service which generates the + alert instance. Default value is select all. Possible values include: + 'Application Insights', 'ActivityLog Administrative', 'ActivityLog + Security', 'ActivityLog Recommendation', 'ActivityLog Policy', + 'ActivityLog Autoscale', 'Log Analytics', 'Nagios', 'Platform', + 'SCOM', 'ServiceHealth', 'SmartDetector', 'VM Insights', 'Zabbix' + :type monitor_service: str or + ~azure.mgmt.alertsmanagement.models.MonitorService + :param monitor_condition: Filter by monitor condition which is either + 'Fired' or 'Resolved'. Default value is to select all. Possible values + include: 'Fired', 'Resolved' + :type monitor_condition: str or + ~azure.mgmt.alertsmanagement.models.MonitorCondition + :param severity: Filter by severity. Default value is select all. + Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4' + :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity + :param smart_group_state: Filter by state of the smart group. Default + value is to select all. Possible values include: 'New', + 'Acknowledged', 'Closed' + :type smart_group_state: str or + ~azure.mgmt.alertsmanagement.models.AlertState + :param time_range: Filter by time range by below listed values. + Default value is 1 day. Possible values include: '1h', '1d', '7d', + '30d' + :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange + :param page_count: Determines number of alerts returned per page in + response. Permissible value is between 1 to 250. When the + "includeContent" filter is selected, maximum value allowed is 25. + Default value is 25. + :type page_count: int + :param sort_by: Sort the query results by input field. Default value + is sort by 'lastModifiedDateTime'. Possible values include: + 'alertsCount', 'state', 'severity', 'startDateTime', + 'lastModifiedDateTime' + :type sort_by: str or + ~azure.mgmt.alertsmanagement.models.SmartGroupsSortByFields + :param sort_order: Sort the query results order in either ascending or + descending. Default value is 'desc' for time fields and 'asc' for + others. Possible values include: 'asc', 'desc' + :type sort_order: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of SmartGroup + :rtype: + ~azure.mgmt.alertsmanagement.models.SmartGroupPaged[~azure.mgmt.alertsmanagement.models.SmartGroup] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.get_all.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if target_resource is not None: + query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') + if monitor_condition is not None: + query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') + if severity is not None: + query_parameters['severity'] = self._serialize.query("severity", severity, 'str') + if smart_group_state is not None: + query_parameters['smartGroupState'] = self._serialize.query("smart_group_state", smart_group_state, 'str') + if time_range is not None: + query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') + if page_count is not None: + query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') + if sort_by is not None: + query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') + if sort_order is not None: + query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.SmartGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + get_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups'} + + def get_by_id( + self, smart_group_id, custom_headers=None, raw=False, **operation_config): + """Get information related to a specific Smart Group. + + Get information related to a specific Smart Group. + + :param smart_group_id: Smart group unique id. + :type smart_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SmartGroup or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.SmartGroup or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_by_id.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SmartGroup', response) + header_dict = { + 'x-ms-request-id': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}'} + + def change_state( + self, smart_group_id, new_state, custom_headers=None, raw=False, **operation_config): + """Change the state of a Smart Group. + + :param smart_group_id: Smart group unique id. + :type smart_group_id: str + :param new_state: New state of the alert. Possible values include: + 'New', 'Acknowledged', 'Closed' + :type new_state: str or ~azure.mgmt.alertsmanagement.models.AlertState + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SmartGroup or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.SmartGroup or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.change_state.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['newState'] = self._serialize.query("new_state", new_state, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + header_dict = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SmartGroup', response) + header_dict = { + 'x-ms-request-id': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + change_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/changeState'} + + def get_history( + self, smart_group_id, custom_headers=None, raw=False, **operation_config): + """Get the history a smart group, which captures any Smart Group state + changes (New/Acknowledged/Closed) . + + :param smart_group_id: Smart group unique id. + :type smart_group_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SmartGroupModification or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.alertsmanagement.models.SmartGroupModification or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_history.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SmartGroupModification', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_history.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/history'} diff --git a/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/version.py b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/version.py new file mode 100644 index 00000000000..ab536c887f8 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/vendored_sdks/alertsmanagement/version.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.2.0rc2" + diff --git a/src/alertsmanagement/setup.cfg b/src/alertsmanagement/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/src/alertsmanagement/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/alertsmanagement/setup.py b/src/alertsmanagement/setup.py new file mode 100644 index 00000000000..1e82c81bd5b --- /dev/null +++ b/src/alertsmanagement/setup.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.rst', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='alertsmanagement', + version=VERSION, + description='Microsoft Azure Command-Line Tools Alerts Extension', + # TODO: Update author and email, if applicable + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + # TODO: consider pointing directly to your source code instead of the generic repo + url='https://github.com/Azure/azure-cli-extensions', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_alertsmanagement': ['azext_metadata.json']}, +) \ No newline at end of file From 0b5607a3048a26cd4455c6d7fcc24d7e166990d2 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Fri, 17 Jan 2020 10:16:58 +0800 Subject: [PATCH 02/41] Update --- .../azext_alertsmanagement/_help.py | 119 ++++----- .../azext_alertsmanagement/_params.py | 42 +-- .../azext_metadata.json | 2 +- .../azext_alertsmanagement/commands.py | 52 ++-- .../azext_alertsmanagement/custom.py | 249 +++++++++--------- .../latest/test_alertsmanagement_scenario.py | 48 ++-- src/alertsmanagement/setup.py | 2 +- 7 files changed, 256 insertions(+), 258 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index 0ae885224a2..77f8917b27e 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -9,230 +9,231 @@ from knack.help_files import helps # pylint: disable=unused-import -helps['alertsmanagement'] = """ +helps['alertsmanagement operation'] = """ type: group - short-summary: Commands to manage alertsmanagement. + short-summary: Commands to manage alertsmanagement operation. """ -helps['alertsmanagement list'] = """ +helps['alertsmanagement operation list'] = """ type: command short-summary: List all operations available through Azure Alerts Management Resource Provider. """ -helps['alertsmanagement changestate'] = """ +helps['alertsmanagement alert'] = """ type: group - short-summary: Commands to manage alertsmanagement changestate. + short-summary: Commands to manage alertsmanagement alert. """ -helps['alertsmanagement changestate change_state'] = """ +helps['alertsmanagement alert change-state'] = """ type: command short-summary: Change the state of an alert. examples: - name: Resolve text: |- - az alertsmanagement changestate change_state --alert-id \\ - "66114d64-d9d9-478b-95c9-b789d6502100" --new-state "Acknowledged" + az alertsmanagement alert change-state --alert-id "66114d64-d9d9-478b-95c9-b789d6502100" \\ + --new-state "Acknowledged" """ -helps['alertsmanagement changestate meta_data'] = """ +helps['alertsmanagement alert meta-data'] = """ type: command short-summary: List alerts meta data information based on value of identifier parameter. examples: - name: MonService text: |- - az alertsmanagement changestate meta_data --identifier "MonitorServiceList" + az alertsmanagement alert meta-data --identifier "MonitorServiceList" """ -helps['alertsmanagement changestate get_all'] = """ +helps['alertsmanagement alert get-all'] = """ type: command short-summary: List all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. time range). The results can then be sorted on the basis specific fields, with the default being lastModifiedDateTime. examples: - name: ListAlerts text: |- - az alertsmanagement changestate get_all + az alertsmanagement alert get-all """ -helps['alertsmanagement changestate get_by_id'] = """ +helps['alertsmanagement alert get-by-id'] = """ type: command short-summary: Get information related to a specific alert examples: - name: GetById text: |- - az alertsmanagement changestate get_by_id --alert-id \\ - "66114d64-d9d9-478b-95c9-b789d6502100" + az alertsmanagement alert get-by-id --alert-id "66114d64-d9d9-478b-95c9-b789d6502100" """ -helps['alertsmanagement changestate get_history'] = """ +helps['alertsmanagement alert get-history'] = """ type: command short-summary: Get the history of an alert, which captures any monitor condition changes (Fired/Resolved) and alert state changes (New/Acknowledged/Closed). examples: - name: Resolve text: |- - az alertsmanagement changestate get_history --alert-id \\ - "66114d64-d9d9-478b-95c9-b789d6502100" + az alertsmanagement alert get-history --alert-id "66114d64-d9d9-478b-95c9-b789d6502100" """ -helps['alertsmanagement changestate get_summary'] = """ +helps['alertsmanagement alert get-summary'] = """ type: command short-summary: Get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns the count of alerts for each severity). examples: - name: Summary text: |- - az alertsmanagement changestate get_summary --groupby "severity,alertState" + az alertsmanagement alert get-summary --groupby "severity,alertState" """ -helps['alertsmanagement change-state'] = """ +helps['alertsmanagement smart-group'] = """ type: group - short-summary: Commands to manage alertsmanagement change state. + short-summary: Commands to manage alertsmanagement smart group. """ -helps['alertsmanagement change-state change_state'] = """ +helps['alertsmanagement smart-group change-state'] = """ type: command short-summary: Change the state of a Smart Group. examples: - name: changestate text: |- - az alertsmanagement change-state change_state --smart-group-id \\ + az alertsmanagement smart-group change-state --smart-group-id \\ "a808445e-bb38-4751-85c2-1b109ccc1059" --new-state "Acknowledged" """ -helps['alertsmanagement change-state get_all'] = """ +helps['alertsmanagement smart-group get-all'] = """ type: command short-summary: List all the Smart Groups within a specified subscription. examples: - name: List text: |- - az alertsmanagement change-state get_all + az alertsmanagement smart-group get-all """ -helps['alertsmanagement change-state get_by_id'] = """ +helps['alertsmanagement smart-group get-by-id'] = """ type: command short-summary: Get information related to a specific Smart Group. examples: - name: Get text: |- - az alertsmanagement change-state get_by_id --smart-group-id \\ + az alertsmanagement smart-group get-by-id --smart-group-id \\ "603675da-9851-4b26-854a-49fc53d32715" """ -helps['alertsmanagement change-state get_history'] = """ +helps['alertsmanagement smart-group get-history'] = """ type: command short-summary: Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) . examples: - name: Resolve text: |- - az alertsmanagement change-state get_history --smart-group-id \\ + az alertsmanagement smart-group get-history --smart-group-id \\ "a808445e-bb38-4751-85c2-1b109ccc1059" """ -helps['alertsmanagement'] = """ +helps['alertsmanagement action-rule'] = """ type: group - short-summary: Commands to manage alertsmanagement. + short-summary: Commands to manage alertsmanagement action rule. """ -helps['alertsmanagement create'] = """ +helps['alertsmanagement action-rule create'] = """ type: command short-summary: Creates/Updates a specific action rule examples: - name: PutActionRule text: |- - az alertsmanagement create --resource-group "alertscorrelationrg" --name \\ + az alertsmanagement action-rule create --resource-group "alertscorrelationrg" --name \\ "DailySuppression" --location "Global" --status "Enabled" """ -helps['alertsmanagement update'] = """ +helps['alertsmanagement action-rule update'] = """ type: command short-summary: Creates/Updates a specific action rule examples: - name: PatchActionRule text: |- - az alertsmanagement update --resource-group "alertscorrelationrg" --name \\ + az alertsmanagement action-rule update --resource-group "alertscorrelationrg" --name \\ "WeeklySuppression" --status "Disabled" """ -helps['alertsmanagement delete'] = """ +helps['alertsmanagement action-rule delete'] = """ type: command short-summary: Deletes a given action rule examples: - name: DeleteActionRule text: |- - az alertsmanagement delete --resource-group "alertscorrelationrg" --name \\ + az alertsmanagement action-rule delete --resource-group "alertscorrelationrg" --name \\ "DailySuppression" """ -helps['alertsmanagement show'] = """ +helps['alertsmanagement action-rule show'] = """ type: command short-summary: Get a specific action rule examples: - name: GetActionRuleById text: |- - az alertsmanagement show --resource-group "alertscorrelationrg" --name "DailySuppression" + az alertsmanagement action-rule show --resource-group "alertscorrelationrg" --name \\ + "DailySuppression" """ -helps['alertsmanagement list'] = """ +helps['alertsmanagement action-rule list'] = """ type: command short-summary: List all action rules of the subscription, created in given resource group and given input filters examples: - name: GetActionRulesSubscriptionWide text: |- - az alertsmanagement list + az alertsmanagement action-rule list - name: GetActionRulesResourceGroupWide text: |- - az alertsmanagement list --resource-group "alertscorrelationrg" + az alertsmanagement action-rule list --resource-group "alertscorrelationrg" """ -helps['alertsmanagement'] = """ +helps['alertsmanagement smart-detector-alert-rule'] = """ type: group - short-summary: Commands to manage alertsmanagement. + short-summary: Commands to manage alertsmanagement smart detector alert rule. """ -helps['alertsmanagement create'] = """ +helps['alertsmanagement smart-detector-alert-rule create'] = """ type: command short-summary: Create or update a Smart Detector alert rule. examples: - name: Create or update a Smart Detector alert rule text: |- - az alertsmanagement create --resource-group "MyAlertRules" --name "MyAlertRule" \\ - --description "Sample smart detector alert rule description" --state "Enabled" --severity \\ - "Sev3" --frequency "PT5M" + az alertsmanagement smart-detector-alert-rule create --resource-group "MyAlertRules" \\ + --name "MyAlertRule" --description "Sample smart detector alert rule description" --state \\ + "Enabled" --severity "Sev3" --frequency "PT5M" """ -helps['alertsmanagement update'] = """ +helps['alertsmanagement smart-detector-alert-rule update'] = """ type: command short-summary: Create or update a Smart Detector alert rule. examples: - name: Patch alert rules text: |- - az alertsmanagement update --resource-group "MyAlertRules" --name "MyAlertRule" \\ - --description "New description for patching" --frequency "PT1M" + az alertsmanagement smart-detector-alert-rule update --resource-group "MyAlertRules" \\ + --name "MyAlertRule" --description "New description for patching" --frequency "PT1M" """ -helps['alertsmanagement delete'] = """ +helps['alertsmanagement smart-detector-alert-rule delete'] = """ type: command short-summary: Delete an existing Smart Detector alert rule. examples: - name: Delete a Smart Detector alert rule text: |- - az alertsmanagement delete --resource-group "MyAlertRules" --name "MyAlertRule" + az alertsmanagement smart-detector-alert-rule delete --resource-group "MyAlertRules" \\ + --name "MyAlertRule" """ -helps['alertsmanagement show'] = """ +helps['alertsmanagement smart-detector-alert-rule show'] = """ type: command short-summary: Get a specific Smart Detector alert rule. examples: - name: Get a Smart Detector alert rule text: |- - az alertsmanagement show --resource-group "MyAlertRules" --name "MyAlertRule" + az alertsmanagement smart-detector-alert-rule show --resource-group "MyAlertRules" --name \\ + "MyAlertRule" """ -helps['alertsmanagement list'] = """ +helps['alertsmanagement smart-detector-alert-rule list'] = """ type: command short-summary: List all the existing Smart Detector alert rules within the subscription and resource group. examples: - name: List Smart Detector alert rules text: |- - az alertsmanagement list --resource-group "MyAlertRules" + az alertsmanagement smart-detector-alert-rule list --resource-group "MyAlertRules" - name: List alert rules text: |- - az alertsmanagement list --resource-group "MyAlertRules" + az alertsmanagement smart-detector-alert-rule list --resource-group "MyAlertRules" """ diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index f08e5bfe4ac..cc33da7a5a3 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -17,17 +17,17 @@ def load_arguments(self, _): - with self.argument_context('alertsmanagement list') as c: + with self.argument_context('alertsmanagement operation list') as c: pass - with self.argument_context('alertsmanagement changestate change_state') as c: + with self.argument_context('alertsmanagement alert change-state') as c: c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') c.argument('new_state', id_part=None, help='New state of the alert.') - with self.argument_context('alertsmanagement changestate meta_data') as c: + with self.argument_context('alertsmanagement alert meta-data') as c: c.argument('identifier', id_part=None, help='Identification of the information to be retrieved by API call.') - with self.argument_context('alertsmanagement changestate get_all') as c: + with self.argument_context('alertsmanagement alert get-all') as c: c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') @@ -46,13 +46,13 @@ def load_arguments(self, _): c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') c.argument('custom_time_range', id_part=None, help='Filter by custom time range in the format / where time is in (ISO-8601 format)\'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none.') - with self.argument_context('alertsmanagement changestate get_by_id') as c: + with self.argument_context('alertsmanagement alert get-by-id') as c: c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') - with self.argument_context('alertsmanagement changestate get_history') as c: + with self.argument_context('alertsmanagement alert get-history') as c: c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') - with self.argument_context('alertsmanagement changestate get_summary') as c: + with self.argument_context('alertsmanagement alert get-summary') as c: c.argument('groupby', id_part=None, help='This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). For example, groupby=severity or groupby=severity,alertstate.') c.argument('include_smart_groups_count', arg_type=get_three_state_flag(), id_part=None, help='Include count of the SmartGroups as part of the summary. Default value is \'false\'.') c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') @@ -66,11 +66,11 @@ def load_arguments(self, _): c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') c.argument('custom_time_range', id_part=None, help='Filter by custom time range in the format / where time is in (ISO-8601 format)\'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none.') - with self.argument_context('alertsmanagement change-state change_state') as c: + with self.argument_context('alertsmanagement smart-group change-state') as c: c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') c.argument('new_state', id_part=None, help='New state of the alert.') - with self.argument_context('alertsmanagement change-state get_all') as c: + with self.argument_context('alertsmanagement smart-group get-all') as c: c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') @@ -83,35 +83,35 @@ def load_arguments(self, _): c.argument('sort_by', id_part=None, help='Sort the query results by input field. Default value is sort by \'lastModifiedDateTime\'.') c.argument('sort_order', id_part=None, help='Sort the query results order in either ascending or descending. Default value is \'desc\' for time fields and \'asc\' for others.') - with self.argument_context('alertsmanagement change-state get_by_id') as c: + with self.argument_context('alertsmanagement smart-group get-by-id') as c: c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') - with self.argument_context('alertsmanagement change-state get_history') as c: + with self.argument_context('alertsmanagement smart-group get-history') as c: c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') - with self.argument_context('alertsmanagement create') as c: + with self.argument_context('alertsmanagement action-rule create') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name that needs to be updated') c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') - with self.argument_context('alertsmanagement update') as c: + with self.argument_context('alertsmanagement action-rule update') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name that needs to be updated') c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') - with self.argument_context('alertsmanagement delete') as c: + with self.argument_context('alertsmanagement action-rule delete') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name that needs to be updated') - with self.argument_context('alertsmanagement show') as c: + with self.argument_context('alertsmanagement action-rule show') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name that needs to be updated') - with self.argument_context('alertsmanagement list') as c: + with self.argument_context('alertsmanagement action-rule list') as c: c.argument('resource_group', resource_group_name_type) c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') @@ -124,7 +124,7 @@ def load_arguments(self, _): c.argument('action_group', id_part=None, help='filter by action group configured as part of action rule') c.argument('name', id_part=None, help='filter by action rule name') - with self.argument_context('alertsmanagement create') as c: + with self.argument_context('alertsmanagement smart-detector-alert-rule create') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name of the alert rule.') c.argument('location', arg_type=get_location_type(self.cli_ctx)) @@ -136,7 +136,7 @@ def load_arguments(self, _): c.argument('action_groups', id_part=None, help='The alert rule actions.') c.argument('throttling', id_part=None, help='The alert rule throttling information.') - with self.argument_context('alertsmanagement update') as c: + with self.argument_context('alertsmanagement smart-detector-alert-rule update') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name of the alert rule.') c.argument('location', arg_type=get_location_type(self.cli_ctx)) @@ -148,15 +148,15 @@ def load_arguments(self, _): c.argument('action_groups', id_part=None, help='The alert rule actions.') c.argument('throttling', id_part=None, help='The alert rule throttling information.') - with self.argument_context('alertsmanagement delete') as c: + with self.argument_context('alertsmanagement smart-detector-alert-rule delete') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name of the alert rule.') - with self.argument_context('alertsmanagement show') as c: + with self.argument_context('alertsmanagement smart-detector-alert-rule show') as c: c.argument('resource_group', resource_group_name_type) c.argument('name', id_part=None, help='The name of the alert rule.') c.argument('expand_detector', arg_type=get_three_state_flag(), id_part=None, help='Indicates if Smart Detector should be expanded.') - with self.argument_context('alertsmanagement list') as c: + with self.argument_context('alertsmanagement smart-detector-alert-rule list') as c: c.argument('resource_group', resource_group_name_type) c.argument('expand_detector', arg_type=get_three_state_flag(), id_part=None, help='Indicates if Smart Detector should be expanded.') diff --git a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json index 4060dd78264..86f8b02db32 100644 --- a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json +++ b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json @@ -1,5 +1,5 @@ { "azext.isPreview": true, "azext.minCliCoreVersion": "2.0.67", - "azext.maxCliCoreVersion": "2.1.0" + "azext.maxCliCoreVersion": "3.0.0" } \ No newline at end of file diff --git a/src/alertsmanagement/azext_alertsmanagement/commands.py b/src/alertsmanagement/azext_alertsmanagement/commands.py index 3067e4d56b2..c20c65b0f14 100644 --- a/src/alertsmanagement/azext_alertsmanagement/commands.py +++ b/src/alertsmanagement/azext_alertsmanagement/commands.py @@ -16,49 +16,49 @@ def load_command_table(self, _): alertsmanagement_operations = CliCommandType( operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._operations_operations#OperationsOperations.{}', client_factory=cf_operations) - with self.command_group('alertsmanagement', alertsmanagement_operations, client_factory=cf_operations) as g: - g.custom_command('list', 'list_alertsmanagement') + with self.command_group('alertsmanagement operation', alertsmanagement_operations, client_factory=cf_operations) as g: + g.custom_command('list', 'list_alertsmanagement_operation') from ._client_factory import cf_alerts alertsmanagement_alerts = CliCommandType( operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._alerts_operations#AlertsOperations.{}', client_factory=cf_alerts) - with self.command_group('alertsmanagement changestate', alertsmanagement_alerts, client_factory=cf_alerts) as g: - g.custom_command('change_state', 'change_state_alertsmanagement_changestate') - g.custom_command('meta_data', 'meta_data_alertsmanagement_changestate') - g.custom_command('get_all', 'get_all_alertsmanagement_changestate') - g.custom_command('get_by_id', 'get_by_id_alertsmanagement_changestate') - g.custom_command('get_history', 'get_history_alertsmanagement_changestate') - g.custom_command('get_summary', 'get_summary_alertsmanagement_changestate') + with self.command_group('alertsmanagement alert', alertsmanagement_alerts, client_factory=cf_alerts) as g: + g.custom_command('change-state', 'change_state_alertsmanagement_alert') + g.custom_command('meta-data', 'meta_data_alertsmanagement_alert') + g.custom_command('get-all', 'get_all_alertsmanagement_alert') + g.custom_command('get-by-id', 'get_by_id_alertsmanagement_alert') + g.custom_command('get-history', 'get_history_alertsmanagement_alert') + g.custom_command('get-summary', 'get_summary_alertsmanagement_alert') from ._client_factory import cf_smart_groups alertsmanagement_smart_groups = CliCommandType( operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._smart_groups_operations#SmartGroupsOperations.{}', client_factory=cf_smart_groups) - with self.command_group('alertsmanagement change-state', alertsmanagement_smart_groups, client_factory=cf_smart_groups) as g: - g.custom_command('change_state', 'change_state_alertsmanagement_change_state') - g.custom_command('get_all', 'get_all_alertsmanagement_change_state') - g.custom_command('get_by_id', 'get_by_id_alertsmanagement_change_state') - g.custom_command('get_history', 'get_history_alertsmanagement_change_state') + with self.command_group('alertsmanagement smart-group', alertsmanagement_smart_groups, client_factory=cf_smart_groups) as g: + g.custom_command('change-state', 'change_state_alertsmanagement_smart_group') + g.custom_command('get-all', 'get_all_alertsmanagement_smart_group') + g.custom_command('get-by-id', 'get_by_id_alertsmanagement_smart_group') + g.custom_command('get-history', 'get_history_alertsmanagement_smart_group') from ._client_factory import cf_action_rules alertsmanagement_action_rules = CliCommandType( operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._action_rules_operations#ActionRulesOperations.{}', client_factory=cf_action_rules) - with self.command_group('alertsmanagement', alertsmanagement_action_rules, client_factory=cf_action_rules) as g: - g.custom_command('create', 'create_alertsmanagement') - g.custom_command('update', 'update_alertsmanagement') - g.custom_command('delete', 'delete_alertsmanagement') - g.custom_command('show', 'get_alertsmanagement') - g.custom_command('list', 'list_alertsmanagement') + with self.command_group('alertsmanagement action-rule', alertsmanagement_action_rules, client_factory=cf_action_rules) as g: + g.custom_command('create', 'create_alertsmanagement_action_rule') + g.custom_command('update', 'update_alertsmanagement_action_rule') + g.custom_command('delete', 'delete_alertsmanagement_action_rule') + g.custom_show_command('show', 'get_alertsmanagement_action_rule') + g.custom_command('list', 'list_alertsmanagement_action_rule') from ._client_factory import cf_smart_detector_alert_rules alertsmanagement_smart_detector_alert_rules = CliCommandType( operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._smart_detector_alert_rules_operations#SmartDetectorAlertRulesOperations.{}', client_factory=cf_smart_detector_alert_rules) - with self.command_group('alertsmanagement', alertsmanagement_smart_detector_alert_rules, client_factory=cf_smart_detector_alert_rules) as g: - g.custom_command('create', 'create_alertsmanagement') - g.custom_command('update', 'update_alertsmanagement') - g.custom_command('delete', 'delete_alertsmanagement') - g.custom_command('show', 'get_alertsmanagement') - g.custom_command('list', 'list_alertsmanagement') + with self.command_group('alertsmanagement smart-detector-alert-rule', alertsmanagement_smart_detector_alert_rules, client_factory=cf_smart_detector_alert_rules) as g: + g.custom_command('create', 'create_alertsmanagement_smart_detector_alert_rule') + g.custom_command('update', 'update_alertsmanagement_smart_detector_alert_rule') + g.custom_command('delete', 'delete_alertsmanagement_smart_detector_alert_rule') + g.custom_show_command('show', 'get_alertsmanagement_smart_detector_alert_rule') + g.custom_command('list', 'list_alertsmanagement_smart_detector_alert_rule') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 685dc27518a..f901f3917da 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -7,107 +7,108 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-locals # pylint: disable=unused-argument +import json -def list_alertsmanagement(cmd, client): +def list_alertsmanagement_operation(cmd, client): return client.list() -def change_state_alertsmanagement_changestate(cmd, client, - alert_id, - new_state=None): +def change_state_alertsmanagement_alert(cmd, client, + alert_id, + new_state=None): return client.change_state(alert_id=alert_id, new_state=new_state) -def meta_data_alertsmanagement_changestate(cmd, client, - identifier=None): +def meta_data_alertsmanagement_alert(cmd, client, + identifier=None): return client.meta_data(identifier=identifier) -def get_all_alertsmanagement_changestate(cmd, client, - target_resource=None, - target_resource_type=None, - target_resource_group=None, - monitor_service=None, - monitor_condition=None, - severity=None, - alert_state=None, - alert_rule=None, - smart_group_id=None, - include_context=None, - include_egress_config=None, - page_count=None, - sort_by=None, - sort_order=None, - select=None, - time_range=None, - custom_time_range=None): +def get_all_alertsmanagement_alert(cmd, client, + target_resource=None, + target_resource_type=None, + target_resource_group=None, + monitor_service=None, + monitor_condition=None, + severity=None, + alert_state=None, + alert_rule=None, + smart_group_id=None, + include_context=None, + include_egress_config=None, + page_count=None, + sort_by=None, + sort_order=None, + select=None, + time_range=None, + custom_time_range=None): return client.get_all(target_resource=target_resource, target_resource_type=target_resource_type, target_resource_group=target_resource_group, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, alert_rule=alert_rule, smart_group_id=smart_group_id, include_context=include_context, include_egress_config=include_egress_config, page_count=page_count, sort_by=sort_by, sort_order=sort_order, select=select, time_range=time_range, custom_time_range=custom_time_range) -def get_by_id_alertsmanagement_changestate(cmd, client, - alert_id): +def get_by_id_alertsmanagement_alert(cmd, client, + alert_id): return client.get_by_id(alert_id=alert_id) -def get_history_alertsmanagement_changestate(cmd, client, - alert_id): +def get_history_alertsmanagement_alert(cmd, client, + alert_id): return client.get_history(alert_id=alert_id) -def get_summary_alertsmanagement_changestate(cmd, client, - groupby=None, - include_smart_groups_count=None, - target_resource=None, - target_resource_type=None, - target_resource_group=None, - monitor_service=None, - monitor_condition=None, - severity=None, - alert_state=None, - alert_rule=None, - time_range=None, - custom_time_range=None): +def get_summary_alertsmanagement_alert(cmd, client, + groupby=None, + include_smart_groups_count=None, + target_resource=None, + target_resource_type=None, + target_resource_group=None, + monitor_service=None, + monitor_condition=None, + severity=None, + alert_state=None, + alert_rule=None, + time_range=None, + custom_time_range=None): return client.get_summary(groupby=groupby, include_smart_groups_count=include_smart_groups_count, target_resource=target_resource, target_resource_type=target_resource_type, target_resource_group=target_resource_group, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, alert_rule=alert_rule, time_range=time_range, custom_time_range=custom_time_range) -def change_state_alertsmanagement_change_state(cmd, client, - smart_group_id, - new_state=None): +def change_state_alertsmanagement_smart_group(cmd, client, + smart_group_id, + new_state=None): return client.change_state(smart_group_id=smart_group_id, new_state=new_state) -def get_all_alertsmanagement_change_state(cmd, client, - target_resource=None, - target_resource_group=None, - target_resource_type=None, - monitor_service=None, - monitor_condition=None, - severity=None, - smart_group_state=None, - time_range=None, - page_count=None, - sort_by=None, - sort_order=None): +def get_all_alertsmanagement_smart_group(cmd, client, + target_resource=None, + target_resource_group=None, + target_resource_type=None, + monitor_service=None, + monitor_condition=None, + severity=None, + smart_group_state=None, + time_range=None, + page_count=None, + sort_by=None, + sort_order=None): return client.get_all(target_resource=target_resource, target_resource_group=target_resource_group, target_resource_type=target_resource_type, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, smart_group_state=smart_group_state, time_range=time_range, page_count=page_count, sort_by=sort_by, sort_order=sort_order) -def get_by_id_alertsmanagement_change_state(cmd, client, - smart_group_id): +def get_by_id_alertsmanagement_smart_group(cmd, client, + smart_group_id): return client.get_by_id(smart_group_id=smart_group_id) -def get_history_alertsmanagement_change_state(cmd, client, - smart_group_id): +def get_history_alertsmanagement_smart_group(cmd, client, + smart_group_id): return client.get_history(smart_group_id=smart_group_id) -def create_alertsmanagement(cmd, client, - resource_group, - name, - location, - tags=None, - status=None): +def create_alertsmanagement_action_rule(cmd, client, + resource_group, + name, + location, + tags=None, + status=None): body = {} body['location'] = location # str body['tags'] = tags # unknown-primary[object] @@ -115,13 +116,13 @@ def create_alertsmanagement(cmd, client, return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) -def update_alertsmanagement(cmd, client, - resource_group, - name, - location=None, - tags=None, - status=None): - body = client.get_by_name(resource_group_name=resource_group, action_rule_name=name).as_dict() +def update_alertsmanagement_action_rule(cmd, client, + resource_group, + name, + location=None, + tags=None, + status=None): + body = {} if location is not None: body['location'] = location # str if tags is not None: @@ -131,46 +132,46 @@ def update_alertsmanagement(cmd, client, return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) -def delete_alertsmanagement(cmd, client, - resource_group, - name): +def delete_alertsmanagement_action_rule(cmd, client, + resource_group, + name): return client.delete(resource_group_name=resource_group, action_rule_name=name) -def get_alertsmanagement(cmd, client, - resource_group, - name): +def get_alertsmanagement_action_rule(cmd, client, + resource_group, + name): return client.get_by_name(resource_group_name=resource_group, action_rule_name=name) -def list_alertsmanagement(cmd, client, - resource_group, - target_resource_group=None, - target_resource_type=None, - target_resource=None, - severity=None, - monitor_service=None, - impacted_scope=None, - description=None, - alert_rule_id=None, - action_group=None, - name=None): +def list_alertsmanagement_action_rule(cmd, client, + resource_group=None, + target_resource_group=None, + target_resource_type=None, + target_resource=None, + severity=None, + monitor_service=None, + impacted_scope=None, + description=None, + alert_rule_id=None, + action_group=None, + name=None): if resource_group is not None and target_resource_group is not None and target_resource_type is not None and target_resource is not None and severity is not None and monitor_service is not None and impacted_scope is not None and description is not None and alert_rule_id is not None and action_group is not None and name is not None: return client.list_by_resource_group(resource_group_name=resource_group, target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) return client.list_by_subscription(target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) -def create_alertsmanagement(cmd, client, - resource_group, - name, - location=None, - tags=None, - description=None, - state=None, - severity=None, - frequency=None, - action_groups=None, - throttling=None): +def create_alertsmanagement_smart_detector_alert_rule(cmd, client, + resource_group, + name, + location=None, + tags=None, + description=None, + state=None, + severity=None, + frequency=None, + action_groups=None, + throttling=None): body = {} body['location'] = location # str body['tags'] = tags # unknown-primary[object] @@ -183,18 +184,18 @@ def create_alertsmanagement(cmd, client, return client.create_or_update(resource_group_name=resource_group, alert_rule_name=name, parameters=body) -def update_alertsmanagement(cmd, client, - resource_group, - name, - location=None, - tags=None, - description=None, - state=None, - severity=None, - frequency=None, - action_groups=None, - throttling=None): - body = client.get(resource_group_name=resource_group, alert_rule_name=name, expand_detector=expand_detector).as_dict() +def update_alertsmanagement_smart_detector_alert_rule(cmd, client, + resource_group, + name, + location=None, + tags=None, + description=None, + state=None, + severity=None, + frequency=None, + action_groups=None, + throttling=None): + body = {} if location is not None: body['location'] = location # str if tags is not None: @@ -214,22 +215,22 @@ def update_alertsmanagement(cmd, client, return client.create_or_update(resource_group_name=resource_group, alert_rule_name=name, parameters=body) -def delete_alertsmanagement(cmd, client, - resource_group, - name): +def delete_alertsmanagement_smart_detector_alert_rule(cmd, client, + resource_group, + name): return client.delete(resource_group_name=resource_group, alert_rule_name=name) -def get_alertsmanagement(cmd, client, - resource_group, - name, - expand_detector=None): +def get_alertsmanagement_smart_detector_alert_rule(cmd, client, + resource_group, + name, + expand_detector=None): return client.get(resource_group_name=resource_group, alert_rule_name=name, expand_detector=expand_detector) -def list_alertsmanagement(cmd, client, - resource_group, - expand_detector=None): +def list_alertsmanagement_smart_detector_alert_rule(cmd, client, + resource_group=None, + expand_detector=None): if resource_group is not None and expand_detector is not None: return client.list_by_resource_group(resource_group_name=resource_group, expand_detector=expand_detector) return client.list(expand_detector=expand_detector) diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 28fc5b76b5c..c7132918f88 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -18,18 +18,14 @@ class AlertsScenarioTest(ScenarioTest): @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement') def test_alertsmanagement(self, resource_group): - self.kwargs.update({ - 'name': 'test1' - }) - - self.cmd('az alertsmanagement create ' + self.cmd('az alertsmanagement action-rule create ' '--resource-group {rg} ' '--name "DailySuppression" ' '--location "Global" ' '--status "Enabled"', checks=[]) - self.cmd('az alertsmanagement create ' + self.cmd('az alertsmanagement smart-detector-alert-rule create ' '--resource-group {rg} ' '--name "MyAlertRule" ' '--description "Sample smart detector alert rule description" ' @@ -38,87 +34,87 @@ def test_alertsmanagement(self, resource_group): '--frequency "PT5M"', checks=[]) - self.cmd('az alertsmanagement show ' + self.cmd('az alertsmanagement smart-detector-alert-rule show ' '--resource-group {rg} ' '--name "MyAlertRule"', checks=[]) - self.cmd('az alertsmanagement show ' + self.cmd('az alertsmanagement action-rule show ' '--resource-group {rg} ' '--name "DailySuppression"', checks=[]) - self.cmd('az alertsmanagement list ' + self.cmd('az alertsmanagement smart-detector-alert-rule list ' '--resource-group {rg}', checks=[]) - self.cmd('az alertsmanagement list ' + self.cmd('az alertsmanagement action-rule list ' '--resource-group {rg}', checks=[]) - self.cmd('az alertsmanagement changestate get_history ' + self.cmd('az alertsmanagement alert get-history ' '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', checks=[]) - self.cmd('az alertsmanagement change-state get_by_id ' + self.cmd('az alertsmanagement smart-group get-by-id ' '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', checks=[]) - self.cmd('az alertsmanagement changestate get_history ' + self.cmd('az alertsmanagement alert get-history ' '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', checks=[]) - self.cmd('az alertsmanagement list ' + self.cmd('az alertsmanagement smart-detector-alert-rule list ' '--resource-group {rg}', checks=[]) - self.cmd('az alertsmanagement changestate get_by_id ' + self.cmd('az alertsmanagement alert get-by-id ' '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', checks=[]) - self.cmd('az alertsmanagement changestate get_summary', + self.cmd('az alertsmanagement alert get-summary', checks=[]) - self.cmd('az alertsmanagement change-state get_all', + self.cmd('az alertsmanagement smart-group get-all', checks=[]) - self.cmd('az alertsmanagement list', + self.cmd('az alertsmanagement action-rule list', checks=[]) - self.cmd('az alertsmanagement changestate get_all', + self.cmd('az alertsmanagement alert get-all', checks=[]) - self.cmd('az alertsmanagement changestate meta_data', + self.cmd('az alertsmanagement alert meta-data', checks=[]) - self.cmd('az alertsmanagement update ' + self.cmd('az alertsmanagement smart-detector-alert-rule update ' '--resource-group {rg} ' '--name "MyAlertRule" ' '--description "New description for patching" ' '--frequency "PT1M"', checks=[]) - self.cmd('az alertsmanagement update ' + self.cmd('az alertsmanagement action-rule update ' '--resource-group {rg} ' '--name "WeeklySuppression" ' '--status "Disabled"', checks=[]) - self.cmd('az alertsmanagement change-state change_state ' + self.cmd('az alertsmanagement smart-group change-state ' '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' '--new-state "Acknowledged"', checks=[]) - self.cmd('az alertsmanagement changestate get_history ' + self.cmd('az alertsmanagement alert get-history ' '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', checks=[]) - self.cmd('az alertsmanagement delete ' + self.cmd('az alertsmanagement smart-detector-alert-rule delete ' '--resource-group {rg} ' '--name "MyAlertRule"', checks=[]) - self.cmd('az alertsmanagement delete ' + self.cmd('az alertsmanagement action-rule delete ' '--resource-group {rg} ' '--name "DailySuppression"', checks=[]) diff --git a/src/alertsmanagement/setup.py b/src/alertsmanagement/setup.py index 1e82c81bd5b..9d623640008 100644 --- a/src/alertsmanagement/setup.py +++ b/src/alertsmanagement/setup.py @@ -57,4 +57,4 @@ packages=find_packages(), install_requires=DEPENDENCIES, package_data={'azext_alertsmanagement': ['azext_metadata.json']}, -) \ No newline at end of file +) From 698d6e550743c8c01bf7105840d8bc2e1f81b387 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Fri, 17 Jan 2020 16:20:33 +0800 Subject: [PATCH 03/41] smart-detector-alert-rule --- .../azext_alertsmanagement/_params.py | 4 +- .../azext_alertsmanagement/custom.py | 9 +- .../recordings/test_alertsmanagement.yaml | 56 +++++++++ .../test_alertsmanagement_alert_rule.yaml | 111 ++++++++++++++++++ .../latest/test_alertsmanagement_scenario.py | 31 +++-- 5 files changed, 199 insertions(+), 12 deletions(-) create mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml create mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index cc33da7a5a3..cd8836cbbf1 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -133,8 +133,10 @@ def load_arguments(self, _): c.argument('state', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='The alert rule state.') c.argument('severity', arg_type=get_enum_type(['Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4']), id_part=None, help='The alert rule severity.') c.argument('frequency', id_part=None, help='The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.') - c.argument('action_groups', id_part=None, help='The alert rule actions.') + c.argument('action_groups', nargs='+', id_part=None, help='The Action Group resource IDs') c.argument('throttling', id_part=None, help='The alert rule throttling information.') + c.argument('detector', help='The alert rule\'s detector') + c.argument('scope', nargs='+', help='The alert rule resources scopes.') with self.argument_context('alertsmanagement smart-detector-alert-rule update') as c: c.argument('resource_group', resource_group_name_type) diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index f901f3917da..ae6b54628be 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -171,7 +171,9 @@ def create_alertsmanagement_smart_detector_alert_rule(cmd, client, severity=None, frequency=None, action_groups=None, - throttling=None): + throttling=None, + detector=None, + scope=None): body = {} body['location'] = location # str body['tags'] = tags # unknown-primary[object] @@ -179,8 +181,11 @@ def create_alertsmanagement_smart_detector_alert_rule(cmd, client, body['state'] = state # str body['severity'] = severity # str body['frequency'] = frequency # unknown-primary[timeSpan] - body['action_groups'] = json.loads(action_groups) if isinstance(action_groups, str) else action_groups + # body['action_groups'] = json.loads(action_groups) if isinstance(action_groups, str) else action_groups + body['action_groups'] = {'groupIds': action_groups} body['throttling'] = json.loads(throttling) if isinstance(throttling, str) else throttling + body['detector'] = {'id': detector} + body['scope'] = scope return client.create_or_update(resource_group_name=resource_group, alert_rule_name=name, parameters=body) diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml new file mode 100644 index 00000000000..d4e378e237d --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: '{"properties": {"description": "Sample smart detector alert rule description", + "state": "Enabled", "severity": "Sev3", "frequency": "PT5M", "detector": {"id": + "aaa"}, "scope": ["bbb"], "actionGroups": {"groupIds": ["ccc"]}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement smart-detector-alert-rule create + Connection: + - keep-alive + Content-Length: + - '224' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --description --state --severity --frequency --detector + --scope --action-groups + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement000001/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule?api-version=2019-06-01 + response: + body: + string: '{"error":{"code":"LinkedInvalidPropertyId","message":"Property id ''bbb'' + at path ''properties.scope[0]'' is invalid. Expect fully qualified resource + Id that start with ''/subscriptions/{subscriptionId}'' or ''/providers/{resourceProviderNamespace}/''."}}' + headers: + cache-control: + - no-cache + content-length: + - '247' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 17 Jan 2020 06:53:52 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 400 + message: Bad Request +version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml new file mode 100644 index 00000000000..05e014c5b2b --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml @@ -0,0 +1,111 @@ +interactions: +- request: + body: '{"location": "global", "properties": {"groupShortName": "ag1", "enabled": + true, "emailReceivers": [], "smsReceivers": [], "webhookReceivers": [], "itsmReceivers": + [], "azureAppPushReceivers": [], "automationRunbookReceivers": [], "voiceReceivers": + [], "logicAppReceivers": [], "azureFunctionReceivers": [], "armRoleReceivers": + []}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor action-group create + Connection: + - keep-alive + Content-Length: + - '331' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-monitor/0.7.0 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1?api-version=2019-06-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1","type":"Microsoft.Insights/ActionGroups","name":"ag1","location":"Global","kind":null,"tags":null,"properties":{"groupShortName":"ag1","enabled":true,"emailReceivers":[],"smsReceivers":[],"webhookReceivers":[],"itsmReceivers":[],"azureAppPushReceivers":[],"automationRunbookReceivers":[],"voiceReceivers":[],"logicAppReceivers":[],"azureFunctionReceivers":[],"armRoleReceivers":[]},"identity":null}' + headers: + cache-control: + - no-cache + content-length: + - '595' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 17 Jan 2020 08:18:52 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: 'b''{"properties": {"description": "Sample smart detector alert rule description", + "state": "Enabled", "severity": "Sev3", "frequency": "PT5M", "detector": {"id": + "aaa"}, "scope": ["bbb"], "actionGroups": {"groupIds": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1"]}}}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement smart-detector-alert-rule create + Connection: + - keep-alive + Content-Length: + - '409' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --description --state --severity --frequency --detector + --scope --action-groups + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule?api-version=2019-06-01 + response: + body: + string: '{"error":{"code":"LinkedInvalidPropertyId","message":"Property id ''bbb'' + at path ''properties.scope[0]'' is invalid. Expect fully qualified resource + Id that start with ''/subscriptions/{subscriptionId}'' or ''/providers/{resourceProviderNamespace}/''."}}' + headers: + cache-control: + - no-cache + content-length: + - '247' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 17 Jan 2020 08:18:53 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 400 + message: Bad Request +version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index c7132918f88..18da04c8475 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -15,15 +15,14 @@ class AlertsScenarioTest(ScenarioTest): - @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement') - def test_alertsmanagement(self, resource_group): + @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_alert_rule_') + def test_alertsmanagement_alert_rule(self, resource_group): - self.cmd('az alertsmanagement action-rule create ' - '--resource-group {rg} ' - '--name "DailySuppression" ' - '--location "Global" ' - '--status "Enabled"', - checks=[]) + ag1_id = self.cmd('monitor action-group create -g {rg} -n ag1').get_output_in_json()['id'] + + self.kwargs.update({ + 'ag1_id': ag1_id + }) self.cmd('az alertsmanagement smart-detector-alert-rule create ' '--resource-group {rg} ' @@ -31,9 +30,23 @@ def test_alertsmanagement(self, resource_group): '--description "Sample smart detector alert rule description" ' '--state "Enabled" ' '--severity "Sev3" ' - '--frequency "PT5M"', + '--frequency "PT5M" ' + '--detector aaa ' + '--scope bbb ' + '--action-groups {ag1_id}', checks=[]) + @ResourceGroupPreparer() + def test_alertsmanagement(self, resource_group): + # self.cmd('az alertsmanagement action-rule create ' + # '--resource-group {rg} ' + # '--name "DailySuppression" ' + # '--location "Global" ' + # '--status "Enabled"', + # checks=[]) + + + self.cmd('az alertsmanagement smart-detector-alert-rule show ' '--resource-group {rg} ' '--name "MyAlertRule"', From 53d7eb9ccf5162b83589782825f0e8b6f0a172f0 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Mon, 20 Jan 2020 16:00:17 +0800 Subject: [PATCH 04/41] Add smart group, alert commands --- .../azext_alertsmanagement/_params.py | 2 +- .../azext_alertsmanagement/custom.py | 2 +- .../test_alertsmanagement_action_rule.yaml | 292 ++++++++++++++ .../test_alertsmanagement_alert.yaml | 357 ++++++++++++++++++ .../test_alertsmanagement_alert_rule.yaml | 16 +- .../test_alertsmanagement_smart_group.yaml | 52 +++ .../latest/test_alertsmanagement_scenario.py | 73 +++- 7 files changed, 773 insertions(+), 21 deletions(-) create mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml create mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml create mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index cd8836cbbf1..751c5c1f8f2 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -53,7 +53,7 @@ def load_arguments(self, _): c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') with self.argument_context('alertsmanagement alert get-summary') as c: - c.argument('groupby', id_part=None, help='This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). For example, groupby=severity or groupby=severity,alertstate.') + c.argument('groupby', id_part=None, help='This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). For example, groupby=severity or groupby=severity,alertstate. Possible values include: severity, alertState, monitorCondition, monitorService, signalType, alertRule') c.argument('include_smart_groups_count', arg_type=get_three_state_flag(), id_part=None, help='Include count of the SmartGroups as part of the summary. Default value is \'false\'.') c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index ae6b54628be..81efbde85ea 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -57,7 +57,7 @@ def get_history_alertsmanagement_alert(cmd, client, def get_summary_alertsmanagement_alert(cmd, client, - groupby=None, + groupby, include_smart_groups_count=None, target_resource=None, target_resource_type=None, diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml new file mode 100644 index 00000000000..3f311601b62 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -0,0 +1,292 @@ +interactions: +- request: + body: '{"location": "Global"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --location --status + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + response: + body: + string: '{"error":{"code":"InternalServerError","message":"Encountered internal + server error. Please try again."}}' + headers: + cache-control: + - no-store, no-cache + connection: + - close + content-length: + - '105' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 03:36:14 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-ratelimit-remaining-subscription-writes: + - '1197' + x-xss-protection: + - 1; mode=block + status: + code: 500 + message: Internal Server Error +- request: + body: '{"location": "Global"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --location --status + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + response: + body: + string: '{"error":{"code":"InternalServerError","message":"Encountered internal + server error. Please try again."}}' + headers: + cache-control: + - no-store, no-cache + connection: + - close + content-length: + - '105' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 03:36:15 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-ratelimit-remaining-subscription-writes: + - '1196' + x-xss-protection: + - 1; mode=block + status: + code: 500 + message: Internal Server Error +- request: + body: '{"location": "Global"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --location --status + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + response: + body: + string: '{"error":{"code":"InternalServerError","message":"Encountered internal + server error. Please try again."}}' + headers: + cache-control: + - no-store, no-cache + connection: + - close + content-length: + - '105' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 03:36:19 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-ratelimit-remaining-subscription-writes: + - '1196' + x-xss-protection: + - 1; mode=block + status: + code: 500 + message: Internal Server Error +- request: + body: '{"location": "Global"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --location --status + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + response: + body: + string: '{"error":{"code":"InternalServerError","message":"Encountered internal + server error. Please try again."}}' + headers: + cache-control: + - no-store, no-cache + connection: + - close + content-length: + - '105' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 03:36:24 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-ratelimit-remaining-subscription-writes: + - '1195' + x-xss-protection: + - 1; mode=block + status: + code: 500 + message: Internal Server Error +- request: + body: '{"location": "Global"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --location --status + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + response: + body: + string: '{"error":{"code":"InternalServerError","message":"Encountered internal + server error. Please try again."}}' + headers: + cache-control: + - no-store, no-cache + connection: + - close + content-length: + - '105' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 03:36:32 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - service + x-ms-ratelimit-remaining-subscription-writes: + - '1194' + x-xss-protection: + - 1; mode=block + status: + code: 500 + message: Internal Server Error +version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml new file mode 100644 index 00000000000..273d511cd0f --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml @@ -0,0 +1,357 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement alert get-history + Connection: + - keep-alive + ParameterSetName: + - --alert-id + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d/history?api-version=2019-05-05-preview + response: + body: + string: '{"properties":{"alertId":"1dde5384-3a40-4616-8a5d-be8e2453595d","modifications":[{"modificationEvent":"AlertCreated","oldValue":"","newValue":"","modifiedAt":"2020-01-20T07:09:21.1107075Z","modifiedBy":"System","comments":"","description":"Alert + fired"}]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d/history/default","type":"Microsoft.AlertsManagement/alerts","name":"rule1"}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '470' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 07:57:55 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement alert get-by-id + Connection: + - keep-alive + ParameterSetName: + - --alert-id + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d?api-version=2019-05-05-preview + response: + body: + string: '{"properties":{"essentials":{"severity":"Sev4","signalType":"Log","alertState":"New","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"5e2788b5-f2c5-40a1-b137-c2b3f530d160","alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","startDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""},"context":{"context":{"activityLog":{"authorization":{"action":"Microsoft.Compute/virtualMachines/write","scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/Microsoft.Compute/virtualMachines/vm1"},"channels":"Operation","claims":"{\"aud\":\"https://management.core.windows.net/\",\"iss\":\"https://sts.windows.net/54826b22-38d6-4fb2-bad9-b7b93a3e9c5a/\",\"iat\":\"1579500784\",\"nbf\":\"1579500784\",\"exp\":\"1579504684\",\"http://schemas.microsoft.com/claims/authnclassreference\":\"1\",\"aio\":\"AWQAm/8OAAAACjpJ16Rghg/9w/tunPtFKG3itgqujW++yG73v5gIiyl+ZuIAqYicgjquOswg6m96nQRyBjMoLW05YIbya46jeDLtIJ0HKI2eCOw+naQNNvRl/tRWhPcRzCVlIyQfYDD7\",\"altsecid\":\"5::10032000571A5D04\",\"http://schemas.microsoft.com/claims/authnmethodsreferences\":\"pwd\",\"appid\":\"04b07795-8ddb-461a-bbee-02f9e1bf7b46\",\"appidacr\":\"0\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress\":\"fey@microsoft.com\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname\":\"Yu\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname\":\"Feiyue\",\"groups\":\"e4bb0b56-1014-40f8-88ab-3d8a8cb0e086\",\"http://schemas.microsoft.com/identity/claims/identityprovider\":\"https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/\",\"ipaddr\":\"167.220.255.61\",\"name\":\"Feiyue + Yu\",\"http://schemas.microsoft.com/identity/claims/objectidentifier\":\"0a592c45-613e-4f1b-9023-7c4414fd53bf\",\"puid\":\"10032000577FB6BB\",\"http://schemas.microsoft.com/identity/claims/scope\":\"user_impersonation\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier\":\"6sKBNS97eU3Bww8tsvVwB7vGnEPRsbGy0LcbjXQerX8\",\"http://schemas.microsoft.com/identity/claims/tenantid\":\"54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name\":\"fey@microsoft.com\",\"uti\":\"D1Jv9tpjw0m0en9C9oBWAA\",\"ver\":\"1.0\",\"wids\":\"62e90394-69f5-4237-9190-012177145e10\"}","caller":"fey@microsoft.com","correlationId":"69d22ec0-5d6e-49be-9b9b-bc9437059d22","description":"","eventSource":"Administrative","eventTimestamp":"2020-01-20T07:08:31.0511601Z","eventDataId":"5e2788b5-f2c5-40a1-b137-c2b3f530d160","level":"Informational","operationName":"Microsoft.Compute/virtualMachines/write","operationId":"552489d1-521a-4b9c-a85b-810a6e3d0256","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/Microsoft.Compute/virtualMachines/vm1","resourceGroupName":"fytest3","resourceProviderName":"Microsoft.Compute","status":"Succeeded","subStatus":"","subscriptionId":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","submissionTimestamp":"2020-01-20T07:09:20.0850147Z","resourceType":"Microsoft.Compute/virtualMachines"}}},"egressConfig":{"partitionKey":"MonitorServiceConfigurationCollectionPartition","monitorService":"ActivityLog + Administrative","monitorServiceOwnerEmailIds":"rkadr@microsoft.com","modifiedByApplicationId":"ccdfc67e-a7a1-4df5-91c7-7876da73b995","displayConfig":[{"rootJsonNode":"context.activityLog","sectionName":"","displayControls":[{"property":"eventSource","displayName":"Event + source","type":"Text","isOptional":false},{"property":"channels","displayName":"Channels","type":"Text","isOptional":false},{"property":"level","displayName":"Level","type":"Text","isOptional":false},{"property":"caller","displayName":"Caller","type":"Text","isOptional":false},{"property":"eventDataId","displayName":"Event + data id","type":"Text","isOptional":false}]},{"rootJsonNode":"context.activityLog","sectionName":"","displayControls":[{"property":"status","displayName":"Status","type":"Text","isOptional":false},{"property":"operationId","displayName":"Operation + id","type":"Text","isOptional":false},{"property":"operationName","displayName":"Operation + name","type":"Text","isOptional":false},{"property":"submissionTimeStamp","displayName":"Submission + time stamp","type":"Text","isOptional":false}]},{"rootJsonNode":"context.activityLog","sectionName":"","displayControls":[{"property":"authorization.action","displayName":"Authorization + - Action","type":"Text","isOptional":false},{"property":"authorization.scope","displayName":"Authorization + - Scope","type":"Text","isOptional":false},{"property":"claims","displayName":"Claims","type":"Text","isOptional":false},{"property":"httpRequest","displayName":"HTTP + request","type":"Text","isOptional":false}]}]}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '5382' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 07:57:58 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '999' + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement alert get-summary + Connection: + - keep-alive + ParameterSetName: + - --groupby + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alertsSummary?groupby=severity%2Calertstate&api-version=2019-05-05-preview + response: + body: + string: '{"properties":{"groupedby":"severity","total":84,"values":[{"name":"Sev0","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev1","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev2","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev3","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev4","count":84,"groupedby":"alertState","values":[{"name":"New","count":84},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]}]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alertsSummary/current","type":"Microsoft.AlertsManagement/alertsSummary","name":"current"}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '993' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 07:58:00 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '999' + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement alert get-all + Connection: + - keep-alive + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts?api-version=2019-05-05-preview + response: + body: + string: '{"nextLink":"https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts?api-version=2019-05-05-preview&ctoken=%2bRID%3a%7eTxpXAK6hCE2XRlABAAAgDA%3d%3d%23RT%3a1%23TRC%3a50%23RTD%3aqtQyMDIwLTAxLTIwVDA3OjQyOjU2LjEyODc0NDha%23ISV%3a1","value":[{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"216ca771-c5be-4a70-9be6-897dadb25b28","startDateTime":"2020-01-20T07:57:55.5094319Z","lastModifiedDateTime":"2020-01-20T07:57:55.5094319Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/77a487ca-b08f-49d0-9f5f-cfd9a1060c81","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"7fbd4fc3-80a7-45a8-ae80-4c94c2c7b4d9","startDateTime":"2020-01-20T07:57:48.6229975Z","lastModifiedDateTime":"2020-01-20T07:57:48.6229975Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/0ea0315d-6a41-4984-9be9-96f0e87668e9","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"e820956d-664a-483a-a770-e0d407003804","startDateTime":"2020-01-20T07:57:40.7844929Z","lastModifiedDateTime":"2020-01-20T07:57:40.7844929Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7207a331-e7cf-4686-ac57-3226583bb014","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"f610e1ac-6cc8-4687-a7d6-b164c5339777","startDateTime":"2020-01-20T07:57:35.9503654Z","lastModifiedDateTime":"2020-01-20T07:57:35.9503654Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c9a916df-e71c-418e-b454-00ead784ee59","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"f12dda7f-de52-4209-8946-077df629c3c8","startDateTime":"2020-01-20T07:57:32.3044374Z","lastModifiedDateTime":"2020-01-20T07:57:32.3044374Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/e4b5a484-8fa4-4339-8517-6dac03460713","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"a7bb99d4-f0fd-45f2-b8f3-8c3c5f193df3","startDateTime":"2020-01-20T07:57:31.1412791Z","lastModifiedDateTime":"2020-01-20T07:57:31.1412791Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5ca5aaaa-9e45-4ef1-b431-b244d88ac087","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"a1af56dc-649c-4e86-8eb5-f2e948f6d67d","startDateTime":"2020-01-20T07:57:15.927035Z","lastModifiedDateTime":"2020-01-20T07:57:15.927035Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/765e234b-dba0-4fd7-9fd3-a773bf37f328","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"d9f10ae6-a9ba-42c0-a896-123da9efe552","startDateTime":"2020-01-20T07:53:58.7649465Z","lastModifiedDateTime":"2020-01-20T07:53:58.7649465Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/215ca1fc-e4ce-4b6e-9869-f6e8165f496a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"0d562e5c-320c-4f7f-b274-7e3dae6fb1b0","startDateTime":"2020-01-20T07:53:44.7902134Z","lastModifiedDateTime":"2020-01-20T07:53:44.7902134Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/2f98a958-0727-4772-a009-af552243aca3","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"8459a6cd-279a-4869-8882-c0dcb95bcc09","startDateTime":"2020-01-20T07:53:14.525652Z","lastModifiedDateTime":"2020-01-20T07:53:14.525652Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5748e11d-81b2-4037-8e92-15b39c4d01c4","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"8f7f7f59-38bf-4aaf-82c8-be0fbfc56f27","startDateTime":"2020-01-20T07:53:03.0511332Z","lastModifiedDateTime":"2020-01-20T07:53:03.0511332Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d38ea903-6a2f-415d-9d5e-ba7f61a3ad19","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"8e444d44-947b-49f1-bc96-b03f9ac2bc8f","startDateTime":"2020-01-20T07:53:01.2252548Z","lastModifiedDateTime":"2020-01-20T07:53:01.2252548Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/09dab1f8-2a29-4350-8e95-1257e335e4f2","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"a7d8e11a-6f41-4789-ad05-c4d9ab6b7b5a","startDateTime":"2020-01-20T07:52:56.4079777Z","lastModifiedDateTime":"2020-01-20T07:52:56.4079777Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d8ea7c86-f063-40f9-a56f-746e64d032ed","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"97c6033d-cf33-4bc6-b181-ae304389e022","startDateTime":"2020-01-20T07:52:47.4565148Z","lastModifiedDateTime":"2020-01-20T07:52:47.4565148Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8fd7cd61-727e-493a-bc0d-6b160e4c7f18","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"b8b466e5-72f7-4c70-bc7a-9240deedc01e","startDateTime":"2020-01-20T07:52:01.3298942Z","lastModifiedDateTime":"2020-01-20T07:52:01.3298942Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f4a2da67-c16f-42fa-a571-a598f692c74a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"c4c9fe36-86e2-4e15-8c9e-ffa019a4101e","startDateTime":"2020-01-20T07:52:00.7372881Z","lastModifiedDateTime":"2020-01-20T07:52:00.7372881Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f4672343-cf8f-462f-8abc-4eff99881e1c","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"e6df5722-d53b-42a2-86ad-2c8179011e08","startDateTime":"2020-01-20T07:51:37.6980376Z","lastModifiedDateTime":"2020-01-20T07:51:37.6980376Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5debb8fa-f5f4-4cbd-a6b5-2bf0bfc42eae","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"7bd45f82-534c-481a-b832-54cdac8f87a5","startDateTime":"2020-01-20T07:51:36.2736377Z","lastModifiedDateTime":"2020-01-20T07:51:36.2736377Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cfd2e4a4-99ef-4d48-9891-8660af342e3d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"17b1927d-cd90-412c-b200-eb4d66a71137","startDateTime":"2020-01-20T07:51:34.3312389Z","lastModifiedDateTime":"2020-01-20T07:51:34.3312389Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c885c5d1-67b9-4923-aa93-387e48f23fd4","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"f66c6af7-a7b1-404e-a6bb-e0e9ea23e860","startDateTime":"2020-01-20T07:51:29.1216442Z","lastModifiedDateTime":"2020-01-20T07:51:29.1216442Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/45ad09c5-8583-48f2-8669-e7d8499da237","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"e248dc0e-0bd9-4ffa-9041-211e12cb1d09","startDateTime":"2020-01-20T07:51:26.504333Z","lastModifiedDateTime":"2020-01-20T07:51:26.504333Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5809c8d8-6f95-45eb-8e10-cb5c56dfb08a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"874ab6c2-a22a-4645-8559-69486c779909","startDateTime":"2020-01-20T07:51:24.013887Z","lastModifiedDateTime":"2020-01-20T07:51:24.013887Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/38278112-fe6d-40df-80c5-c260f26a0685","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"9433cc99-feea-4480-8222-10b3cc77998c","startDateTime":"2020-01-20T07:51:18.9307378Z","lastModifiedDateTime":"2020-01-20T07:51:18.9307378Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/4a08d675-0dff-4c8e-a47a-fbaddc5d3acc","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"3101519a-612c-40fa-a39b-24cb788821eb","startDateTime":"2020-01-20T07:51:15.2829736Z","lastModifiedDateTime":"2020-01-20T07:51:15.2829736Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/0b050ae5-d955-406b-999f-d3464e535428","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"94926307-904b-4ca6-b559-60a026c9acf8","startDateTime":"2020-01-20T07:51:09.6252756Z","lastModifiedDateTime":"2020-01-20T07:51:09.6252756Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/41e04ad4-5873-4095-98d2-cc091e64c82b","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"6af6afd9-6ee3-493a-accb-65439b3fb06f","startDateTime":"2020-01-20T07:51:08.7088066Z","lastModifiedDateTime":"2020-01-20T07:51:08.7088066Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ca833f3a-e7ba-4e2b-b499-43e890e86161","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"269e1429-c3ca-4954-9559-c23d25a6b0fb","startDateTime":"2020-01-20T07:51:01.3575743Z","lastModifiedDateTime":"2020-01-20T07:51:01.3575743Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/426593cb-76a0-4bd9-a2ef-6ee720c827d0","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"179edb92-15c3-4552-be4a-a26649e6fbe1","startDateTime":"2020-01-20T07:50:57.5620124Z","lastModifiedDateTime":"2020-01-20T07:50:57.5620124Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c2df50ce-954d-4e34-ba06-dabdc996cb9e","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"f52cb859-ad63-4c6c-a3d7-b9d6b24aebdb","startDateTime":"2020-01-20T07:50:48.3954841Z","lastModifiedDateTime":"2020-01-20T07:50:48.3954841Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/00722648-6f2b-4285-ab58-5ef075b54594","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"1b661885-2fcf-4582-a62d-27161642198a","startDateTime":"2020-01-20T07:50:41.9673058Z","lastModifiedDateTime":"2020-01-20T07:50:41.9673058Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/06d79f29-d9d0-4cfa-b6b6-be65e61666d2","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"14f7b750-7516-42ff-9807-0dd25715cb8f","startDateTime":"2020-01-20T07:50:37.0629334Z","lastModifiedDateTime":"2020-01-20T07:50:37.0629334Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/9923b848-8ef3-40ce-a93b-158807b9a497","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"320402fe-70ca-4c97-b2a2-55b5b6845f29","startDateTime":"2020-01-20T07:50:37.0474515Z","lastModifiedDateTime":"2020-01-20T07:50:37.0474515Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/aa56af9c-77a0-4e25-88f2-24b382a7d478","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"f4fc4b33-dc46-4f34-88d9-b731aa000a0c","startDateTime":"2020-01-20T07:50:35.7347511Z","lastModifiedDateTime":"2020-01-20T07:50:35.7347511Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7b945696-56df-4b7c-97cb-f14f29965e46","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.notificationhubs","targetResourceName":"","targetResourceGroup":"","targetResourceType":"","sourceCreatedId":"b3986983-191f-4e44-a682-3a684c490da3","startDateTime":"2020-01-20T07:50:31.3913265Z","lastModifiedDateTime":"2020-01-20T07:50:31.3913265Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/679ec649-01d6-4f02-a135-00d7a290db51","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"57afa1b7-ae91-4a0b-bdb6-3ad19765f130","startDateTime":"2020-01-20T07:50:29.6610175Z","lastModifiedDateTime":"2020-01-20T07:50:29.6610175Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7ec69ee4-8cb8-480f-ad2e-b56424f7066d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.notificationhubs","targetResourceName":"","targetResourceGroup":"","targetResourceType":"","sourceCreatedId":"70f56a5b-0428-4243-8444-02e534cfe425","startDateTime":"2020-01-20T07:50:17.0501887Z","lastModifiedDateTime":"2020-01-20T07:50:17.0501887Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f059a362-0342-4585-a606-d1bffec081a6","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"b6efe870-339d-4816-9a59-ef50d8ac1eba","startDateTime":"2020-01-20T07:50:14.6282086Z","lastModifiedDateTime":"2020-01-20T07:50:14.6282086Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/510a8450-6efb-4fcf-be4d-07dd4acd3c65","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"38f75778-5495-4034-8bcf-6794a3749da4","startDateTime":"2020-01-20T07:50:11.1048096Z","lastModifiedDateTime":"2020-01-20T07:50:11.1048096Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/efc8fb74-c4f6-47dc-b554-dfe75bc19c3c","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"027bc922-21dd-41bb-8eb3-c539f76b0721","startDateTime":"2020-01-20T07:50:05.6579163Z","lastModifiedDateTime":"2020-01-20T07:50:05.6579163Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5aa059bb-fa5c-4893-b256-2f1ca4840475","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"ff32bc38-c72b-4edc-9141-da0409cdb2cc","startDateTime":"2020-01-20T07:49:55.5168487Z","lastModifiedDateTime":"2020-01-20T07:49:55.5168487Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cc789036-46d5-4b5b-b941-ac90112adc55","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"78945ed2-882b-4425-beda-b2f6e1999dc3","startDateTime":"2020-01-20T07:49:42.6986923Z","lastModifiedDateTime":"2020-01-20T07:49:42.6986923Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d822bc7c-4a4f-43df-87d7-ef2541664f88","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"66619eba-b950-482d-8f9a-7e8f867680c7","startDateTime":"2020-01-20T07:48:13.3277567Z","lastModifiedDateTime":"2020-01-20T07:48:13.3277567Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/fc1374ae-1d16-42dd-8f4c-4bc3a53a123d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"0dfaeb0d-d8f0-41b7-a66a-e34b873944a5","startDateTime":"2020-01-20T07:47:24.7325953Z","lastModifiedDateTime":"2020-01-20T07:47:24.7325953Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/6e0f3026-3733-4dfb-b14e-5acdb2f723c1","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"0c63cfec-ed32-4625-a8ba-b2c287665bf2","startDateTime":"2020-01-20T07:47:23.6298306Z","lastModifiedDateTime":"2020-01-20T07:47:23.6298306Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/04772497-6b73-4cd1-835f-0697279328d0","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"e2f170e7-8097-49e1-bb57-3c80f388049d","startDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/a010d10b-d462-4f9d-b34c-b6b091e8f502","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"7588a96e-3878-4090-b903-a56117431742","startDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5a6ecba0-1ee5-446a-af35-e0b2e606bc7a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"021ac2f8-9aa4-4f7c-ab1e-6d2309b81959","startDateTime":"2020-01-20T07:44:03.6096308Z","lastModifiedDateTime":"2020-01-20T07:44:03.6096308Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f079e751-7ed0-46fb-bbf8-51b492a62bbc","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"ea2e4dce-7314-4aba-b24b-60dd227467a4","startDateTime":"2020-01-20T07:43:47.2710982Z","lastModifiedDateTime":"2020-01-20T07:43:47.2710982Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/a9ed6d3c-aea3-4e6f-9d9e-fb27be85f54a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"83f2b624-2c62-4255-9542-de63bd53f4fa","startDateTime":"2020-01-20T07:43:18.6068908Z","lastModifiedDateTime":"2020-01-20T07:43:18.6068908Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/bb6f2e7b-1aff-4773-aedc-5178a5f260c7","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"274e696c-0797-44f7-978d-3519040b91d5","startDateTime":"2020-01-20T07:42:56.1287448Z","lastModifiedDateTime":"2020-01-20T07:42:56.1287448Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ec63bc45-d7d7-41c3-9985-6b155d31911d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"}]}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '54493' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 07:58:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '999' + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement alert get-all + Connection: + - keep-alive + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts?api-version=2019-05-05-preview&ctoken=%2bRID%3a~TxpXAK6hCE2XRlABAAAgDA%3d%3d%23RT%3a1%23TRC%3a50%23RTD%3aqtQyMDIwLTAxLTIwVDA3OjQyOjU2LjEyODc0NDha%23ISV%3a1 + response: + body: + string: '{"value":[{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"b6b2bf96-e15b-42d2-9610-fffabb944c16","startDateTime":"2020-01-20T07:42:52.1716037Z","lastModifiedDateTime":"2020-01-20T07:42:52.1716037Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cfb4b0f1-e618-403e-a8ab-1cea570a5942","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"e30f2875-d115-4129-82f7-80aa769aa09b","startDateTime":"2020-01-20T07:42:50.9021318Z","lastModifiedDateTime":"2020-01-20T07:42:50.9021318Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f7931d3c-db4a-40b5-bf7c-e150b77ce324","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"eb908f86-ea97-4588-9c41-12666941dc32","startDateTime":"2020-01-20T07:42:50.3342457Z","lastModifiedDateTime":"2020-01-20T07:42:50.3342457Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d6975f7d-42da-49bd-b66a-168eb0e726c4","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"44ea98d2-3c3e-41f9-ae60-930c073af2b7","startDateTime":"2020-01-20T07:30:49.3787388Z","lastModifiedDateTime":"2020-01-20T07:30:49.3787388Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5550a5cd-3391-44d5-a27c-3889c6fe01cf","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.insights/activitylogalerts/rule2","targetResourceName":"rule2","targetResourceGroup":"fytest3","targetResourceType":"activitylogalerts","sourceCreatedId":"9533a774-7fc3-4bef-8748-d0004bb88675","startDateTime":"2020-01-20T07:30:42.8462977Z","lastModifiedDateTime":"2020-01-20T07:30:42.8462977Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7644a9b8-27c7-48de-9aef-48d224c588c8","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"8e154d3f-96c5-44bb-8dfa-2168f5f45616","startDateTime":"2020-01-20T07:30:09.9361446Z","lastModifiedDateTime":"2020-01-20T07:30:09.9361446Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/57973c01-f204-4b7f-8758-b5acac6e1343","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/bim-rg/providers/microsoft.keyvault/vaults/bim-kv5","targetResourceName":"bim-kv5","targetResourceGroup":"bim-rg","targetResourceType":"vaults","sourceCreatedId":"4768e756-4f73-4570-8e59-b0aedcf27138","startDateTime":"2020-01-20T07:29:58.2069762Z","lastModifiedDateTime":"2020-01-20T07:29:58.2069762Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c5fb08d9-1209-413e-b71d-351a118ec77c","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"879b705f-556f-448f-99be-d7834e86eb3d","startDateTime":"2020-01-20T07:29:06.9706248Z","lastModifiedDateTime":"2020-01-20T07:29:06.9706248Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/53c692f7-9031-41e3-a522-5436ff4d5f7a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"3b71c87a-1262-4302-8aaf-ea25f5ac2976","startDateTime":"2020-01-20T07:28:55.3245957Z","lastModifiedDateTime":"2020-01-20T07:28:55.3245957Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/2e14a7f9-e9a5-438b-ae84-6439d98421fc","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"bb1a2cc7-975c-440c-95ba-6e668c2d5d93","startDateTime":"2020-01-20T07:26:30.4233806Z","lastModifiedDateTime":"2020-01-20T07:26:30.4233806Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f9c24fa5-5103-4d5a-97d7-04637fa72c6a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"b9a29fea-ed48-4ff7-80b7-a50f8e3ed91a","startDateTime":"2020-01-20T07:26:08.8398227Z","lastModifiedDateTime":"2020-01-20T07:26:08.8398227Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/82085348-e9ee-4081-b357-16bf5dc5c0e6","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"e9ca3586-64d2-4b40-b7d6-8a0810e2fed0","startDateTime":"2020-01-20T07:26:07.5741733Z","lastModifiedDateTime":"2020-01-20T07:26:07.5741733Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/e42b99f2-34c8-4693-a8d2-19f1c4b7fc20","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"e913ab71-b238-4dbc-900a-40f07af2f8fe","startDateTime":"2020-01-20T07:26:06.4404755Z","lastModifiedDateTime":"2020-01-20T07:26:06.4404755Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/4de91bec-8926-404d-820c-f90a5562b515","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"123d0f64-d680-4967-a5d3-6895909e7a89","startDateTime":"2020-01-20T07:25:56.5900617Z","lastModifiedDateTime":"2020-01-20T07:25:56.5900617Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f737f576-152b-46ae-9534-83f83a9991ab","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"6e5ad26d-22db-4dd3-9549-8fe6ae6e380f","startDateTime":"2020-01-20T07:25:55.7775404Z","lastModifiedDateTime":"2020-01-20T07:25:55.7775404Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/459ed590-b925-4d8f-93eb-2c0d5b629931","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"8a6cdfb5-7101-4e49-94d2-96e5fe5939d4","startDateTime":"2020-01-20T07:25:47.6590636Z","lastModifiedDateTime":"2020-01-20T07:25:47.6590636Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8142305a-5726-4150-ad64-7cef674ca554","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test/providers/microsoft.compute/disks/test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceName":"test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceGroup":"test","targetResourceType":"disks","sourceCreatedId":"0e7cc7d7-ef30-459d-b4e0-484d4a335776","startDateTime":"2020-01-20T07:24:11.0185974Z","lastModifiedDateTime":"2020-01-20T07:24:11.0185974Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/92cf85b4-4453-49d6-b658-9680ce19c933","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/xiaojianxu/providers/microsoft.compute/disks/test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceName":"test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceGroup":"xiaojianxu","targetResourceType":"disks","sourceCreatedId":"aae664f6-3b58-4da2-896e-6346820cdd6e","startDateTime":"2020-01-20T07:23:20.1773014Z","lastModifiedDateTime":"2020-01-20T07:23:20.1773014Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8ff0623b-5af1-4d78-98bb-ae8fafecc160","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test/providers/microsoft.network/networkinterfaces/test7vmnic","targetResourceName":"test7vmnic","targetResourceGroup":"test","targetResourceType":"networkinterfaces","sourceCreatedId":"46f254c0-016b-4618-b5c4-4df2fef42a40","startDateTime":"2020-01-20T07:22:50.9005649Z","lastModifiedDateTime":"2020-01-20T07:22:50.9005649Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8109e42c-3dd3-4c5a-b9b7-d9e05cf9d83d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.insights/activitylogalerts/rule2","targetResourceName":"rule2","targetResourceGroup":"fytest3","targetResourceType":"activitylogalerts","sourceCreatedId":"7ffbe0a8-426e-4eb0-9aa5-5ff2f4e37e01","startDateTime":"2020-01-20T07:20:49.541761Z","lastModifiedDateTime":"2020-01-20T07:20:49.541761Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/0f0e2b99-55e6-4d77-9e9a-ce87cd0b95f6","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.insights/activitylogalerts/rule2","targetResourceName":"rule2","targetResourceGroup":"fytest3","targetResourceType":"activitylogalerts","sourceCreatedId":"7bcde580-a05b-4167-a865-9764c6547eb9","startDateTime":"2020-01-20T07:20:01.9043401Z","lastModifiedDateTime":"2020-01-20T07:20:01.9043401Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/29c4acad-8eb1-4955-86c8-99d6229e7e1f","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/jlrg1/providers/microsoft.compute/virtualmachines/test5","targetResourceName":"test5","targetResourceGroup":"jlrg1","targetResourceType":"virtualmachines","sourceCreatedId":"5c61d88a-2451-45ea-9e75-064126b9ab4d","startDateTime":"2020-01-20T07:17:04.5898192Z","lastModifiedDateTime":"2020-01-20T07:17:04.5898192Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/e238e7db-b94c-4ae3-bd76-fbd97c2f458d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/jlrg1/providers/microsoft.compute/virtualmachines/test5","targetResourceName":"test5","targetResourceGroup":"jlrg1","targetResourceType":"virtualmachines","sourceCreatedId":"651bc8df-7340-4d15-8125-6662afa3bb19","startDateTime":"2020-01-20T07:15:49.8003226Z","lastModifiedDateTime":"2020-01-20T07:15:49.8003226Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/21381cb7-8186-4c51-8196-d5052d70eeea","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/jlrg1/providers/microsoft.compute/virtualmachines/test5","targetResourceName":"test5","targetResourceGroup":"jlrg1","targetResourceType":"virtualmachines","sourceCreatedId":"4f570640-6b99-4637-94d5-b8b64af5ddae","startDateTime":"2020-01-20T07:15:46.2967815Z","lastModifiedDateTime":"2020-01-20T07:15:46.2967815Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1a3cc527-ecd4-4c13-bd35-108e82fcf7dd","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"2cb48ba8-4ac9-4e55-9719-cca482d85c25","startDateTime":"2020-01-20T07:15:14.2662421Z","lastModifiedDateTime":"2020-01-20T07:15:14.2662421Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f93358ad-256e-4a64-ae9a-a64d246e74b5","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"dc55163d-239c-4ba0-85e7-9eb4094ca3a4","startDateTime":"2020-01-20T07:14:44.9656314Z","lastModifiedDateTime":"2020-01-20T07:14:44.9656314Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/301c65e4-9b51-40c3-acf0-04563e631651","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"4018ef20-b1d3-4063-ac4b-37e292b4df6a","startDateTime":"2020-01-20T07:14:38.5335344Z","lastModifiedDateTime":"2020-01-20T07:14:38.5335344Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/186a4144-8ac7-4e1d-b7d5-f0e43ba7bcac","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/xiaojianxu/providers/microsoft.compute/virtualmachines/test7","targetResourceName":"test7","targetResourceGroup":"xiaojianxu","targetResourceType":"virtualmachines","sourceCreatedId":"44788ae5-1289-4b4d-b7a5-528c0399899c","startDateTime":"2020-01-20T07:12:36.1424154Z","lastModifiedDateTime":"2020-01-20T07:12:36.1424154Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ff1fc043-6230-4a13-be38-0e0fd65c8123","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"c9e19254-47ff-4819-9c9f-6abd3da70463","startDateTime":"2020-01-20T07:12:21.7632527Z","lastModifiedDateTime":"2020-01-20T07:12:21.7632527Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/b646b578-6f25-4a3d-9740-90b9dc2a431f","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/xiaojianxu/providers/microsoft.compute/virtualmachines/test7","targetResourceName":"test7","targetResourceGroup":"xiaojianxu","targetResourceType":"virtualmachines","sourceCreatedId":"5ca5b794-418b-4c07-9817-ebd65dcca9d6","startDateTime":"2020-01-20T07:12:09.4891925Z","lastModifiedDateTime":"2020-01-20T07:12:09.4891925Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ef028eee-a6fe-4f02-81c6-86a6c822ba98","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"278c5410-6017-4e98-960b-1d445e2959d7","startDateTime":"2020-01-20T07:12:02.6534794Z","lastModifiedDateTime":"2020-01-20T07:12:02.6534794Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/92e96cb6-bb45-45d0-886d-f101717f061c","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"8ab4bd16-750c-4e4e-bd31-7625b2d89402","startDateTime":"2020-01-20T07:11:50.0496379Z","lastModifiedDateTime":"2020-01-20T07:11:50.0496379Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/b9bd2a9d-ffd5-4c86-80b0-f7d7ea32b095","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"3ab8e392-d023-4ace-94e9-66fceff8d4b6","startDateTime":"2020-01-20T07:11:40.0508192Z","lastModifiedDateTime":"2020-01-20T07:11:40.0508192Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cd6d247e-7c54-4d4c-b1ea-4e3b9ba53d9d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog + Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"5e2788b5-f2c5-40a1-b137-c2b3f530d160","startDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"}]}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '33141' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 07:58:04 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '998' + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml index 05e014c5b2b..f518d6e5d6d 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml @@ -38,7 +38,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Fri, 17 Jan 2020 08:18:52 GMT + - Mon, 20 Jan 2020 03:32:37 GMT expires: - '-1' pragma: @@ -57,7 +57,8 @@ interactions: - request: body: 'b''{"properties": {"description": "Sample smart detector alert rule description", "state": "Enabled", "severity": "Sev3", "frequency": "PT5M", "detector": {"id": - "aaa"}, "scope": ["bbb"], "actionGroups": {"groupIds": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1"]}}}''' + "asdf"}, "scope": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001"], + "actionGroups": {"groupIds": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1"]}}}''' headers: Accept: - application/json @@ -68,7 +69,7 @@ interactions: Connection: - keep-alive Content-Length: - - '409' + - '549' Content-Type: - application/json; charset=utf-8 ParameterSetName: @@ -83,18 +84,17 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule?api-version=2019-06-01 response: body: - string: '{"error":{"code":"LinkedInvalidPropertyId","message":"Property id ''bbb'' - at path ''properties.scope[0]'' is invalid. Expect fully qualified resource - Id that start with ''/subscriptions/{subscriptionId}'' or ''/providers/{resourceProviderNamespace}/''."}}' + string: '{"error":{"code":"LocationRequired","message":"The location property + is required for this definition."}}' headers: cache-control: - no-cache content-length: - - '247' + - '104' content-type: - application/json; charset=utf-8 date: - - Fri, 17 Jan 2020 08:18:53 GMT + - Mon, 20 Jan 2020 03:32:39 GMT expires: - '-1' pragma: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml new file mode 100644 index 00000000000..47761e33b78 --- /dev/null +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml @@ -0,0 +1,52 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement smart-group get-by-id + Connection: + - keep-alive + ParameterSetName: + - --smart-group-id + User-Agent: + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/smartGroups/603675da-9851-4b26-854a-49fc53d32715?api-version=2019-05-05-preview + response: + body: + string: '{"error":{"code":"NotFound","message":"Unable to find the input smart + group","target":"https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/smartGroups/603675da-9851-4b26-854a-49fc53d32715?api-version=2019-05-05-preview"}}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '286' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 20 Jan 2020 06:26:19 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '999' + x-xss-protection: + - 1; mode=block + status: + code: 404 + message: Not Found +version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 18da04c8475..29fc5d94225 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -17,11 +17,14 @@ class AlertsScenarioTest(ScenarioTest): @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_alert_rule_') def test_alertsmanagement_alert_rule(self, resource_group): + subscription_id = self.get_subscription_id() ag1_id = self.cmd('monitor action-group create -g {rg} -n ag1').get_output_in_json()['id'] self.kwargs.update({ - 'ag1_id': ag1_id + 'ag1_id': ag1_id, + 'scope': '/subscriptions/{}/resourceGroups/{}'.format(subscription_id, resource_group), + 'detector_id': 'asdf' }) self.cmd('az alertsmanagement smart-detector-alert-rule create ' @@ -31,21 +34,69 @@ def test_alertsmanagement_alert_rule(self, resource_group): '--state "Enabled" ' '--severity "Sev3" ' '--frequency "PT5M" ' - '--detector aaa ' - '--scope bbb ' + '--detector {detector_id} ' + '--scope {scope} ' '--action-groups {ag1_id}', checks=[]) - @ResourceGroupPreparer() - def test_alertsmanagement(self, resource_group): - # self.cmd('az alertsmanagement action-rule create ' - # '--resource-group {rg} ' - # '--name "DailySuppression" ' - # '--location "Global" ' - # '--status "Enabled"', - # checks=[]) + @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_action_rule_') + def test_alertsmanagement_action_rule(self, resource_group): + subscription_id = self.get_subscription_id() + + self.cmd('az alertsmanagement action-rule create ' + '--resource-group {rg} ' + '--name "DailySuppression" ' + '--location "Global" ' + '--status "Enabled"', + checks=[]) + + self.cmd('az alertsmanagement action-rule show ' + '--resource-group {rg} ' + '--name "DailySuppression"', + checks=[]) + + @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_smart_group_') + def test_alertsmanagement_smart_group(self, resource_group): + self.cmd('az alertsmanagement smart-group get-all', + checks=[]) + self.cmd('az alertsmanagement smart-group get-by-id ' + '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', + checks=[]) + self.cmd('az alertsmanagement smart-group change-state ' + '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' + '--new-state "Acknowledged"', + checks=[]) + self.cmd('az alertsmanagement smart-group get-history ' + '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', + checks=[]) + @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_alert_') + def test_alertsmanagement_alert(self, resource_group): + subscription_id = self.get_subscription_id() + self.kwargs.update({ + 'alert_id': '1dde5384-3a40-4616-8a5d-be8e2453595d', + 'alert_full_id': '/subscriptions/{}/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d'.format(subscription_id) + }) + self.cmd('az alertsmanagement alert get-history ' + '--alert-id {alert_id}', + checks=[self.check('properties.alertId', '{alert_id}')]) + self.cmd('az alertsmanagement alert get-by-id ' + '--alert-id {alert_id}', + checks=[self.check('id', '{alert_full_id}')]) + self.cmd('az alertsmanagement alert get-summary --groupby "severity,alertstate"', + checks=[]) + self.cmd('az alertsmanagement alert get-all', + checks=[]) + + @ResourceGroupPreparer() + def test_alertsmanagement(self, resource_group): + self.cmd('az alertsmanagement action-rule create ' + '--resource-group {rg} ' + '--name "DailySuppression" ' + '--location "Global" ' + '--status "Enabled"', + checks=[]) self.cmd('az alertsmanagement smart-detector-alert-rule show ' '--resource-group {rg} ' From 81ba2ae7826abf6c70c53ce4e9a47c60bb858054 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Mon, 17 Feb 2020 18:08:29 +0800 Subject: [PATCH 05/41] Update --- .../azext_alertsmanagement/_params.py | 14 +- .../test_alertsmanagement_action_rule.yaml | 46 ++-- .../test_alertsmanagement_alert_rule.yaml | 12 +- .../test_alertsmanagement_smart_group.yaml | 25 ++- .../latest/test_alertsmanagement_scenario.py | 211 +++++++++--------- src/alertsmanagement/setup.py | 4 +- 6 files changed, 160 insertions(+), 152 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 751c5c1f8f2..d361517ba6c 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -13,10 +13,13 @@ resource_group_name_type, get_location_type ) +from knack.arguments import CLIArgumentType def load_arguments(self, _): + name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME') + with self.argument_context('alertsmanagement operation list') as c: pass @@ -89,27 +92,30 @@ def load_arguments(self, _): with self.argument_context('alertsmanagement smart-group get-history') as c: c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') + action_rule_name = CLIArgumentType(overrides=name_arg_type, help='Name of action rule.', + id_part='name') + with self.argument_context('alertsmanagement action-rule create') as c: c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name that needs to be updated') + c.argument('name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') with self.argument_context('alertsmanagement action-rule update') as c: c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name that needs to be updated') + c.argument('name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') with self.argument_context('alertsmanagement action-rule delete') as c: c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name that needs to be updated') + c.argument('name', action_rule_name) with self.argument_context('alertsmanagement action-rule show') as c: c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name that needs to be updated') + c.argument('name', action_rule_name) with self.argument_context('alertsmanagement action-rule list') as c: c.argument('resource_group', resource_group_name_type) diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index 3f311601b62..99d399588b0 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -17,12 +17,12 @@ interactions: ParameterSetName: - --resource-group --name --location --status User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: string: '{"error":{"code":"InternalServerError","message":"Encountered internal @@ -39,7 +39,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 03:36:14 GMT + - Mon, 17 Feb 2020 09:05:51 GMT expires: - '-1' pragma: @@ -75,12 +75,12 @@ interactions: ParameterSetName: - --resource-group --name --location --status User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: string: '{"error":{"code":"InternalServerError","message":"Encountered internal @@ -97,7 +97,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 03:36:15 GMT + - Mon, 17 Feb 2020 09:05:54 GMT expires: - '-1' pragma: @@ -109,7 +109,7 @@ interactions: x-ms-failure-cause: - service x-ms-ratelimit-remaining-subscription-writes: - - '1196' + - '1198' x-xss-protection: - 1; mode=block status: @@ -133,12 +133,12 @@ interactions: ParameterSetName: - --resource-group --name --location --status User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: string: '{"error":{"code":"InternalServerError","message":"Encountered internal @@ -155,7 +155,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 03:36:19 GMT + - Mon, 17 Feb 2020 09:05:59 GMT expires: - '-1' pragma: @@ -191,12 +191,12 @@ interactions: ParameterSetName: - --resource-group --name --location --status User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: string: '{"error":{"code":"InternalServerError","message":"Encountered internal @@ -213,7 +213,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 03:36:24 GMT + - Mon, 17 Feb 2020 09:06:03 GMT expires: - '-1' pragma: @@ -225,7 +225,7 @@ interactions: x-ms-failure-cause: - service x-ms-ratelimit-remaining-subscription-writes: - - '1195' + - '1197' x-xss-protection: - 1; mode=block status: @@ -249,12 +249,12 @@ interactions: ParameterSetName: - --resource-group --name --location --status User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/DailySuppression?api-version=2019-05-05-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: string: '{"error":{"code":"InternalServerError","message":"Encountered internal @@ -271,7 +271,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 03:36:32 GMT + - Mon, 17 Feb 2020 09:06:12 GMT expires: - '-1' pragma: @@ -283,7 +283,7 @@ interactions: x-ms-failure-cause: - service x-ms-ratelimit-remaining-subscription-writes: - - '1194' + - '1198' x-xss-protection: - 1; mode=block status: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml index f518d6e5d6d..7c0e96c9600 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml @@ -21,8 +21,8 @@ interactions: ParameterSetName: - -g -n User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.7.0 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-monitor/0.7.0 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: PUT @@ -38,7 +38,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 03:32:37 GMT + - Mon, 17 Feb 2020 08:21:50 GMT expires: - '-1' pragma: @@ -76,8 +76,8 @@ interactions: - --resource-group --name --description --state --severity --frequency --detector --scope --action-groups User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: PUT @@ -94,7 +94,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 03:32:39 GMT + - Mon, 17 Feb 2020 08:21:54 GMT expires: - '-1' pragma: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml index 47761e33b78..a6e2301e8b4 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml @@ -7,39 +7,40 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement smart-group get-by-id + - alertsmanagement smart-group get-all Connection: - keep-alive - ParameterSetName: - - --smart-group-id User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 accept-language: - en-US method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/smartGroups/603675da-9851-4b26-854a-49fc53d32715?api-version=2019-05-05-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/smartGroups?api-version=2019-05-05-preview response: body: - string: '{"error":{"code":"NotFound","message":"Unable to find the input smart - group","target":"https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/smartGroups/603675da-9851-4b26-854a-49fc53d32715?api-version=2019-05-05-preview"}}' + string: '{"value":[]}' headers: cache-control: - no-store, no-cache content-length: - - '286' + - '12' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Mon, 20 Jan 2020 06:26:19 GMT + - Mon, 17 Feb 2020 08:48:28 GMT expires: - '-1' pragma: - no-cache strict-transport-security: - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: @@ -47,6 +48,6 @@ interactions: x-xss-protection: - 1; mode=block status: - code: 404 - message: Not Found + code: 200 + message: OK version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 29fc5d94225..04e2ebb1c41 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -15,6 +15,7 @@ class AlertsScenarioTest(ScenarioTest): + @unittest.skip('Smart detector not ready') @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_alert_rule_') def test_alertsmanagement_alert_rule(self, resource_group): subscription_id = self.get_subscription_id() @@ -45,30 +46,30 @@ def test_alertsmanagement_action_rule(self, resource_group): self.cmd('az alertsmanagement action-rule create ' '--resource-group {rg} ' - '--name "DailySuppression" ' + '--name "rule1" ' '--location "Global" ' '--status "Enabled"', checks=[]) self.cmd('az alertsmanagement action-rule show ' '--resource-group {rg} ' - '--name "DailySuppression"', + '--name "rule1"', checks=[]) @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_smart_group_') def test_alertsmanagement_smart_group(self, resource_group): self.cmd('az alertsmanagement smart-group get-all', checks=[]) - self.cmd('az alertsmanagement smart-group get-by-id ' - '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', - checks=[]) - self.cmd('az alertsmanagement smart-group change-state ' - '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' - '--new-state "Acknowledged"', - checks=[]) - self.cmd('az alertsmanagement smart-group get-history ' - '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', - checks=[]) + # self.cmd('az alertsmanagement smart-group get-by-id ' + # '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', + # checks=[]) + # self.cmd('az alertsmanagement smart-group change-state ' + # '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' + # '--new-state "Acknowledged"', + # checks=[]) + # self.cmd('az alertsmanagement smart-group get-history ' + # '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', + # checks=[]) @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_alert_') def test_alertsmanagement_alert(self, resource_group): @@ -89,96 +90,96 @@ def test_alertsmanagement_alert(self, resource_group): self.cmd('az alertsmanagement alert get-all', checks=[]) - @ResourceGroupPreparer() - def test_alertsmanagement(self, resource_group): - self.cmd('az alertsmanagement action-rule create ' - '--resource-group {rg} ' - '--name "DailySuppression" ' - '--location "Global" ' - '--status "Enabled"', - checks=[]) - - self.cmd('az alertsmanagement smart-detector-alert-rule show ' - '--resource-group {rg} ' - '--name "MyAlertRule"', - checks=[]) - - self.cmd('az alertsmanagement action-rule show ' - '--resource-group {rg} ' - '--name "DailySuppression"', - checks=[]) - - self.cmd('az alertsmanagement smart-detector-alert-rule list ' - '--resource-group {rg}', - checks=[]) - - self.cmd('az alertsmanagement action-rule list ' - '--resource-group {rg}', - checks=[]) - - self.cmd('az alertsmanagement alert get-history ' - '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - checks=[]) - - self.cmd('az alertsmanagement smart-group get-by-id ' - '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', - checks=[]) - - self.cmd('az alertsmanagement alert get-history ' - '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - checks=[]) - - self.cmd('az alertsmanagement smart-detector-alert-rule list ' - '--resource-group {rg}', - checks=[]) - - self.cmd('az alertsmanagement alert get-by-id ' - '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - checks=[]) - - self.cmd('az alertsmanagement alert get-summary', - checks=[]) - - self.cmd('az alertsmanagement smart-group get-all', - checks=[]) - - self.cmd('az alertsmanagement action-rule list', - checks=[]) - - self.cmd('az alertsmanagement alert get-all', - checks=[]) - - self.cmd('az alertsmanagement alert meta-data', - checks=[]) - - self.cmd('az alertsmanagement smart-detector-alert-rule update ' - '--resource-group {rg} ' - '--name "MyAlertRule" ' - '--description "New description for patching" ' - '--frequency "PT1M"', - checks=[]) - - self.cmd('az alertsmanagement action-rule update ' - '--resource-group {rg} ' - '--name "WeeklySuppression" ' - '--status "Disabled"', - checks=[]) - - self.cmd('az alertsmanagement smart-group change-state ' - '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' - '--new-state "Acknowledged"', - checks=[]) - - self.cmd('az alertsmanagement alert get-history ' - '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - checks=[]) - - self.cmd('az alertsmanagement smart-detector-alert-rule delete ' - '--resource-group {rg} ' - '--name "MyAlertRule"', - checks=[]) - - self.cmd('az alertsmanagement action-rule delete ' - '--resource-group {rg} ' - '--name "DailySuppression"', - checks=[]) + # @ResourceGroupPreparer() + # def test_alertsmanagement(self, resource_group): + # self.cmd('az alertsmanagement action-rule create ' + # '--resource-group {rg} ' + # '--name "DailySuppression" ' + # '--location "Global" ' + # '--status "Enabled"', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-detector-alert-rule show ' + # '--resource-group {rg} ' + # '--name "MyAlertRule"', + # checks=[]) + # + # self.cmd('az alertsmanagement action-rule show ' + # '--resource-group {rg} ' + # '--name "DailySuppression"', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-detector-alert-rule list ' + # '--resource-group {rg}', + # checks=[]) + # + # self.cmd('az alertsmanagement action-rule list ' + # '--resource-group {rg}', + # checks=[]) + # + # self.cmd('az alertsmanagement alert get-history ' + # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-group get-by-id ' + # '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', + # checks=[]) + # + # self.cmd('az alertsmanagement alert get-history ' + # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-detector-alert-rule list ' + # '--resource-group {rg}', + # checks=[]) + # + # self.cmd('az alertsmanagement alert get-by-id ' + # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + # checks=[]) + # + # self.cmd('az alertsmanagement alert get-summary', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-group get-all', + # checks=[]) + # + # self.cmd('az alertsmanagement action-rule list', + # checks=[]) + # + # self.cmd('az alertsmanagement alert get-all', + # checks=[]) + # + # self.cmd('az alertsmanagement alert meta-data', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-detector-alert-rule update ' + # '--resource-group {rg} ' + # '--name "MyAlertRule" ' + # '--description "New description for patching" ' + # '--frequency "PT1M"', + # checks=[]) + # + # self.cmd('az alertsmanagement action-rule update ' + # '--resource-group {rg} ' + # '--name "WeeklySuppression" ' + # '--status "Disabled"', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-group change-state ' + # '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' + # '--new-state "Acknowledged"', + # checks=[]) + # + # self.cmd('az alertsmanagement alert get-history ' + # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', + # checks=[]) + # + # self.cmd('az alertsmanagement smart-detector-alert-rule delete ' + # '--resource-group {rg} ' + # '--name "MyAlertRule"', + # checks=[]) + # + # self.cmd('az alertsmanagement action-rule delete ' + # '--resource-group {rg} ' + # '--name "DailySuppression"', + # checks=[]) diff --git a/src/alertsmanagement/setup.py b/src/alertsmanagement/setup.py index 9d623640008..a0947ef8e9d 100644 --- a/src/alertsmanagement/setup.py +++ b/src/alertsmanagement/setup.py @@ -47,8 +47,8 @@ version=VERSION, description='Microsoft Azure Command-Line Tools Alerts Extension', # TODO: Update author and email, if applicable - author='Microsoft Corporation', - author_email='azpycli@microsoft.com', + author='Github:qwordy', + author_email='fey@microsoft.com', # TODO: consider pointing directly to your source code instead of the generic repo url='https://github.com/Azure/azure-cli-extensions', long_description=README + '\n\n' + HISTORY, From 5c288eab7493be98beb37198d14ec650c89ef2f5 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 18 Feb 2020 18:08:59 +0800 Subject: [PATCH 06/41] action-rule create --- .../azext_alertsmanagement/_params.py | 11 ++++ .../azext_alertsmanagement/custom.py | 64 +++++++++++++++++++ .../test_alertsmanagement_action_rule.yaml | 28 ++++---- .../latest/test_alertsmanagement_scenario.py | 4 +- 4 files changed, 92 insertions(+), 15 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index d361517ba6c..08f86d332e3 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -101,6 +101,17 @@ def load_arguments(self, _): c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') + c.argument('type', arg_type=get_enum_type(['Suppression', 'ActionGroup', 'Diagnostics']), help='Indicates type of action rule') + c.argument('description', help='Description of action rule') + c.argument('scope_type', help='Type of target scope') + c.argument('scope', nargs='+', help='List of ARM IDs (space-delimited) of the given scope type which will be the target of the given action rule.') + c.argument('severity', nargs='+', help='Filter alerts by severity. All filters should follow format "operator value1 value2 ... valueN". Operator is Equals, NotEquals, Contains or DoesNotContain.') + c.argument('monitor_service', nargs='+', help='Filter alerts by monitor service') + c.argument('monitor_condition', nargs='+', help='Filter alerts by monitor condition') + c.argument('target_resource_type', nargs='+', help='Filter alerts by target resource type') + c.argument('alert_rule_id', nargs='+', help='Filter alerts by alert rule ID') + c.argument('alert_description', nargs='+', help='Filter alerts by alert rule description') + c.argument('alert_context', nargs='+', help='Filter alerts by alert context (payload)') with self.argument_context('alertsmanagement action-rule update') as c: c.argument('resource_group', resource_group_name_type) diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 81efbde85ea..0d5c14ccea8 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -9,6 +9,8 @@ # pylint: disable=unused-argument import json +from knack.util import CLIError + def list_alertsmanagement_operation(cmd, client): return client.list() @@ -103,16 +105,78 @@ def get_history_alertsmanagement_smart_group(cmd, client, return client.get_history(smart_group_id=smart_group_id) +def _transform_condition(condition): + """ + ['Equals', 'Sev0', 'Sev2'] -> + { + "operator": "Equals", + "values": [ + "Sev0", + "Sev2" + ] + } + :param condition: a list + :return: a dict + """ + if condition is None: + return None + if len(condition) < 2: + raise CLIError('usage error: condition type should have at least two elements') + return { + 'operator': condition[0], + 'values': condition[1:] + } + + def create_alertsmanagement_action_rule(cmd, client, resource_group, name, location, + type, + description=None, + scope_type=None, + scope=None, + severity=None, + monitor_service=None, + monitor_condition=None, + target_resource_type=None, + alert_rule_id=None, + alert_description=None, + alert_context=None, tags=None, status=None): body = {} body['location'] = location # str body['tags'] = tags # unknown-primary[object] body['status'] = status # str + body['type'] = type + body['description'] = description + body['scope'] = { + 'scopeType': scope_type, + 'values': scope + } + severity = _transform_condition(severity) + monitor_service = _transform_condition(monitor_service) + monitor_condition = _transform_condition(monitor_condition) + target_resource_type = _transform_condition(target_resource_type) + alert_rule_id = _transform_condition(alert_rule_id) + alert_description = _transform_condition(alert_description) + alert_context = _transform_condition(alert_context) + body['conditions'] = {} + if severity is not None: + body['conditions']['severity'] = severity + if severity is not None: + body['conditions']['monitorService'] = monitor_service + if severity is not None: + body['conditions']['monitorCondition'] = monitor_condition + if severity is not None: + body['conditions']['targetResourceType'] = target_resource_type + if severity is not None: + body['conditions']['alertRuleId'] = alert_rule_id + if severity is not None: + body['conditions']['description'] = alert_description + if severity is not None: + body['conditions']['alertContext'] = alert_context return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index 99d399588b0..3bcaf4edfce 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -15,7 +15,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status + - --resource-group --name --location --status --type --severity User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 @@ -39,7 +39,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 17 Feb 2020 09:05:51 GMT + - Tue, 18 Feb 2020 03:48:49 GMT expires: - '-1' pragma: @@ -51,7 +51,7 @@ interactions: x-ms-failure-cause: - service x-ms-ratelimit-remaining-subscription-writes: - - '1197' + - '1199' x-xss-protection: - 1; mode=block status: @@ -73,7 +73,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status + - --resource-group --name --location --status --type --severity User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 @@ -97,7 +97,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 17 Feb 2020 09:05:54 GMT + - Tue, 18 Feb 2020 03:48:51 GMT expires: - '-1' pragma: @@ -109,7 +109,7 @@ interactions: x-ms-failure-cause: - service x-ms-ratelimit-remaining-subscription-writes: - - '1198' + - '1199' x-xss-protection: - 1; mode=block status: @@ -131,7 +131,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status + - --resource-group --name --location --status --type --severity User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 @@ -155,7 +155,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 17 Feb 2020 09:05:59 GMT + - Tue, 18 Feb 2020 03:48:55 GMT expires: - '-1' pragma: @@ -167,7 +167,7 @@ interactions: x-ms-failure-cause: - service x-ms-ratelimit-remaining-subscription-writes: - - '1196' + - '1199' x-xss-protection: - 1; mode=block status: @@ -189,7 +189,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status + - --resource-group --name --location --status --type --severity User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 @@ -213,7 +213,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 17 Feb 2020 09:06:03 GMT + - Tue, 18 Feb 2020 03:49:00 GMT expires: - '-1' pragma: @@ -225,7 +225,7 @@ interactions: x-ms-failure-cause: - service x-ms-ratelimit-remaining-subscription-writes: - - '1197' + - '1199' x-xss-protection: - 1; mode=block status: @@ -247,7 +247,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status + - --resource-group --name --location --status --type --severity User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 @@ -271,7 +271,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 17 Feb 2020 09:06:12 GMT + - Tue, 18 Feb 2020 03:49:07 GMT expires: - '-1' pragma: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 04e2ebb1c41..b5e00b3cb89 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -48,7 +48,9 @@ def test_alertsmanagement_action_rule(self, resource_group): '--resource-group {rg} ' '--name "rule1" ' '--location "Global" ' - '--status "Enabled"', + '--status "Enabled" ' + '--type Suppression ' + '--severity Equals Sev0 Sev2 ', checks=[]) self.cmd('az alertsmanagement action-rule show ' From 187facdaabb0388b7960c042d1d486b2147ffe72 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 20 Feb 2020 00:49:25 +0800 Subject: [PATCH 07/41] action-rule create / udpate --- .../azext_alertsmanagement/_params.py | 7 +- .../azext_alertsmanagement/commands.py | 4 +- .../azext_alertsmanagement/custom.py | 78 ++++--- .../test_alertsmanagement_action_rule.yaml | 197 ++++++------------ .../latest/test_alertsmanagement_scenario.py | 22 +- 5 files changed, 144 insertions(+), 164 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 08f86d332e3..5540f754525 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -112,10 +112,15 @@ def load_arguments(self, _): c.argument('alert_rule_id', nargs='+', help='Filter alerts by alert rule ID') c.argument('alert_description', nargs='+', help='Filter alerts by alert rule description') c.argument('alert_context', nargs='+', help='Filter alerts by alert context (payload)') + c.argument('recurrence_type', arg_type=get_enum_type(['Always', 'Once', 'Daily', 'Weekly', 'Monthly']), help='Specifies when the suppression should be applied') + c.argument('start_date', help='Start date for suppression') + c.argument('end_date', help='End date for suppression') + c.argument('start_time', help='Start time for suppression') + c.argument('end_time', help='End date for suppression') with self.argument_context('alertsmanagement action-rule update') as c: c.argument('resource_group', resource_group_name_type) - c.argument('name', action_rule_name) + c.argument('action_rule_name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') diff --git a/src/alertsmanagement/azext_alertsmanagement/commands.py b/src/alertsmanagement/azext_alertsmanagement/commands.py index c20c65b0f14..69ae3198a6d 100644 --- a/src/alertsmanagement/azext_alertsmanagement/commands.py +++ b/src/alertsmanagement/azext_alertsmanagement/commands.py @@ -47,7 +47,9 @@ def load_command_table(self, _): client_factory=cf_action_rules) with self.command_group('alertsmanagement action-rule', alertsmanagement_action_rules, client_factory=cf_action_rules) as g: g.custom_command('create', 'create_alertsmanagement_action_rule') - g.custom_command('update', 'update_alertsmanagement_action_rule') + g.generic_update_command('update', custom_func_name='update_alertsmanagement_action_rule', + setter_arg_name='action_rule', getter_name='get_by_name', + setter_name='create_update') g.custom_command('delete', 'delete_alertsmanagement_action_rule') g.custom_show_command('show', 'get_alertsmanagement_action_rule') g.custom_command('list', 'list_alertsmanagement_action_rule') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 0d5c14ccea8..ade2cc9f2de 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -144,17 +144,27 @@ def create_alertsmanagement_action_rule(cmd, client, alert_description=None, alert_context=None, tags=None, - status=None): + status=None, + recurrence_type=None, + start_date=None, + end_date=None, + start_time=None, + end_time=None): body = {} body['location'] = location # str body['tags'] = tags # unknown-primary[object] - body['status'] = status # str - body['type'] = type - body['description'] = description - body['scope'] = { - 'scopeType': scope_type, - 'values': scope - } + + properties = {} + if status is not None: + properties['status'] = status + properties['type'] = type + if description is not None: + properties['description'] = description + if scope is not None and scope_type is not None: + properties['scope'] = { + 'scopeType': scope_type, + 'values': scope + } severity = _transform_condition(severity) monitor_service = _transform_condition(monitor_service) monitor_condition = _transform_condition(monitor_condition) @@ -162,38 +172,46 @@ def create_alertsmanagement_action_rule(cmd, client, alert_rule_id = _transform_condition(alert_rule_id) alert_description = _transform_condition(alert_description) alert_context = _transform_condition(alert_context) - body['conditions'] = {} - if severity is not None: - body['conditions']['severity'] = severity - if severity is not None: - body['conditions']['monitorService'] = monitor_service - if severity is not None: - body['conditions']['monitorCondition'] = monitor_condition - if severity is not None: - body['conditions']['targetResourceType'] = target_resource_type - if severity is not None: - body['conditions']['alertRuleId'] = alert_rule_id + properties['conditions'] = {} if severity is not None: - body['conditions']['description'] = alert_description - if severity is not None: - body['conditions']['alertContext'] = alert_context + properties['conditions']['severity'] = severity + if monitor_service is not None: + properties['conditions']['monitorService'] = monitor_service + if monitor_condition is not None: + properties['conditions']['monitorCondition'] = monitor_condition + if target_resource_type is not None: + properties['conditions']['targetResourceType'] = target_resource_type + if alert_rule_id is not None: + properties['conditions']['alertRuleId'] = alert_rule_id + if alert_description is not None: + properties['conditions']['description'] = alert_description + if alert_context is not None: + properties['conditions']['alertContext'] = alert_context + properties['suppressionConfig'] = { + 'recurrenceType': recurrence_type, + 'schedule': { + 'startDate': start_date, + 'endDate': end_date, + 'startTime': start_time, + 'endTime': end_time + } + } + body['properties'] = properties + return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) -def update_alertsmanagement_action_rule(cmd, client, - resource_group, - name, +def update_alertsmanagement_action_rule(instance, client, location=None, tags=None, status=None): - body = {} if location is not None: - body['location'] = location # str + instance.location = location if tags is not None: - body['tags'] = tags # unknown-primary[object] + instance.tags = tags if status is not None: - body['status'] = status # str - return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) + instance.properties.status = status + return instance def delete_alertsmanagement_action_rule(cmd, client, diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index 3bcaf4edfce..ab0cd8b4685 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -1,6 +1,9 @@ interactions: - request: - body: '{"location": "Global"}' + body: '{"location": "Global", "properties": {"conditions": {"severity": {"operator": + "Equals", "values": ["Sev0", "Sev2"]}}, "status": "Enabled", "type": "Suppression", + "suppressionConfig": {"recurrenceType": "Daily", "schedule": {"startDate": "12/09/2018", + "endDate": "12/18/2018", "startTime": "06:00:00", "endTime": "14:00:00"}}}}' headers: Accept: - application/json @@ -11,282 +14,216 @@ interactions: Connection: - keep-alive Content-Length: - - '22' + - '326' Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status --type --severity + - --resource-group --name --location --status --type --severity --recurrence-type + --start-date --end-date --start-time --end-time User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 accept-language: - en-US method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"error":{"code":"InternalServerError","message":"Encountered internal - server error. Please try again."}}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:47:57.7041574Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache - connection: - - close content-length: - - '105' + - '729' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Tue, 18 Feb 2020 03:48:49 GMT + - Wed, 19 Feb 2020 16:47:59 GMT expires: - '-1' pragma: - no-cache strict-transport-security: - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding x-content-type-options: - nosniff - x-ms-failure-cause: - - service x-ms-ratelimit-remaining-subscription-writes: - - '1199' - x-xss-protection: - - 1; mode=block - status: - code: 500 - message: Internal Server Error -- request: - body: '{"location": "Global"}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement action-rule create - Connection: - - keep-alive - Content-Length: - - '22' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - --resource-group --name --location --status --type --severity - User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview - response: - body: - string: '{"error":{"code":"InternalServerError","message":"Encountered internal - server error. Please try again."}}' - headers: - cache-control: - - no-store, no-cache - connection: - - close - content-length: - - '105' - content-security-policy: - - script-src 'self' - content-type: - - application/json; charset=utf-8 - date: - - Tue, 18 Feb 2020 03:48:51 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - x-content-type-options: - - nosniff - x-ms-failure-cause: - - service - x-ms-ratelimit-remaining-subscription-writes: - - '1199' + - '1198' x-xss-protection: - 1; mode=block status: - code: 500 - message: Internal Server Error + code: 200 + message: OK - request: - body: '{"location": "Global"}' + body: null headers: Accept: - application/json Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule create + - alertsmanagement action-rule show Connection: - keep-alive - Content-Length: - - '22' - Content-Type: - - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status --type --severity + - --resource-group --name User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 accept-language: - en-US - method: PUT + method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"error":{"code":"InternalServerError","message":"Encountered internal - server error. Please try again."}}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:47:57.7041574Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache - connection: - - close content-length: - - '105' + - '729' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Tue, 18 Feb 2020 03:48:55 GMT + - Wed, 19 Feb 2020 16:48:02 GMT expires: - '-1' pragma: - no-cache strict-transport-security: - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding x-content-type-options: - nosniff - x-ms-failure-cause: - - service - x-ms-ratelimit-remaining-subscription-writes: - - '1199' + x-ms-ratelimit-remaining-subscription-resource-requests: + - '999' x-xss-protection: - 1; mode=block status: - code: 500 - message: Internal Server Error + code: 200 + message: OK - request: - body: '{"location": "Global"}' + body: null headers: Accept: - application/json Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule create + - alertsmanagement action-rule update Connection: - keep-alive - Content-Length: - - '22' - Content-Type: - - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status --type --severity + - --resource-group --name --status User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 accept-language: - en-US - method: PUT + method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"error":{"code":"InternalServerError","message":"Encountered internal - server error. Please try again."}}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:47:57.7041574Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache - connection: - - close content-length: - - '105' + - '729' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Tue, 18 Feb 2020 03:49:00 GMT + - Wed, 19 Feb 2020 16:48:03 GMT expires: - '-1' pragma: - no-cache strict-transport-security: - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding x-content-type-options: - nosniff - x-ms-failure-cause: - - service - x-ms-ratelimit-remaining-subscription-writes: - - '1199' + x-ms-ratelimit-remaining-subscription-resource-requests: + - '999' x-xss-protection: - 1; mode=block status: - code: 500 - message: Internal Server Error + code: 200 + message: OK - request: - body: '{"location": "Global"}' + body: '{"location": "Global", "properties": {"conditions": {"severity": {"operator": + "Equals", "values": ["Sev0", "Sev2"]}}, "status": "Disabled", "type": "Suppression", + "suppressionConfig": {"recurrenceType": "Daily", "schedule": {"startDate": "12/09/2018", + "endDate": "12/18/2018", "startTime": "06:00:00", "endTime": "14:00:00"}}}}' headers: Accept: - application/json Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule create + - alertsmanagement action-rule update Connection: - keep-alive Content-Length: - - '22' + - '327' Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status --type --severity + - --resource-group --name --status User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 accept-language: - en-US method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"error":{"code":"InternalServerError","message":"Encountered internal - server error. Please try again."}}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Disabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:48:05.4108095Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache - connection: - - close content-length: - - '105' + - '730' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Tue, 18 Feb 2020 03:49:07 GMT + - Wed, 19 Feb 2020 16:48:05 GMT expires: - '-1' pragma: - no-cache strict-transport-security: - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding x-content-type-options: - nosniff - x-ms-failure-cause: - - service x-ms-ratelimit-remaining-subscription-writes: - '1198' x-xss-protection: - 1; mode=block status: - code: 500 - message: Internal Server Error + code: 200 + message: OK version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index b5e00b3cb89..55ae9e140f8 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -50,13 +50,31 @@ def test_alertsmanagement_action_rule(self, resource_group): '--location "Global" ' '--status "Enabled" ' '--type Suppression ' - '--severity Equals Sev0 Sev2 ', + '--severity Equals Sev0 Sev2 ' + '--recurrence-type Daily ' + '--start-date 12/09/2018 ' + '--end-date 12/18/2018 ' + '--start-time 06:00:00 ' + '--end-time 14:00:00', checks=[]) self.cmd('az alertsmanagement action-rule show ' '--resource-group {rg} ' '--name "rule1"', - checks=[]) + checks=[ + self.check('name', 'rule1'), + self.check('location', 'Global'), + self.check('properties.status', 'Enabled'), + self.check('properties.type', 'Suppression') + ]) + + self.cmd('az alertsmanagement action-rule update ' + '--resource-group {rg} ' + '--name "rule1" ' + '--status Disabled', + checks=[ + self.check('properties.status', 'Disabled') + ]) @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_smart_group_') def test_alertsmanagement_smart_group(self, resource_group): From e9bf8747c8fd6e31e29a5ff337fb73b616c9be8f Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 20 Feb 2020 00:57:05 +0800 Subject: [PATCH 08/41] Fix style --- .../azext_alertsmanagement/_help.py | 8 +++---- .../azext_alertsmanagement/_params.py | 2 +- .../azext_alertsmanagement/custom.py | 5 +++-- .../test_alertsmanagement_action_rule.yaml | 22 +++++++++---------- .../latest/test_alertsmanagement_scenario.py | 4 +--- src/alertsmanagement/setup.py | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index 77f8917b27e..3fbbb06b721 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -45,7 +45,7 @@ helps['alertsmanagement alert get-all'] = """ type: command - short-summary: List all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. time range). The results can then be sorted on the basis specific fields, with the default being lastModifiedDateTime. + short-summary: List all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. time range). The results can then be sorted on the basis specific fields, with the default being lastModifiedDateTime. examples: - name: ListAlerts text: |- @@ -96,7 +96,7 @@ helps['alertsmanagement smart-group get-all'] = """ type: command - short-summary: List all the Smart Groups within a specified subscription. + short-summary: List all the Smart Groups within a specified subscription. examples: - name: List text: |- @@ -134,8 +134,8 @@ examples: - name: PutActionRule text: |- - az alertsmanagement action-rule create --resource-group "alertscorrelationrg" --name \\ - "DailySuppression" --location "Global" --status "Enabled" + az alertsmanagement action-rule create --resource-group "alertscorrelationrg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --start-date 12/09/2018 --end-date 12/18/2018 --start-time 06:00:00 --end-time 14:00:00 + """ helps['alertsmanagement action-rule update'] = """ diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 5540f754525..c5936f1c0fb 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -101,7 +101,7 @@ def load_arguments(self, _): c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') - c.argument('type', arg_type=get_enum_type(['Suppression', 'ActionGroup', 'Diagnostics']), help='Indicates type of action rule') + c.argument('rule_type', arg_type=get_enum_type(['Suppression', 'ActionGroup', 'Diagnostics']), help='Indicates type of action rule') c.argument('description', help='Description of action rule') c.argument('scope_type', help='Type of target scope') c.argument('scope', nargs='+', help='List of ARM IDs (space-delimited) of the given scope type which will be the target of the given action rule.') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index ade2cc9f2de..d7967404230 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -7,6 +7,7 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-locals # pylint: disable=unused-argument +# pylint: disable=too-many-boolean-expressions import json from knack.util import CLIError @@ -132,7 +133,7 @@ def create_alertsmanagement_action_rule(cmd, client, resource_group, name, location, - type, + rule_type, description=None, scope_type=None, scope=None, @@ -157,7 +158,7 @@ def create_alertsmanagement_action_rule(cmd, client, properties = {} if status is not None: properties['status'] = status - properties['type'] = type + properties['type'] = rule_type if description is not None: properties['description'] = description if scope is not None and scope_type is not None: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index ab0cd8b4685..495c3ecdff8 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -18,7 +18,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status --type --severity --recurrence-type + - --resource-group --name --location --status --rule-type --severity --recurrence-type --start-date --end-date --start-time --end-time User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 @@ -29,7 +29,7 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:47:57.7041574Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:37.7744856Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -40,7 +40,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:47:59 GMT + - Wed, 19 Feb 2020 16:55:39 GMT expires: - '-1' pragma: @@ -54,7 +54,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1198' + - '1199' x-xss-protection: - 1; mode=block status: @@ -82,7 +82,7 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:47:57.7041574Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:37.7744856Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -93,7 +93,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:48:02 GMT + - Wed, 19 Feb 2020 16:55:41 GMT expires: - '-1' pragma: @@ -135,7 +135,7 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:47:57.7041574Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:37.7744856Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -146,7 +146,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:48:03 GMT + - Wed, 19 Feb 2020 16:55:44 GMT expires: - '-1' pragma: @@ -195,7 +195,7 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Disabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:47:57.7041574Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:48:05.4108095Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Disabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:46.2519341Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -206,7 +206,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:48:05 GMT + - Wed, 19 Feb 2020 16:55:46 GMT expires: - '-1' pragma: @@ -220,7 +220,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1198' + - '1197' x-xss-protection: - 1; mode=block status: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 55ae9e140f8..bd88c0a5666 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -42,14 +42,12 @@ def test_alertsmanagement_alert_rule(self, resource_group): @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_action_rule_') def test_alertsmanagement_action_rule(self, resource_group): - subscription_id = self.get_subscription_id() - self.cmd('az alertsmanagement action-rule create ' '--resource-group {rg} ' '--name "rule1" ' '--location "Global" ' '--status "Enabled" ' - '--type Suppression ' + '--rule-type Suppression ' '--severity Equals Sev0 Sev2 ' '--recurrence-type Daily ' '--start-date 12/09/2018 ' diff --git a/src/alertsmanagement/setup.py b/src/alertsmanagement/setup.py index a0947ef8e9d..a675fc1673f 100644 --- a/src/alertsmanagement/setup.py +++ b/src/alertsmanagement/setup.py @@ -46,7 +46,7 @@ name='alertsmanagement', version=VERSION, description='Microsoft Azure Command-Line Tools Alerts Extension', - # TODO: Update author and email, if applicable + # TODO: Update author and email, if applicable author='Github:qwordy', author_email='fey@microsoft.com', # TODO: consider pointing directly to your source code instead of the generic repo From 0be79cf804ecc4fe58d8725765ee99d208ad72c7 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 20 Feb 2020 11:59:05 +0800 Subject: [PATCH 09/41] add code owner --- .github/CODEOWNERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 796b64d2965..79a4d77ac56 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -76,4 +76,6 @@ /src/connection-monitor-preview/ @haroldrandom -/src/support/ @mit2nil @shahbj79 \ No newline at end of file +/src/support/ @mit2nil @shahbj79 + +/src/alertsmanagement/ @qwordy From eebe4ee9338351082ab892f3db9fca8670618a17 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Mon, 9 Mar 2020 22:34:16 +0800 Subject: [PATCH 10/41] test --- .../azext_alertsmanagement/_help.py | 6 +- .../azext_alertsmanagement/_params.py | 4 +- .../test_alertsmanagement_action_rule.yaml | 238 +++++++++++++++--- .../latest/test_alertsmanagement_scenario.py | 37 ++- 4 files changed, 246 insertions(+), 39 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index 3fbbb06b721..d106f05f674 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -132,7 +132,7 @@ type: command short-summary: Creates/Updates a specific action rule examples: - - name: PutActionRule + - name: Create an action rule. text: |- az alertsmanagement action-rule create --resource-group "alertscorrelationrg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --start-date 12/09/2018 --end-date 12/18/2018 --start-time 06:00:00 --end-time 14:00:00 @@ -142,7 +142,7 @@ type: command short-summary: Creates/Updates a specific action rule examples: - - name: PatchActionRule + - name: Update an action rule. text: |- az alertsmanagement action-rule update --resource-group "alertscorrelationrg" --name \\ "WeeklySuppression" --status "Disabled" @@ -150,7 +150,7 @@ helps['alertsmanagement action-rule delete'] = """ type: command - short-summary: Deletes a given action rule + short-summary: Delete a given action rule examples: - name: DeleteActionRule text: |- diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index c5936f1c0fb..2858bb14791 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -103,9 +103,9 @@ def load_arguments(self, _): c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') c.argument('rule_type', arg_type=get_enum_type(['Suppression', 'ActionGroup', 'Diagnostics']), help='Indicates type of action rule') c.argument('description', help='Description of action rule') - c.argument('scope_type', help='Type of target scope') + c.argument('scope_type', help='Type of target scope', arg_type=get_enum_type(['ResourceGroup', 'Resource'])) c.argument('scope', nargs='+', help='List of ARM IDs (space-delimited) of the given scope type which will be the target of the given action rule.') - c.argument('severity', nargs='+', help='Filter alerts by severity. All filters should follow format "operator value1 value2 ... valueN". Operator is Equals, NotEquals, Contains or DoesNotContain.') + c.argument('severity', nargs='+', help='Filter alerts by severity. All filters should follow format "operator value1 value2 ... valueN". Operator is one of Equals, NotEquals, Contains and DoesNotContain.') c.argument('monitor_service', nargs='+', help='Filter alerts by monitor service') c.argument('monitor_condition', nargs='+', help='Filter alerts by monitor condition') c.argument('target_resource_type', nargs='+', help='Filter alerts by target resource type') diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index 495c3ecdff8..dd78fd07e12 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -1,9 +1,14 @@ interactions: - request: - body: '{"location": "Global", "properties": {"conditions": {"severity": {"operator": - "Equals", "values": ["Sev0", "Sev2"]}}, "status": "Enabled", "type": "Suppression", - "suppressionConfig": {"recurrenceType": "Daily", "schedule": {"startDate": "12/09/2018", - "endDate": "12/18/2018", "startTime": "06:00:00", "endTime": "14:00:00"}}}}' + body: 'b''{"location": "Global", "properties": {"scope": {"scopeType": "ResourceGroup", + "values": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]}, + "conditions": {"severity": {"operator": "Equals", "values": ["Sev0", "Sev2"]}, + "monitorService": {"operator": "Equals", "values": ["Platform", "Application + Insights"]}, "monitorCondition": {"operator": "Equals", "values": ["Fired"]}, + "targetResourceType": {"operator": "NotEquals", "values": ["Microsoft.Compute/VirtualMachines"]}}, + "status": "Enabled", "type": "Suppression", "suppressionConfig": {"recurrenceType": + "Daily", "schedule": {"startDate": "12/09/2018", "endDate": "12/18/2018", "startTime": + "06:00:00", "endTime": "14:00:00"}}}}''' headers: Accept: - application/json @@ -14,33 +19,35 @@ interactions: Connection: - keep-alive Content-Length: - - '326' + - '778' Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --status --rule-type --severity --recurrence-type + - --resource-group --name --location --status --rule-type --scope-type --scope + --severity --monitor-service --monitor-condition --target-resource-type --recurrence-type --start-date --end-date --start-time --end-time User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:37.7744856Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:16:42.8333622Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '729' + - '1160' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:55:39 GMT + - Mon, 09 Mar 2020 14:16:44 GMT expires: - '-1' pragma: @@ -54,7 +61,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1199' + - '1197' x-xss-protection: - 1; mode=block status: @@ -75,25 +82,26 @@ interactions: - --resource-group --name User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:37.7744856Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:16:42.8333622Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '729' + - '1160' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:55:41 GMT + - Mon, 09 Mar 2020 14:16:52 GMT expires: - '-1' pragma: @@ -128,25 +136,26 @@ interactions: - --resource-group --name --status User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:37.7744856Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:16:42.8333622Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '729' + - '1160' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:55:44 GMT + - Mon, 09 Mar 2020 14:16:54 GMT expires: - '-1' pragma: @@ -160,17 +169,22 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' + - '998' x-xss-protection: - 1; mode=block status: code: 200 message: OK - request: - body: '{"location": "Global", "properties": {"conditions": {"severity": {"operator": - "Equals", "values": ["Sev0", "Sev2"]}}, "status": "Disabled", "type": "Suppression", - "suppressionConfig": {"recurrenceType": "Daily", "schedule": {"startDate": "12/09/2018", - "endDate": "12/18/2018", "startTime": "06:00:00", "endTime": "14:00:00"}}}}' + body: 'b''{"location": "Global", "properties": {"scope": {"scopeType": "ResourceGroup", + "values": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]}, + "conditions": {"severity": {"operator": "Equals", "values": ["Sev0", "Sev2"]}, + "monitorService": {"operator": "Equals", "values": ["Platform", "Application + Insights"]}, "monitorCondition": {"operator": "Equals", "values": ["Fired"]}, + "targetResourceType": {"operator": "NotEquals", "values": ["Microsoft.Compute/VirtualMachines"]}}, + "status": "Disabled", "type": "Suppression", "suppressionConfig": {"recurrenceType": + "Daily", "schedule": {"startDate": "12/09/2018", "endDate": "12/18/2018", "startTime": + "06:00:00", "endTime": "14:00:00"}}}}''' headers: Accept: - application/json @@ -181,32 +195,33 @@ interactions: Connection: - keep-alive Content-Length: - - '327' + - '779' Content-Type: - application/json; charset=utf-8 ParameterSetName: - --resource-group --name --status User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.1.0 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview response: body: - string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Disabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-02-19T16:55:37.7744856Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-02-19T16:55:46.2519341Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:17:00.8193938Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '730' + - '1161' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Wed, 19 Feb 2020 16:55:46 GMT + - Mon, 09 Mar 2020 14:17:01 GMT expires: - '-1' pragma: @@ -220,7 +235,170 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1197' + - '1192' + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule list + Connection: + - keep-alive + User-Agent: + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/actionRules?api-version=2019-05-05-preview + response: + body: + string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T13:39:22.3390714Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T13:39:22.3390714Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:17:00.8193938Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '2198' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 09 Mar 2020 14:17:06 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '999' + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule list + Connection: + - keep-alive + ParameterSetName: + - -g + User-Agent: + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/actionRules?api-version=2019-05-05-preview + response: + body: + string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T13:39:22.3390714Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T13:39:22.3390714Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:17:00.8193938Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + headers: + cache-control: + - no-store, no-cache + content-length: + - '2198' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 09 Mar 2020 14:17:08 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '998' + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - alertsmanagement action-rule delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n + User-Agent: + - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 + accept-language: + - en-US + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1?api-version=2019-05-05-preview + response: + body: + string: 'true' + headers: + cache-control: + - no-store, no-cache + content-length: + - '4' + content-security-policy: + - script-src 'self' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 09 Mar 2020 14:17:14 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14998' x-xss-protection: - 1; mode=block status: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index bd88c0a5666..f30bc2d596a 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -42,13 +42,23 @@ def test_alertsmanagement_alert_rule(self, resource_group): @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_action_rule_') def test_alertsmanagement_action_rule(self, resource_group): + subs_id = self.get_subscription_id() + rg_id = '/subscriptions/{}/resourceGroups/{}'.format(subs_id, resource_group) + self.kwargs.update({ + 'rg_id': rg_id + }) self.cmd('az alertsmanagement action-rule create ' '--resource-group {rg} ' - '--name "rule1" ' - '--location "Global" ' - '--status "Enabled" ' + '--name rule1 ' + '--location Global ' + '--status Enabled ' '--rule-type Suppression ' + '--scope-type ResourceGroup ' + '--scope {rg_id} ' '--severity Equals Sev0 Sev2 ' + '--monitor-service Equals Platform "Application Insights" ' + '--monitor-condition Equals Fired ' + '--target-resource-type NotEquals Microsoft.Compute/VirtualMachines ' '--recurrence-type Daily ' '--start-date 12/09/2018 ' '--end-date 12/18/2018 ' @@ -63,7 +73,20 @@ def test_alertsmanagement_action_rule(self, resource_group): self.check('name', 'rule1'), self.check('location', 'Global'), self.check('properties.status', 'Enabled'), - self.check('properties.type', 'Suppression') + self.check('properties.type', 'Suppression'), + self.check('properties.conditions.monitorCondition.operator', 'Equals'), + self.check('properties.conditions.monitorCondition.values[0]', 'Fired'), + self.check('properties.conditions.severity.operator', 'Equals'), + self.check('properties.conditions.severity.values[0]', 'Sev0'), + self.check('properties.conditions.severity.values[1]', 'Sev2'), + self.check('properties.conditions.targetResourceType.operator', 'NotEquals'), + self.check('properties.conditions.targetResourceType.values[0]', + 'Microsoft.Compute/VirtualMachines'), + self.check('properties.suppressionConfig.recurrenceType', 'Daily'), + self.check('properties.suppressionConfig.schedule.endDate', '12/18/2018'), + self.check('properties.suppressionConfig.schedule.endTime', '14:00:00'), + self.check('properties.suppressionConfig.schedule.startDate', '12/09/2018'), + self.check('properties.suppressionConfig.schedule.startTime', '06:00:00'), ]) self.cmd('az alertsmanagement action-rule update ' @@ -74,6 +97,12 @@ def test_alertsmanagement_action_rule(self, resource_group): self.check('properties.status', 'Disabled') ]) + self.cmd('az alertsmanagement action-rule list') + + self.cmd('az alertsmanagement action-rule list -g {rg}') + + self.cmd('az alertsmanagement action-rule delete -g {rg} -n rule1') + @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_smart_group_') def test_alertsmanagement_smart_group(self, resource_group): self.cmd('az alertsmanagement smart-group get-all', From 48dc0b0cdc04867de937c710761ee6ad031a9da8 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 10 Mar 2020 10:56:43 +0800 Subject: [PATCH 11/41] remove rubbish code --- .../azext_metadata.json | 3 +- .../latest/test_alertsmanagement_scenario.py | 94 ------------------- 2 files changed, 1 insertion(+), 96 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json index 86f8b02db32..55c81bf3328 100644 --- a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json +++ b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json @@ -1,5 +1,4 @@ { "azext.isPreview": true, - "azext.minCliCoreVersion": "2.0.67", - "azext.maxCliCoreVersion": "3.0.0" + "azext.minCliCoreVersion": "2.0.67" } \ No newline at end of file diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index f30bc2d596a..5047f48e82d 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -136,97 +136,3 @@ def test_alertsmanagement_alert(self, resource_group): checks=[]) self.cmd('az alertsmanagement alert get-all', checks=[]) - - # @ResourceGroupPreparer() - # def test_alertsmanagement(self, resource_group): - # self.cmd('az alertsmanagement action-rule create ' - # '--resource-group {rg} ' - # '--name "DailySuppression" ' - # '--location "Global" ' - # '--status "Enabled"', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-detector-alert-rule show ' - # '--resource-group {rg} ' - # '--name "MyAlertRule"', - # checks=[]) - # - # self.cmd('az alertsmanagement action-rule show ' - # '--resource-group {rg} ' - # '--name "DailySuppression"', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-detector-alert-rule list ' - # '--resource-group {rg}', - # checks=[]) - # - # self.cmd('az alertsmanagement action-rule list ' - # '--resource-group {rg}', - # checks=[]) - # - # self.cmd('az alertsmanagement alert get-history ' - # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-group get-by-id ' - # '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', - # checks=[]) - # - # self.cmd('az alertsmanagement alert get-history ' - # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-detector-alert-rule list ' - # '--resource-group {rg}', - # checks=[]) - # - # self.cmd('az alertsmanagement alert get-by-id ' - # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - # checks=[]) - # - # self.cmd('az alertsmanagement alert get-summary', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-group get-all', - # checks=[]) - # - # self.cmd('az alertsmanagement action-rule list', - # checks=[]) - # - # self.cmd('az alertsmanagement alert get-all', - # checks=[]) - # - # self.cmd('az alertsmanagement alert meta-data', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-detector-alert-rule update ' - # '--resource-group {rg} ' - # '--name "MyAlertRule" ' - # '--description "New description for patching" ' - # '--frequency "PT1M"', - # checks=[]) - # - # self.cmd('az alertsmanagement action-rule update ' - # '--resource-group {rg} ' - # '--name "WeeklySuppression" ' - # '--status "Disabled"', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-group change-state ' - # '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' - # '--new-state "Acknowledged"', - # checks=[]) - # - # self.cmd('az alertsmanagement alert get-history ' - # '--alert-id "66114d64-d9d9-478b-95c9-b789d6502100"', - # checks=[]) - # - # self.cmd('az alertsmanagement smart-detector-alert-rule delete ' - # '--resource-group {rg} ' - # '--name "MyAlertRule"', - # checks=[]) - # - # self.cmd('az alertsmanagement action-rule delete ' - # '--resource-group {rg} ' - # '--name "DailySuppression"', - # checks=[]) From 7fb3654792f7e1583ebbbb8dbe7bdd819f34b93d Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 10 Mar 2020 17:28:20 +0800 Subject: [PATCH 12/41] Only reserve action-rule commands --- .../azext_alertsmanagement/_help.py | 176 +-------- .../azext_alertsmanagement/_params.py | 112 ------ .../azext_alertsmanagement/commands.py | 40 -- .../recordings/test_alertsmanagement.yaml | 56 --- .../test_alertsmanagement_action_rule.yaml | 38 +- .../test_alertsmanagement_alert.yaml | 357 ------------------ .../test_alertsmanagement_alert_rule.yaml | 111 ------ .../test_alertsmanagement_smart_group.yaml | 53 --- .../latest/test_alertsmanagement_scenario.py | 65 +--- 9 files changed, 25 insertions(+), 983 deletions(-) delete mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml delete mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml delete mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml delete mode 100644 src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index d106f05f674..64b68a34611 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -9,120 +9,6 @@ from knack.help_files import helps # pylint: disable=unused-import -helps['alertsmanagement operation'] = """ - type: group - short-summary: Commands to manage alertsmanagement operation. -""" - -helps['alertsmanagement operation list'] = """ - type: command - short-summary: List all operations available through Azure Alerts Management Resource Provider. -""" - -helps['alertsmanagement alert'] = """ - type: group - short-summary: Commands to manage alertsmanagement alert. -""" - -helps['alertsmanagement alert change-state'] = """ - type: command - short-summary: Change the state of an alert. - examples: - - name: Resolve - text: |- - az alertsmanagement alert change-state --alert-id "66114d64-d9d9-478b-95c9-b789d6502100" \\ - --new-state "Acknowledged" -""" - -helps['alertsmanagement alert meta-data'] = """ - type: command - short-summary: List alerts meta data information based on value of identifier parameter. - examples: - - name: MonService - text: |- - az alertsmanagement alert meta-data --identifier "MonitorServiceList" -""" - -helps['alertsmanagement alert get-all'] = """ - type: command - short-summary: List all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. time range). The results can then be sorted on the basis specific fields, with the default being lastModifiedDateTime. - examples: - - name: ListAlerts - text: |- - az alertsmanagement alert get-all -""" - -helps['alertsmanagement alert get-by-id'] = """ - type: command - short-summary: Get information related to a specific alert - examples: - - name: GetById - text: |- - az alertsmanagement alert get-by-id --alert-id "66114d64-d9d9-478b-95c9-b789d6502100" -""" - -helps['alertsmanagement alert get-history'] = """ - type: command - short-summary: Get the history of an alert, which captures any monitor condition changes (Fired/Resolved) and alert state changes (New/Acknowledged/Closed). - examples: - - name: Resolve - text: |- - az alertsmanagement alert get-history --alert-id "66114d64-d9d9-478b-95c9-b789d6502100" -""" - -helps['alertsmanagement alert get-summary'] = """ - type: command - short-summary: Get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns the count of alerts for each severity). - examples: - - name: Summary - text: |- - az alertsmanagement alert get-summary --groupby "severity,alertState" -""" - -helps['alertsmanagement smart-group'] = """ - type: group - short-summary: Commands to manage alertsmanagement smart group. -""" - -helps['alertsmanagement smart-group change-state'] = """ - type: command - short-summary: Change the state of a Smart Group. - examples: - - name: changestate - text: |- - az alertsmanagement smart-group change-state --smart-group-id \\ - "a808445e-bb38-4751-85c2-1b109ccc1059" --new-state "Acknowledged" -""" - -helps['alertsmanagement smart-group get-all'] = """ - type: command - short-summary: List all the Smart Groups within a specified subscription. - examples: - - name: List - text: |- - az alertsmanagement smart-group get-all -""" - -helps['alertsmanagement smart-group get-by-id'] = """ - type: command - short-summary: Get information related to a specific Smart Group. - examples: - - name: Get - text: |- - az alertsmanagement smart-group get-by-id --smart-group-id \\ - "603675da-9851-4b26-854a-49fc53d32715" -""" - -helps['alertsmanagement smart-group get-history'] = """ - type: command - short-summary: Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) . - examples: - - name: Resolve - text: |- - az alertsmanagement smart-group get-history --smart-group-id \\ - "a808445e-bb38-4751-85c2-1b109ccc1059" -""" - helps['alertsmanagement action-rule'] = """ type: group short-summary: Commands to manage alertsmanagement action rule. @@ -172,68 +58,10 @@ type: command short-summary: List all action rules of the subscription, created in given resource group and given input filters examples: - - name: GetActionRulesSubscriptionWide + - name: List action rules of the subscription text: |- az alertsmanagement action-rule list - - name: GetActionRulesResourceGroupWide + - name: List action rules of the resource group text: |- az alertsmanagement action-rule list --resource-group "alertscorrelationrg" """ - -helps['alertsmanagement smart-detector-alert-rule'] = """ - type: group - short-summary: Commands to manage alertsmanagement smart detector alert rule. -""" - -helps['alertsmanagement smart-detector-alert-rule create'] = """ - type: command - short-summary: Create or update a Smart Detector alert rule. - examples: - - name: Create or update a Smart Detector alert rule - text: |- - az alertsmanagement smart-detector-alert-rule create --resource-group "MyAlertRules" \\ - --name "MyAlertRule" --description "Sample smart detector alert rule description" --state \\ - "Enabled" --severity "Sev3" --frequency "PT5M" -""" - -helps['alertsmanagement smart-detector-alert-rule update'] = """ - type: command - short-summary: Create or update a Smart Detector alert rule. - examples: - - name: Patch alert rules - text: |- - az alertsmanagement smart-detector-alert-rule update --resource-group "MyAlertRules" \\ - --name "MyAlertRule" --description "New description for patching" --frequency "PT1M" -""" - -helps['alertsmanagement smart-detector-alert-rule delete'] = """ - type: command - short-summary: Delete an existing Smart Detector alert rule. - examples: - - name: Delete a Smart Detector alert rule - text: |- - az alertsmanagement smart-detector-alert-rule delete --resource-group "MyAlertRules" \\ - --name "MyAlertRule" -""" - -helps['alertsmanagement smart-detector-alert-rule show'] = """ - type: command - short-summary: Get a specific Smart Detector alert rule. - examples: - - name: Get a Smart Detector alert rule - text: |- - az alertsmanagement smart-detector-alert-rule show --resource-group "MyAlertRules" --name \\ - "MyAlertRule" -""" - -helps['alertsmanagement smart-detector-alert-rule list'] = """ - type: command - short-summary: List all the existing Smart Detector alert rules within the subscription and resource group. - examples: - - name: List Smart Detector alert rules - text: |- - az alertsmanagement smart-detector-alert-rule list --resource-group "MyAlertRules" - - name: List alert rules - text: |- - az alertsmanagement smart-detector-alert-rule list --resource-group "MyAlertRules" -""" diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 2858bb14791..04dd3eb7c3a 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -8,7 +8,6 @@ from azure.cli.core.commands.parameters import ( tags_type, - get_three_state_flag, get_enum_type, resource_group_name_type, get_location_type @@ -20,78 +19,6 @@ def load_arguments(self, _): name_arg_type = CLIArgumentType(options_list=['--name', '-n'], metavar='NAME') - with self.argument_context('alertsmanagement operation list') as c: - pass - - with self.argument_context('alertsmanagement alert change-state') as c: - c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') - c.argument('new_state', id_part=None, help='New state of the alert.') - - with self.argument_context('alertsmanagement alert meta-data') as c: - c.argument('identifier', id_part=None, help='Identification of the information to be retrieved by API call.') - - with self.argument_context('alertsmanagement alert get-all') as c: - c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') - c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') - c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') - c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') - c.argument('monitor_condition', id_part=None, help='Filter by monitor condition which is either \'Fired\' or \'Resolved\'. Default value is to select all.') - c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') - c.argument('alert_state', id_part=None, help='Filter by state of the alert instance. Default value is to select all.') - c.argument('alert_rule', id_part=None, help='Filter by specific alert rule. Default value is to select all.') - c.argument('smart_group_id', id_part=None, help='Filter the alerts list by the Smart Group Id. Default value is none.') - c.argument('include_context', arg_type=get_three_state_flag(), id_part=None, help='Include context which has contextual data specific to the monitor service. Default value is false\'') - c.argument('include_egress_config', arg_type=get_three_state_flag(), id_part=None, help='Include egress config which would be used for displaying the content in portal. Default value is \'false\'.') - c.argument('page_count', id_part=None, help='Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25.') - c.argument('sort_by', id_part=None, help='Sort the query results by input field, Default value is \'lastModifiedDateTime\'.') - c.argument('sort_order', id_part=None, help='Sort the query results order in either ascending or descending. Default value is \'desc\' for time fields and \'asc\' for others.') - c.argument('select', id_part=None, help='This filter allows to selection of the fields(comma separated) which would be part of the essential section. This would allow to project only the required fields rather than getting entire content. Default is to fetch all the fields in the essentials section.') - c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') - c.argument('custom_time_range', id_part=None, help='Filter by custom time range in the format / where time is in (ISO-8601 format)\'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none.') - - with self.argument_context('alertsmanagement alert get-by-id') as c: - c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') - - with self.argument_context('alertsmanagement alert get-history') as c: - c.argument('alert_id', id_part=None, help='Unique ID of an alert instance.') - - with self.argument_context('alertsmanagement alert get-summary') as c: - c.argument('groupby', id_part=None, help='This parameter allows the result set to be grouped by input fields (Maximum 2 comma separated fields supported). For example, groupby=severity or groupby=severity,alertstate. Possible values include: severity, alertState, monitorCondition, monitorService, signalType, alertRule') - c.argument('include_smart_groups_count', arg_type=get_three_state_flag(), id_part=None, help='Include count of the SmartGroups as part of the summary. Default value is \'false\'.') - c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') - c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') - c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') - c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') - c.argument('monitor_condition', id_part=None, help='Filter by monitor condition which is either \'Fired\' or \'Resolved\'. Default value is to select all.') - c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') - c.argument('alert_state', id_part=None, help='Filter by state of the alert instance. Default value is to select all.') - c.argument('alert_rule', id_part=None, help='Filter by specific alert rule. Default value is to select all.') - c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') - c.argument('custom_time_range', id_part=None, help='Filter by custom time range in the format / where time is in (ISO-8601 format)\'. Permissible values is within 30 days from query time. Either timeRange or customTimeRange could be used but not both. Default is none.') - - with self.argument_context('alertsmanagement smart-group change-state') as c: - c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') - c.argument('new_state', id_part=None, help='New state of the alert.') - - with self.argument_context('alertsmanagement smart-group get-all') as c: - c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') - c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') - c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') - c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') - c.argument('monitor_condition', id_part=None, help='Filter by monitor condition which is either \'Fired\' or \'Resolved\'. Default value is to select all.') - c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') - c.argument('smart_group_state', id_part=None, help='Filter by state of the smart group. Default value is to select all.') - c.argument('time_range', id_part=None, help='Filter by time range by below listed values. Default value is 1 day.') - c.argument('page_count', id_part=None, help='Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25.') - c.argument('sort_by', id_part=None, help='Sort the query results by input field. Default value is sort by \'lastModifiedDateTime\'.') - c.argument('sort_order', id_part=None, help='Sort the query results order in either ascending or descending. Default value is \'desc\' for time fields and \'asc\' for others.') - - with self.argument_context('alertsmanagement smart-group get-by-id') as c: - c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') - - with self.argument_context('alertsmanagement smart-group get-history') as c: - c.argument('smart_group_id', id_part=None, help='Smart group unique id. ') - action_rule_name = CLIArgumentType(overrides=name_arg_type, help='Name of action rule.', id_part='name') @@ -145,42 +72,3 @@ def load_arguments(self, _): c.argument('alert_rule_id', id_part=None, help='filter by alert rule id') c.argument('action_group', id_part=None, help='filter by action group configured as part of action rule') c.argument('name', id_part=None, help='filter by action rule name') - - with self.argument_context('alertsmanagement smart-detector-alert-rule create') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the alert rule.') - c.argument('location', arg_type=get_location_type(self.cli_ctx)) - c.argument('tags', tags_type) - c.argument('description', id_part=None, help='The alert rule description.') - c.argument('state', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='The alert rule state.') - c.argument('severity', arg_type=get_enum_type(['Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4']), id_part=None, help='The alert rule severity.') - c.argument('frequency', id_part=None, help='The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.') - c.argument('action_groups', nargs='+', id_part=None, help='The Action Group resource IDs') - c.argument('throttling', id_part=None, help='The alert rule throttling information.') - c.argument('detector', help='The alert rule\'s detector') - c.argument('scope', nargs='+', help='The alert rule resources scopes.') - - with self.argument_context('alertsmanagement smart-detector-alert-rule update') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the alert rule.') - c.argument('location', arg_type=get_location_type(self.cli_ctx)) - c.argument('tags', tags_type) - c.argument('description', id_part=None, help='The alert rule description.') - c.argument('state', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='The alert rule state.') - c.argument('severity', arg_type=get_enum_type(['Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4']), id_part=None, help='The alert rule severity.') - c.argument('frequency', id_part=None, help='The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.') - c.argument('action_groups', id_part=None, help='The alert rule actions.') - c.argument('throttling', id_part=None, help='The alert rule throttling information.') - - with self.argument_context('alertsmanagement smart-detector-alert-rule delete') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the alert rule.') - - with self.argument_context('alertsmanagement smart-detector-alert-rule show') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the alert rule.') - c.argument('expand_detector', arg_type=get_three_state_flag(), id_part=None, help='Indicates if Smart Detector should be expanded.') - - with self.argument_context('alertsmanagement smart-detector-alert-rule list') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('expand_detector', arg_type=get_three_state_flag(), id_part=None, help='Indicates if Smart Detector should be expanded.') diff --git a/src/alertsmanagement/azext_alertsmanagement/commands.py b/src/alertsmanagement/azext_alertsmanagement/commands.py index 69ae3198a6d..045e39a8f0f 100644 --- a/src/alertsmanagement/azext_alertsmanagement/commands.py +++ b/src/alertsmanagement/azext_alertsmanagement/commands.py @@ -12,35 +12,6 @@ def load_command_table(self, _): - from ._client_factory import cf_operations - alertsmanagement_operations = CliCommandType( - operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._operations_operations#OperationsOperations.{}', - client_factory=cf_operations) - with self.command_group('alertsmanagement operation', alertsmanagement_operations, client_factory=cf_operations) as g: - g.custom_command('list', 'list_alertsmanagement_operation') - - from ._client_factory import cf_alerts - alertsmanagement_alerts = CliCommandType( - operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._alerts_operations#AlertsOperations.{}', - client_factory=cf_alerts) - with self.command_group('alertsmanagement alert', alertsmanagement_alerts, client_factory=cf_alerts) as g: - g.custom_command('change-state', 'change_state_alertsmanagement_alert') - g.custom_command('meta-data', 'meta_data_alertsmanagement_alert') - g.custom_command('get-all', 'get_all_alertsmanagement_alert') - g.custom_command('get-by-id', 'get_by_id_alertsmanagement_alert') - g.custom_command('get-history', 'get_history_alertsmanagement_alert') - g.custom_command('get-summary', 'get_summary_alertsmanagement_alert') - - from ._client_factory import cf_smart_groups - alertsmanagement_smart_groups = CliCommandType( - operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._smart_groups_operations#SmartGroupsOperations.{}', - client_factory=cf_smart_groups) - with self.command_group('alertsmanagement smart-group', alertsmanagement_smart_groups, client_factory=cf_smart_groups) as g: - g.custom_command('change-state', 'change_state_alertsmanagement_smart_group') - g.custom_command('get-all', 'get_all_alertsmanagement_smart_group') - g.custom_command('get-by-id', 'get_by_id_alertsmanagement_smart_group') - g.custom_command('get-history', 'get_history_alertsmanagement_smart_group') - from ._client_factory import cf_action_rules alertsmanagement_action_rules = CliCommandType( operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._action_rules_operations#ActionRulesOperations.{}', @@ -53,14 +24,3 @@ def load_command_table(self, _): g.custom_command('delete', 'delete_alertsmanagement_action_rule') g.custom_show_command('show', 'get_alertsmanagement_action_rule') g.custom_command('list', 'list_alertsmanagement_action_rule') - - from ._client_factory import cf_smart_detector_alert_rules - alertsmanagement_smart_detector_alert_rules = CliCommandType( - operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._smart_detector_alert_rules_operations#SmartDetectorAlertRulesOperations.{}', - client_factory=cf_smart_detector_alert_rules) - with self.command_group('alertsmanagement smart-detector-alert-rule', alertsmanagement_smart_detector_alert_rules, client_factory=cf_smart_detector_alert_rules) as g: - g.custom_command('create', 'create_alertsmanagement_smart_detector_alert_rule') - g.custom_command('update', 'update_alertsmanagement_smart_detector_alert_rule') - g.custom_command('delete', 'delete_alertsmanagement_smart_detector_alert_rule') - g.custom_show_command('show', 'get_alertsmanagement_smart_detector_alert_rule') - g.custom_command('list', 'list_alertsmanagement_smart_detector_alert_rule') diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml deleted file mode 100644 index d4e378e237d..00000000000 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement.yaml +++ /dev/null @@ -1,56 +0,0 @@ -interactions: -- request: - body: '{"properties": {"description": "Sample smart detector alert rule description", - "state": "Enabled", "severity": "Sev3", "frequency": "PT5M", "detector": {"id": - "aaa"}, "scope": ["bbb"], "actionGroups": {"groupIds": ["ccc"]}}}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement smart-detector-alert-rule create - Connection: - - keep-alive - Content-Length: - - '224' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - --resource-group --name --description --state --severity --frequency --detector - --scope --action-groups - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement000001/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule?api-version=2019-06-01 - response: - body: - string: '{"error":{"code":"LinkedInvalidPropertyId","message":"Property id ''bbb'' - at path ''properties.scope[0]'' is invalid. Expect fully qualified resource - Id that start with ''/subscriptions/{subscriptionId}'' or ''/providers/{resourceProviderNamespace}/''."}}' - headers: - cache-control: - - no-cache - content-length: - - '247' - content-type: - - application/json; charset=utf-8 - date: - - Fri, 17 Jan 2020 06:53:52 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - x-content-type-options: - - nosniff - x-ms-failure-cause: - - gateway - status: - code: 400 - message: Bad Request -version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index dd78fd07e12..629486e28bf 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -36,7 +36,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:16:42.8333622Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:20.7032795Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -47,7 +47,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 09 Mar 2020 14:16:44 GMT + - Tue, 10 Mar 2020 09:21:21 GMT expires: - '-1' pragma: @@ -61,7 +61,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1197' + - '1199' x-xss-protection: - 1; mode=block status: @@ -90,7 +90,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:16:42.8333622Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:20.7032795Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -101,7 +101,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 09 Mar 2020 14:16:52 GMT + - Tue, 10 Mar 2020 09:21:24 GMT expires: - '-1' pragma: @@ -144,7 +144,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:16:42.8333622Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:20.7032795Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -155,7 +155,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 09 Mar 2020 14:16:54 GMT + - Tue, 10 Mar 2020 09:21:26 GMT expires: - '-1' pragma: @@ -210,7 +210,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:17:00.8193938Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:29.0366385Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -221,7 +221,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 09 Mar 2020 14:17:01 GMT + - Tue, 10 Mar 2020 09:21:28 GMT expires: - '-1' pragma: @@ -235,7 +235,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1192' + - '1199' x-xss-protection: - 1; mode=block status: @@ -262,8 +262,8 @@ interactions: response: body: string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T13:39:22.3390714Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T13:39:22.3390714Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:17:00.8193938Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:16:24.6085711Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:16:24.6085711Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:29.0366385Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' headers: cache-control: - no-store, no-cache @@ -274,7 +274,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 09 Mar 2020 14:17:06 GMT + - Tue, 10 Mar 2020 09:21:31 GMT expires: - '-1' pragma: @@ -317,8 +317,8 @@ interactions: response: body: string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T13:39:22.3390714Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T13:39:22.3390714Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-09T14:16:42.8333622Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-09T14:17:00.8193938Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:16:24.6085711Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:16:24.6085711Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:29.0366385Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' headers: cache-control: - no-store, no-cache @@ -329,7 +329,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 09 Mar 2020 14:17:08 GMT + - Tue, 10 Mar 2020 09:21:33 GMT expires: - '-1' pragma: @@ -343,7 +343,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '998' + - '999' x-xss-protection: - 1; mode=block status: @@ -384,7 +384,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Mon, 09 Mar 2020 14:17:14 GMT + - Tue, 10 Mar 2020 09:21:42 GMT expires: - '-1' pragma: @@ -398,7 +398,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-deletes: - - '14998' + - '14999' x-xss-protection: - 1; mode=block status: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml deleted file mode 100644 index 273d511cd0f..00000000000 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert.yaml +++ /dev/null @@ -1,357 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement alert get-history - Connection: - - keep-alive - ParameterSetName: - - --alert-id - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d/history?api-version=2019-05-05-preview - response: - body: - string: '{"properties":{"alertId":"1dde5384-3a40-4616-8a5d-be8e2453595d","modifications":[{"modificationEvent":"AlertCreated","oldValue":"","newValue":"","modifiedAt":"2020-01-20T07:09:21.1107075Z","modifiedBy":"System","comments":"","description":"Alert - fired"}]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d/history/default","type":"Microsoft.AlertsManagement/alerts","name":"rule1"}' - headers: - cache-control: - - no-store, no-cache - content-length: - - '470' - content-security-policy: - - script-src 'self' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Jan 2020 07:57:55 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-xss-protection: - - 1; mode=block - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement alert get-by-id - Connection: - - keep-alive - ParameterSetName: - - --alert-id - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d?api-version=2019-05-05-preview - response: - body: - string: '{"properties":{"essentials":{"severity":"Sev4","signalType":"Log","alertState":"New","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"5e2788b5-f2c5-40a1-b137-c2b3f530d160","alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","startDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""},"context":{"context":{"activityLog":{"authorization":{"action":"Microsoft.Compute/virtualMachines/write","scope":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/Microsoft.Compute/virtualMachines/vm1"},"channels":"Operation","claims":"{\"aud\":\"https://management.core.windows.net/\",\"iss\":\"https://sts.windows.net/54826b22-38d6-4fb2-bad9-b7b93a3e9c5a/\",\"iat\":\"1579500784\",\"nbf\":\"1579500784\",\"exp\":\"1579504684\",\"http://schemas.microsoft.com/claims/authnclassreference\":\"1\",\"aio\":\"AWQAm/8OAAAACjpJ16Rghg/9w/tunPtFKG3itgqujW++yG73v5gIiyl+ZuIAqYicgjquOswg6m96nQRyBjMoLW05YIbya46jeDLtIJ0HKI2eCOw+naQNNvRl/tRWhPcRzCVlIyQfYDD7\",\"altsecid\":\"5::10032000571A5D04\",\"http://schemas.microsoft.com/claims/authnmethodsreferences\":\"pwd\",\"appid\":\"04b07795-8ddb-461a-bbee-02f9e1bf7b46\",\"appidacr\":\"0\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress\":\"fey@microsoft.com\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname\":\"Yu\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname\":\"Feiyue\",\"groups\":\"e4bb0b56-1014-40f8-88ab-3d8a8cb0e086\",\"http://schemas.microsoft.com/identity/claims/identityprovider\":\"https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/\",\"ipaddr\":\"167.220.255.61\",\"name\":\"Feiyue - Yu\",\"http://schemas.microsoft.com/identity/claims/objectidentifier\":\"0a592c45-613e-4f1b-9023-7c4414fd53bf\",\"puid\":\"10032000577FB6BB\",\"http://schemas.microsoft.com/identity/claims/scope\":\"user_impersonation\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier\":\"6sKBNS97eU3Bww8tsvVwB7vGnEPRsbGy0LcbjXQerX8\",\"http://schemas.microsoft.com/identity/claims/tenantid\":\"54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name\":\"fey@microsoft.com\",\"uti\":\"D1Jv9tpjw0m0en9C9oBWAA\",\"ver\":\"1.0\",\"wids\":\"62e90394-69f5-4237-9190-012177145e10\"}","caller":"fey@microsoft.com","correlationId":"69d22ec0-5d6e-49be-9b9b-bc9437059d22","description":"","eventSource":"Administrative","eventTimestamp":"2020-01-20T07:08:31.0511601Z","eventDataId":"5e2788b5-f2c5-40a1-b137-c2b3f530d160","level":"Informational","operationName":"Microsoft.Compute/virtualMachines/write","operationId":"552489d1-521a-4b9c-a85b-810a6e3d0256","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/Microsoft.Compute/virtualMachines/vm1","resourceGroupName":"fytest3","resourceProviderName":"Microsoft.Compute","status":"Succeeded","subStatus":"","subscriptionId":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","submissionTimestamp":"2020-01-20T07:09:20.0850147Z","resourceType":"Microsoft.Compute/virtualMachines"}}},"egressConfig":{"partitionKey":"MonitorServiceConfigurationCollectionPartition","monitorService":"ActivityLog - Administrative","monitorServiceOwnerEmailIds":"rkadr@microsoft.com","modifiedByApplicationId":"ccdfc67e-a7a1-4df5-91c7-7876da73b995","displayConfig":[{"rootJsonNode":"context.activityLog","sectionName":"","displayControls":[{"property":"eventSource","displayName":"Event - source","type":"Text","isOptional":false},{"property":"channels","displayName":"Channels","type":"Text","isOptional":false},{"property":"level","displayName":"Level","type":"Text","isOptional":false},{"property":"caller","displayName":"Caller","type":"Text","isOptional":false},{"property":"eventDataId","displayName":"Event - data id","type":"Text","isOptional":false}]},{"rootJsonNode":"context.activityLog","sectionName":"","displayControls":[{"property":"status","displayName":"Status","type":"Text","isOptional":false},{"property":"operationId","displayName":"Operation - id","type":"Text","isOptional":false},{"property":"operationName","displayName":"Operation - name","type":"Text","isOptional":false},{"property":"submissionTimeStamp","displayName":"Submission - time stamp","type":"Text","isOptional":false}]},{"rootJsonNode":"context.activityLog","sectionName":"","displayControls":[{"property":"authorization.action","displayName":"Authorization - - Action","type":"Text","isOptional":false},{"property":"authorization.scope","displayName":"Authorization - - Scope","type":"Text","isOptional":false},{"property":"claims","displayName":"Claims","type":"Text","isOptional":false},{"property":"httpRequest","displayName":"HTTP - request","type":"Text","isOptional":false}]}]}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"}' - headers: - cache-control: - - no-store, no-cache - content-length: - - '5382' - content-security-policy: - - script-src 'self' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Jan 2020 07:57:58 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' - x-xss-protection: - - 1; mode=block - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement alert get-summary - Connection: - - keep-alive - ParameterSetName: - - --groupby - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alertsSummary?groupby=severity%2Calertstate&api-version=2019-05-05-preview - response: - body: - string: '{"properties":{"groupedby":"severity","total":84,"values":[{"name":"Sev0","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev1","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev2","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev3","count":0,"groupedby":"alertState","values":[{"name":"New","count":0},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]},{"name":"Sev4","count":84,"groupedby":"alertState","values":[{"name":"New","count":84},{"name":"Acknowledged","count":0},{"name":"Closed","count":0}]}]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alertsSummary/current","type":"Microsoft.AlertsManagement/alertsSummary","name":"current"}' - headers: - cache-control: - - no-store, no-cache - content-length: - - '993' - content-security-policy: - - script-src 'self' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Jan 2020 07:58:00 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' - x-xss-protection: - - 1; mode=block - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement alert get-all - Connection: - - keep-alive - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts?api-version=2019-05-05-preview - response: - body: - string: '{"nextLink":"https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts?api-version=2019-05-05-preview&ctoken=%2bRID%3a%7eTxpXAK6hCE2XRlABAAAgDA%3d%3d%23RT%3a1%23TRC%3a50%23RTD%3aqtQyMDIwLTAxLTIwVDA3OjQyOjU2LjEyODc0NDha%23ISV%3a1","value":[{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"216ca771-c5be-4a70-9be6-897dadb25b28","startDateTime":"2020-01-20T07:57:55.5094319Z","lastModifiedDateTime":"2020-01-20T07:57:55.5094319Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/77a487ca-b08f-49d0-9f5f-cfd9a1060c81","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"7fbd4fc3-80a7-45a8-ae80-4c94c2c7b4d9","startDateTime":"2020-01-20T07:57:48.6229975Z","lastModifiedDateTime":"2020-01-20T07:57:48.6229975Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/0ea0315d-6a41-4984-9be9-96f0e87668e9","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"e820956d-664a-483a-a770-e0d407003804","startDateTime":"2020-01-20T07:57:40.7844929Z","lastModifiedDateTime":"2020-01-20T07:57:40.7844929Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7207a331-e7cf-4686-ac57-3226583bb014","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"f610e1ac-6cc8-4687-a7d6-b164c5339777","startDateTime":"2020-01-20T07:57:35.9503654Z","lastModifiedDateTime":"2020-01-20T07:57:35.9503654Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c9a916df-e71c-418e-b454-00ead784ee59","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"f12dda7f-de52-4209-8946-077df629c3c8","startDateTime":"2020-01-20T07:57:32.3044374Z","lastModifiedDateTime":"2020-01-20T07:57:32.3044374Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/e4b5a484-8fa4-4339-8517-6dac03460713","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_djitloidunizp4wdxe2kari6wl6e2dcciychgphn7ng","targetResourceType":"","sourceCreatedId":"a7bb99d4-f0fd-45f2-b8f3-8c3c5f193df3","startDateTime":"2020-01-20T07:57:31.1412791Z","lastModifiedDateTime":"2020-01-20T07:57:31.1412791Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5ca5aaaa-9e45-4ef1-b431-b244d88ac087","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"a1af56dc-649c-4e86-8eb5-f2e948f6d67d","startDateTime":"2020-01-20T07:57:15.927035Z","lastModifiedDateTime":"2020-01-20T07:57:15.927035Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/765e234b-dba0-4fd7-9fd3-a773bf37f328","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"d9f10ae6-a9ba-42c0-a896-123da9efe552","startDateTime":"2020-01-20T07:53:58.7649465Z","lastModifiedDateTime":"2020-01-20T07:53:58.7649465Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/215ca1fc-e4ce-4b6e-9869-f6e8165f496a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"0d562e5c-320c-4f7f-b274-7e3dae6fb1b0","startDateTime":"2020-01-20T07:53:44.7902134Z","lastModifiedDateTime":"2020-01-20T07:53:44.7902134Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/2f98a958-0727-4772-a009-af552243aca3","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"8459a6cd-279a-4869-8882-c0dcb95bcc09","startDateTime":"2020-01-20T07:53:14.525652Z","lastModifiedDateTime":"2020-01-20T07:53:14.525652Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5748e11d-81b2-4037-8e92-15b39c4d01c4","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"8f7f7f59-38bf-4aaf-82c8-be0fbfc56f27","startDateTime":"2020-01-20T07:53:03.0511332Z","lastModifiedDateTime":"2020-01-20T07:53:03.0511332Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d38ea903-6a2f-415d-9d5e-ba7f61a3ad19","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"8e444d44-947b-49f1-bc96-b03f9ac2bc8f","startDateTime":"2020-01-20T07:53:01.2252548Z","lastModifiedDateTime":"2020-01-20T07:53:01.2252548Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/09dab1f8-2a29-4350-8e95-1257e335e4f2","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"a7d8e11a-6f41-4789-ad05-c4d9ab6b7b5a","startDateTime":"2020-01-20T07:52:56.4079777Z","lastModifiedDateTime":"2020-01-20T07:52:56.4079777Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d8ea7c86-f063-40f9-a56f-746e64d032ed","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"97c6033d-cf33-4bc6-b181-ae304389e022","startDateTime":"2020-01-20T07:52:47.4565148Z","lastModifiedDateTime":"2020-01-20T07:52:47.4565148Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8fd7cd61-727e-493a-bc0d-6b160e4c7f18","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"b8b466e5-72f7-4c70-bc7a-9240deedc01e","startDateTime":"2020-01-20T07:52:01.3298942Z","lastModifiedDateTime":"2020-01-20T07:52:01.3298942Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f4a2da67-c16f-42fa-a571-a598f692c74a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"c4c9fe36-86e2-4e15-8c9e-ffa019a4101e","startDateTime":"2020-01-20T07:52:00.7372881Z","lastModifiedDateTime":"2020-01-20T07:52:00.7372881Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f4672343-cf8f-462f-8abc-4eff99881e1c","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"e6df5722-d53b-42a2-86ad-2c8179011e08","startDateTime":"2020-01-20T07:51:37.6980376Z","lastModifiedDateTime":"2020-01-20T07:51:37.6980376Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5debb8fa-f5f4-4cbd-a6b5-2bf0bfc42eae","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"7bd45f82-534c-481a-b832-54cdac8f87a5","startDateTime":"2020-01-20T07:51:36.2736377Z","lastModifiedDateTime":"2020-01-20T07:51:36.2736377Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cfd2e4a4-99ef-4d48-9891-8660af342e3d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"17b1927d-cd90-412c-b200-eb4d66a71137","startDateTime":"2020-01-20T07:51:34.3312389Z","lastModifiedDateTime":"2020-01-20T07:51:34.3312389Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c885c5d1-67b9-4923-aa93-387e48f23fd4","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"f66c6af7-a7b1-404e-a6bb-e0e9ea23e860","startDateTime":"2020-01-20T07:51:29.1216442Z","lastModifiedDateTime":"2020-01-20T07:51:29.1216442Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/45ad09c5-8583-48f2-8669-e7d8499da237","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"e248dc0e-0bd9-4ffa-9041-211e12cb1d09","startDateTime":"2020-01-20T07:51:26.504333Z","lastModifiedDateTime":"2020-01-20T07:51:26.504333Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5809c8d8-6f95-45eb-8e10-cb5c56dfb08a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"874ab6c2-a22a-4645-8559-69486c779909","startDateTime":"2020-01-20T07:51:24.013887Z","lastModifiedDateTime":"2020-01-20T07:51:24.013887Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/38278112-fe6d-40df-80c5-c260f26a0685","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/notificationhubs/my-test-hub/authorizationrules/my-hub-listen-key","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"9433cc99-feea-4480-8222-10b3cc77998c","startDateTime":"2020-01-20T07:51:18.9307378Z","lastModifiedDateTime":"2020-01-20T07:51:18.9307378Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/4a08d675-0dff-4c8e-a47a-fbaddc5d3acc","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"3101519a-612c-40fa-a39b-24cb788821eb","startDateTime":"2020-01-20T07:51:15.2829736Z","lastModifiedDateTime":"2020-01-20T07:51:15.2829736Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/0b050ae5-d955-406b-999f-d3464e535428","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"94926307-904b-4ca6-b559-60a026c9acf8","startDateTime":"2020-01-20T07:51:09.6252756Z","lastModifiedDateTime":"2020-01-20T07:51:09.6252756Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/41e04ad4-5873-4095-98d2-cc091e64c82b","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"6af6afd9-6ee3-493a-accb-65439b3fb06f","startDateTime":"2020-01-20T07:51:08.7088066Z","lastModifiedDateTime":"2020-01-20T07:51:08.7088066Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ca833f3a-e7ba-4e2b-b499-43e890e86161","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space/authorizationrules/my-space-rule","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"269e1429-c3ca-4954-9559-c23d25a6b0fb","startDateTime":"2020-01-20T07:51:01.3575743Z","lastModifiedDateTime":"2020-01-20T07:51:01.3575743Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/426593cb-76a0-4bd9-a2ef-6ee720c827d0","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"179edb92-15c3-4552-be4a-a26649e6fbe1","startDateTime":"2020-01-20T07:50:57.5620124Z","lastModifiedDateTime":"2020-01-20T07:50:57.5620124Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c2df50ce-954d-4e34-ba06-dabdc996cb9e","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"f52cb859-ad63-4c6c-a3d7-b9d6b24aebdb","startDateTime":"2020-01-20T07:50:48.3954841Z","lastModifiedDateTime":"2020-01-20T07:50:48.3954841Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/00722648-6f2b-4285-ab58-5ef075b54594","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"1b661885-2fcf-4582-a62d-27161642198a","startDateTime":"2020-01-20T07:50:41.9673058Z","lastModifiedDateTime":"2020-01-20T07:50:41.9673058Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/06d79f29-d9d0-4cfa-b6b6-be65e61666d2","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"14f7b750-7516-42ff-9807-0dd25715cb8f","startDateTime":"2020-01-20T07:50:37.0629334Z","lastModifiedDateTime":"2020-01-20T07:50:37.0629334Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/9923b848-8ef3-40ce-a93b-158807b9a497","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"320402fe-70ca-4c97-b2a2-55b5b6845f29","startDateTime":"2020-01-20T07:50:37.0474515Z","lastModifiedDateTime":"2020-01-20T07:50:37.0474515Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/aa56af9c-77a0-4e25-88f2-24b382a7d478","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceName":"","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"","sourceCreatedId":"f4fc4b33-dc46-4f34-88d9-b731aa000a0c","startDateTime":"2020-01-20T07:50:35.7347511Z","lastModifiedDateTime":"2020-01-20T07:50:35.7347511Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7b945696-56df-4b7c-97cb-f14f29965e46","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.notificationhubs","targetResourceName":"","targetResourceGroup":"","targetResourceType":"","sourceCreatedId":"b3986983-191f-4e44-a682-3a684c490da3","startDateTime":"2020-01-20T07:50:31.3913265Z","lastModifiedDateTime":"2020-01-20T07:50:31.3913265Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/679ec649-01d6-4f02-a135-00d7a290db51","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_y6i5pdvrgas7bes5qz4lpyqrjmqs7poh24r542pww5s","targetResourceType":"","sourceCreatedId":"57afa1b7-ae91-4a0b-bdb6-3ad19765f130","startDateTime":"2020-01-20T07:50:29.6610175Z","lastModifiedDateTime":"2020-01-20T07:50:29.6610175Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7ec69ee4-8cb8-480f-ad2e-b56424f7066d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.notificationhubs","targetResourceName":"","targetResourceGroup":"","targetResourceType":"","sourceCreatedId":"70f56a5b-0428-4243-8444-02e534cfe425","startDateTime":"2020-01-20T07:50:17.0501887Z","lastModifiedDateTime":"2020-01-20T07:50:17.0501887Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f059a362-0342-4585-a606-d1bffec081a6","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"b6efe870-339d-4816-9a59-ef50d8ac1eba","startDateTime":"2020-01-20T07:50:14.6282086Z","lastModifiedDateTime":"2020-01-20T07:50:14.6282086Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/510a8450-6efb-4fcf-be4d-07dd4acd3c65","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"38f75778-5495-4034-8bcf-6794a3749da4","startDateTime":"2020-01-20T07:50:11.1048096Z","lastModifiedDateTime":"2020-01-20T07:50:11.1048096Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/efc8fb74-c4f6-47dc-b554-dfe75bc19c3c","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"027bc922-21dd-41bb-8eb3-c539f76b0721","startDateTime":"2020-01-20T07:50:05.6579163Z","lastModifiedDateTime":"2020-01-20T07:50:05.6579163Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5aa059bb-fa5c-4893-b256-2f1ca4840475","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_6npq4ixwuzgw6zp3kuvbbekfwneckcutktruligfwdu","targetResourceType":"","sourceCreatedId":"ff32bc38-c72b-4edc-9141-da0409cdb2cc","startDateTime":"2020-01-20T07:49:55.5168487Z","lastModifiedDateTime":"2020-01-20T07:49:55.5168487Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cc789036-46d5-4b5b-b941-ac90112adc55","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e/providers/microsoft.notificationhubs/namespaces/my-test-space","targetResourceName":"my-test-space","targetResourceGroup":"cli_test_notificationhubskszz3fgp2zb7h6p7gvhy45vae2eonrvcebuhac62eu6lvcvw3e","targetResourceType":"namespaces","sourceCreatedId":"78945ed2-882b-4425-beda-b2f6e1999dc3","startDateTime":"2020-01-20T07:49:42.6986923Z","lastModifiedDateTime":"2020-01-20T07:49:42.6986923Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d822bc7c-4a4f-43df-87d7-ef2541664f88","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"66619eba-b950-482d-8f9a-7e8f867680c7","startDateTime":"2020-01-20T07:48:13.3277567Z","lastModifiedDateTime":"2020-01-20T07:48:13.3277567Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/fc1374ae-1d16-42dd-8f4c-4bc3a53a123d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"0dfaeb0d-d8f0-41b7-a66a-e34b873944a5","startDateTime":"2020-01-20T07:47:24.7325953Z","lastModifiedDateTime":"2020-01-20T07:47:24.7325953Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/6e0f3026-3733-4dfb-b14e-5acdb2f723c1","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"0c63cfec-ed32-4625-a8ba-b2c287665bf2","startDateTime":"2020-01-20T07:47:23.6298306Z","lastModifiedDateTime":"2020-01-20T07:47:23.6298306Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/04772497-6b73-4cd1-835f-0697279328d0","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"e2f170e7-8097-49e1-bb57-3c80f388049d","startDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/a010d10b-d462-4f9d-b34c-b6b091e8f502","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceName":"","targetResourceGroup":"cli_test_alertsmanagement_alert_ccgcr6url26as56ns4b3gzlpgupdxwzuacx455defre","targetResourceType":"","sourceCreatedId":"7588a96e-3878-4090-b903-a56117431742","startDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedDateTime":"2020-01-20T07:46:57.4001279Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5a6ecba0-1ee5-446a-af35-e0b2e606bc7a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"021ac2f8-9aa4-4f7c-ab1e-6d2309b81959","startDateTime":"2020-01-20T07:44:03.6096308Z","lastModifiedDateTime":"2020-01-20T07:44:03.6096308Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f079e751-7ed0-46fb-bbf8-51b492a62bbc","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"ea2e4dce-7314-4aba-b24b-60dd227467a4","startDateTime":"2020-01-20T07:43:47.2710982Z","lastModifiedDateTime":"2020-01-20T07:43:47.2710982Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/a9ed6d3c-aea3-4e6f-9d9e-fb27be85f54a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"83f2b624-2c62-4255-9542-de63bd53f4fa","startDateTime":"2020-01-20T07:43:18.6068908Z","lastModifiedDateTime":"2020-01-20T07:43:18.6068908Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/bb6f2e7b-1aff-4773-aedc-5178a5f260c7","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"274e696c-0797-44f7-978d-3519040b91d5","startDateTime":"2020-01-20T07:42:56.1287448Z","lastModifiedDateTime":"2020-01-20T07:42:56.1287448Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ec63bc45-d7d7-41c3-9985-6b155d31911d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"}]}' - headers: - cache-control: - - no-store, no-cache - content-length: - - '54493' - content-security-policy: - - script-src 'self' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Jan 2020 07:58:03 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' - x-xss-protection: - - 1; mode=block - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement alert get-all - Connection: - - keep-alive - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.80 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts?api-version=2019-05-05-preview&ctoken=%2bRID%3a~TxpXAK6hCE2XRlABAAAgDA%3d%3d%23RT%3a1%23TRC%3a50%23RTD%3aqtQyMDIwLTAxLTIwVDA3OjQyOjU2LjEyODc0NDha%23ISV%3a1 - response: - body: - string: '{"value":[{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"b6b2bf96-e15b-42d2-9610-fffabb944c16","startDateTime":"2020-01-20T07:42:52.1716037Z","lastModifiedDateTime":"2020-01-20T07:42:52.1716037Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cfb4b0f1-e618-403e-a8ab-1cea570a5942","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"e30f2875-d115-4129-82f7-80aa769aa09b","startDateTime":"2020-01-20T07:42:50.9021318Z","lastModifiedDateTime":"2020-01-20T07:42:50.9021318Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f7931d3c-db4a-40b5-bf7c-e150b77ce324","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg99710a","targetResourceName":"","targetResourceGroup":"rg99710a","targetResourceType":"","sourceCreatedId":"eb908f86-ea97-4588-9c41-12666941dc32","startDateTime":"2020-01-20T07:42:50.3342457Z","lastModifiedDateTime":"2020-01-20T07:42:50.3342457Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/d6975f7d-42da-49bd-b66a-168eb0e726c4","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"44ea98d2-3c3e-41f9-ae60-930c073af2b7","startDateTime":"2020-01-20T07:30:49.3787388Z","lastModifiedDateTime":"2020-01-20T07:30:49.3787388Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/5550a5cd-3391-44d5-a27c-3889c6fe01cf","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.insights/activitylogalerts/rule2","targetResourceName":"rule2","targetResourceGroup":"fytest3","targetResourceType":"activitylogalerts","sourceCreatedId":"9533a774-7fc3-4bef-8748-d0004bb88675","startDateTime":"2020-01-20T07:30:42.8462977Z","lastModifiedDateTime":"2020-01-20T07:30:42.8462977Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/7644a9b8-27c7-48de-9aef-48d224c588c8","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"8e154d3f-96c5-44bb-8dfa-2168f5f45616","startDateTime":"2020-01-20T07:30:09.9361446Z","lastModifiedDateTime":"2020-01-20T07:30:09.9361446Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/57973c01-f204-4b7f-8758-b5acac6e1343","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/bim-rg/providers/microsoft.keyvault/vaults/bim-kv5","targetResourceName":"bim-kv5","targetResourceGroup":"bim-rg","targetResourceType":"vaults","sourceCreatedId":"4768e756-4f73-4570-8e59-b0aedcf27138","startDateTime":"2020-01-20T07:29:58.2069762Z","lastModifiedDateTime":"2020-01-20T07:29:58.2069762Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/c5fb08d9-1209-413e-b71d-351a118ec77c","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"879b705f-556f-448f-99be-d7834e86eb3d","startDateTime":"2020-01-20T07:29:06.9706248Z","lastModifiedDateTime":"2020-01-20T07:29:06.9706248Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/53c692f7-9031-41e3-a522-5436ff4d5f7a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/acctestrg-mssqlvm-tf/providers/microsoft.keyvault/vaults/acckvtf3","targetResourceName":"acckvtf3","targetResourceGroup":"acctestrg-mssqlvm-tf","targetResourceType":"vaults","sourceCreatedId":"3b71c87a-1262-4302-8aaf-ea25f5ac2976","startDateTime":"2020-01-20T07:28:55.3245957Z","lastModifiedDateTime":"2020-01-20T07:28:55.3245957Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/2e14a7f9-e9a5-438b-ae84-6439d98421fc","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"bb1a2cc7-975c-440c-95ba-6e668c2d5d93","startDateTime":"2020-01-20T07:26:30.4233806Z","lastModifiedDateTime":"2020-01-20T07:26:30.4233806Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f9c24fa5-5103-4d5a-97d7-04637fa72c6a","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"b9a29fea-ed48-4ff7-80b7-a50f8e3ed91a","startDateTime":"2020-01-20T07:26:08.8398227Z","lastModifiedDateTime":"2020-01-20T07:26:08.8398227Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/82085348-e9ee-4081-b357-16bf5dc5c0e6","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"e9ca3586-64d2-4b40-b7d6-8a0810e2fed0","startDateTime":"2020-01-20T07:26:07.5741733Z","lastModifiedDateTime":"2020-01-20T07:26:07.5741733Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/e42b99f2-34c8-4693-a8d2-19f1c4b7fc20","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"e913ab71-b238-4dbc-900a-40f07af2f8fe","startDateTime":"2020-01-20T07:26:06.4404755Z","lastModifiedDateTime":"2020-01-20T07:26:06.4404755Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/4de91bec-8926-404d-820c-f90a5562b515","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"123d0f64-d680-4967-a5d3-6895909e7a89","startDateTime":"2020-01-20T07:25:56.5900617Z","lastModifiedDateTime":"2020-01-20T07:25:56.5900617Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f737f576-152b-46ae-9534-83f83a9991ab","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"6e5ad26d-22db-4dd3-9549-8fe6ae6e380f","startDateTime":"2020-01-20T07:25:55.7775404Z","lastModifiedDateTime":"2020-01-20T07:25:55.7775404Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/459ed590-b925-4d8f-93eb-2c0d5b629931","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg532017","targetResourceName":"","targetResourceGroup":"rg532017","targetResourceType":"","sourceCreatedId":"8a6cdfb5-7101-4e49-94d2-96e5fe5939d4","startDateTime":"2020-01-20T07:25:47.6590636Z","lastModifiedDateTime":"2020-01-20T07:25:47.6590636Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8142305a-5726-4150-ad64-7cef674ca554","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test/providers/microsoft.compute/disks/test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceName":"test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceGroup":"test","targetResourceType":"disks","sourceCreatedId":"0e7cc7d7-ef30-459d-b4e0-484d4a335776","startDateTime":"2020-01-20T07:24:11.0185974Z","lastModifiedDateTime":"2020-01-20T07:24:11.0185974Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/92cf85b4-4453-49d6-b658-9680ce19c933","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/xiaojianxu/providers/microsoft.compute/disks/test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceName":"test7_disk1_843eb6afe52d4eb9812ec7c642150759","targetResourceGroup":"xiaojianxu","targetResourceType":"disks","sourceCreatedId":"aae664f6-3b58-4da2-896e-6346820cdd6e","startDateTime":"2020-01-20T07:23:20.1773014Z","lastModifiedDateTime":"2020-01-20T07:23:20.1773014Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8ff0623b-5af1-4d78-98bb-ae8fafecc160","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test/providers/microsoft.network/networkinterfaces/test7vmnic","targetResourceName":"test7vmnic","targetResourceGroup":"test","targetResourceType":"networkinterfaces","sourceCreatedId":"46f254c0-016b-4618-b5c4-4df2fef42a40","startDateTime":"2020-01-20T07:22:50.9005649Z","lastModifiedDateTime":"2020-01-20T07:22:50.9005649Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/8109e42c-3dd3-4c5a-b9b7-d9e05cf9d83d","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.insights/activitylogalerts/rule2","targetResourceName":"rule2","targetResourceGroup":"fytest3","targetResourceType":"activitylogalerts","sourceCreatedId":"7ffbe0a8-426e-4eb0-9aa5-5ff2f4e37e01","startDateTime":"2020-01-20T07:20:49.541761Z","lastModifiedDateTime":"2020-01-20T07:20:49.541761Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/0f0e2b99-55e6-4d77-9e9a-ce87cd0b95f6","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule2","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.insights/activitylogalerts/rule2","targetResourceName":"rule2","targetResourceGroup":"fytest3","targetResourceType":"activitylogalerts","sourceCreatedId":"7bcde580-a05b-4167-a865-9764c6547eb9","startDateTime":"2020-01-20T07:20:01.9043401Z","lastModifiedDateTime":"2020-01-20T07:20:01.9043401Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/29c4acad-8eb1-4955-86c8-99d6229e7e1f","type":"Microsoft.AlertsManagement/alerts","name":"rule2"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/jlrg1/providers/microsoft.compute/virtualmachines/test5","targetResourceName":"test5","targetResourceGroup":"jlrg1","targetResourceType":"virtualmachines","sourceCreatedId":"5c61d88a-2451-45ea-9e75-064126b9ab4d","startDateTime":"2020-01-20T07:17:04.5898192Z","lastModifiedDateTime":"2020-01-20T07:17:04.5898192Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/e238e7db-b94c-4ae3-bd76-fbd97c2f458d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/jlrg1/providers/microsoft.compute/virtualmachines/test5","targetResourceName":"test5","targetResourceGroup":"jlrg1","targetResourceType":"virtualmachines","sourceCreatedId":"651bc8df-7340-4d15-8125-6662afa3bb19","startDateTime":"2020-01-20T07:15:49.8003226Z","lastModifiedDateTime":"2020-01-20T07:15:49.8003226Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/21381cb7-8186-4c51-8196-d5052d70eeea","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/jlrg1/providers/microsoft.compute/virtualmachines/test5","targetResourceName":"test5","targetResourceGroup":"jlrg1","targetResourceType":"virtualmachines","sourceCreatedId":"4f570640-6b99-4637-94d5-b8b64af5ddae","startDateTime":"2020-01-20T07:15:46.2967815Z","lastModifiedDateTime":"2020-01-20T07:15:46.2967815Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1a3cc527-ecd4-4c13-bd35-108e82fcf7dd","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"2cb48ba8-4ac9-4e55-9719-cca482d85c25","startDateTime":"2020-01-20T07:15:14.2662421Z","lastModifiedDateTime":"2020-01-20T07:15:14.2662421Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/f93358ad-256e-4a64-ae9a-a64d246e74b5","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"dc55163d-239c-4ba0-85e7-9eb4094ca3a4","startDateTime":"2020-01-20T07:14:44.9656314Z","lastModifiedDateTime":"2020-01-20T07:14:44.9656314Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/301c65e4-9b51-40c3-acf0-04563e631651","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"4018ef20-b1d3-4063-ac4b-37e292b4df6a","startDateTime":"2020-01-20T07:14:38.5335344Z","lastModifiedDateTime":"2020-01-20T07:14:38.5335344Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/186a4144-8ac7-4e1d-b7d5-f0e43ba7bcac","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/xiaojianxu/providers/microsoft.compute/virtualmachines/test7","targetResourceName":"test7","targetResourceGroup":"xiaojianxu","targetResourceType":"virtualmachines","sourceCreatedId":"44788ae5-1289-4b4d-b7a5-528c0399899c","startDateTime":"2020-01-20T07:12:36.1424154Z","lastModifiedDateTime":"2020-01-20T07:12:36.1424154Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ff1fc043-6230-4a13-be38-0e0fd65c8123","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"c9e19254-47ff-4819-9c9f-6abd3da70463","startDateTime":"2020-01-20T07:12:21.7632527Z","lastModifiedDateTime":"2020-01-20T07:12:21.7632527Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/b646b578-6f25-4a3d-9740-90b9dc2a431f","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/xiaojianxu/providers/microsoft.compute/virtualmachines/test7","targetResourceName":"test7","targetResourceGroup":"xiaojianxu","targetResourceType":"virtualmachines","sourceCreatedId":"5ca5b794-418b-4c07-9817-ebd65dcca9d6","startDateTime":"2020-01-20T07:12:09.4891925Z","lastModifiedDateTime":"2020-01-20T07:12:09.4891925Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/ef028eee-a6fe-4f02-81c6-86a6c822ba98","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"278c5410-6017-4e98-960b-1d445e2959d7","startDateTime":"2020-01-20T07:12:02.6534794Z","lastModifiedDateTime":"2020-01-20T07:12:02.6534794Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/92e96cb6-bb45-45d0-886d-f101717f061c","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"8ab4bd16-750c-4e4e-bd31-7625b2d89402","startDateTime":"2020-01-20T07:11:50.0496379Z","lastModifiedDateTime":"2020-01-20T07:11:50.0496379Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/b9bd2a9d-ffd5-4c86-80b0-f7d7ea32b095","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"3ab8e392-d023-4ace-94e9-66fceff8d4b6","startDateTime":"2020-01-20T07:11:40.0508192Z","lastModifiedDateTime":"2020-01-20T07:11:40.0508192Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/cd6d247e-7c54-4d4c-b1ea-4e3b9ba53d9d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"},{"properties":{"essentials":{"alertRule":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest3/providers/microsoft.insights/activityLogAlerts/rule1","alertState":"New","severity":"Sev4","signalType":"Log","monitorCondition":"Fired","monitorService":"ActivityLog - Administrative","targetResource":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/fytest3/providers/microsoft.compute/virtualmachines/vm1","targetResourceName":"vm1","targetResourceGroup":"fytest3","targetResourceType":"virtualmachines","sourceCreatedId":"5e2788b5-f2c5-40a1-b137-c2b3f530d160","startDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedDateTime":"2020-01-20T07:09:21.1107075Z","lastModifiedUserName":"System","actionStatus":{"isSuppressed":false},"description":""}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d","type":"Microsoft.AlertsManagement/alerts","name":"rule1"}]}' - headers: - cache-control: - - no-store, no-cache - content-length: - - '33141' - content-security-policy: - - script-src 'self' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Jan 2020 07:58:04 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-resource-requests: - - '998' - x-xss-protection: - - 1; mode=block - status: - code: 200 - message: OK -version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml deleted file mode 100644 index 7c0e96c9600..00000000000 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_alert_rule.yaml +++ /dev/null @@ -1,111 +0,0 @@ -interactions: -- request: - body: '{"location": "global", "properties": {"groupShortName": "ag1", "enabled": - true, "emailReceivers": [], "smsReceivers": [], "webhookReceivers": [], "itsmReceivers": - [], "azureAppPushReceivers": [], "automationRunbookReceivers": [], "voiceReceivers": - [], "logicAppReceivers": [], "azureFunctionReceivers": [], "armRoleReceivers": - []}}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - monitor action-group create - Connection: - - keep-alive - Content-Length: - - '331' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - -g -n - User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-monitor/0.7.0 Azure-SDK-For-Python AZURECLI/2.0.81 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1?api-version=2019-06-01 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1","type":"Microsoft.Insights/ActionGroups","name":"ag1","location":"Global","kind":null,"tags":null,"properties":{"groupShortName":"ag1","enabled":true,"emailReceivers":[],"smsReceivers":[],"webhookReceivers":[],"itsmReceivers":[],"azureAppPushReceivers":[],"automationRunbookReceivers":[],"voiceReceivers":[],"logicAppReceivers":[],"azureFunctionReceivers":[],"armRoleReceivers":[]},"identity":null}' - headers: - cache-control: - - no-cache - content-length: - - '595' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 17 Feb 2020 08:21:50 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-IIS/10.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-writes: - - '1198' - status: - code: 201 - message: Created -- request: - body: 'b''{"properties": {"description": "Sample smart detector alert rule description", - "state": "Enabled", "severity": "Sev3", "frequency": "PT5M", "detector": {"id": - "asdf"}, "scope": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001"], - "actionGroups": {"groupIds": ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.insights/actionGroups/ag1"]}}}''' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement smart-detector-alert-rule create - Connection: - - keep-alive - Content-Length: - - '549' - Content-Type: - - application/json; charset=utf-8 - ParameterSetName: - - --resource-group --name --description --state --severity --frequency --detector - --scope --action-groups - User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 - accept-language: - - en-US - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_alert_rule_000001/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule?api-version=2019-06-01 - response: - body: - string: '{"error":{"code":"LocationRequired","message":"The location property - is required for this definition."}}' - headers: - cache-control: - - no-cache - content-length: - - '104' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 17 Feb 2020 08:21:54 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - x-content-type-options: - - nosniff - x-ms-failure-cause: - - gateway - status: - code: 400 - message: Bad Request -version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml deleted file mode 100644 index a6e2301e8b4..00000000000 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_smart_group.yaml +++ /dev/null @@ -1,53 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - alertsmanagement smart-group get-all - Connection: - - keep-alive - User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 - azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.0.81 - accept-language: - - en-US - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/smartGroups?api-version=2019-05-05-preview - response: - body: - string: '{"value":[]}' - headers: - cache-control: - - no-store, no-cache - content-length: - - '12' - content-security-policy: - - script-src 'self' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 17 Feb 2020 08:48:28 GMT - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' - x-xss-protection: - - 1; mode=block - status: - code: 200 - message: OK -version: 1 diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 5047f48e82d..2d802403850 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -15,31 +15,6 @@ class AlertsScenarioTest(ScenarioTest): - @unittest.skip('Smart detector not ready') - @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_alert_rule_') - def test_alertsmanagement_alert_rule(self, resource_group): - subscription_id = self.get_subscription_id() - - ag1_id = self.cmd('monitor action-group create -g {rg} -n ag1').get_output_in_json()['id'] - - self.kwargs.update({ - 'ag1_id': ag1_id, - 'scope': '/subscriptions/{}/resourceGroups/{}'.format(subscription_id, resource_group), - 'detector_id': 'asdf' - }) - - self.cmd('az alertsmanagement smart-detector-alert-rule create ' - '--resource-group {rg} ' - '--name "MyAlertRule" ' - '--description "Sample smart detector alert rule description" ' - '--state "Enabled" ' - '--severity "Sev3" ' - '--frequency "PT5M" ' - '--detector {detector_id} ' - '--scope {scope} ' - '--action-groups {ag1_id}', - checks=[]) - @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_action_rule_') def test_alertsmanagement_action_rule(self, resource_group): subs_id = self.get_subscription_id() @@ -97,42 +72,10 @@ def test_alertsmanagement_action_rule(self, resource_group): self.check('properties.status', 'Disabled') ]) - self.cmd('az alertsmanagement action-rule list') + self.cmd('az alertsmanagement action-rule list', + checks=self.check('[0].name', 'rule1')) - self.cmd('az alertsmanagement action-rule list -g {rg}') + self.cmd('az alertsmanagement action-rule list -g {rg}', + checks=self.check('[0].name', 'rule1')) self.cmd('az alertsmanagement action-rule delete -g {rg} -n rule1') - - @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_smart_group_') - def test_alertsmanagement_smart_group(self, resource_group): - self.cmd('az alertsmanagement smart-group get-all', - checks=[]) - # self.cmd('az alertsmanagement smart-group get-by-id ' - # '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', - # checks=[]) - # self.cmd('az alertsmanagement smart-group change-state ' - # '--smart-group-id "a808445e-bb38-4751-85c2-1b109ccc1059" ' - # '--new-state "Acknowledged"', - # checks=[]) - # self.cmd('az alertsmanagement smart-group get-history ' - # '--smart-group-id "603675da-9851-4b26-854a-49fc53d32715"', - # checks=[]) - - @ResourceGroupPreparer(name_prefix='cli_test_alertsmanagement_alert_') - def test_alertsmanagement_alert(self, resource_group): - subscription_id = self.get_subscription_id() - self.kwargs.update({ - 'alert_id': '1dde5384-3a40-4616-8a5d-be8e2453595d', - 'alert_full_id': '/subscriptions/{}/providers/Microsoft.AlertsManagement/alerts/1dde5384-3a40-4616-8a5d-be8e2453595d'.format(subscription_id) - }) - - self.cmd('az alertsmanagement alert get-history ' - '--alert-id {alert_id}', - checks=[self.check('properties.alertId', '{alert_id}')]) - self.cmd('az alertsmanagement alert get-by-id ' - '--alert-id {alert_id}', - checks=[self.check('id', '{alert_full_id}')]) - self.cmd('az alertsmanagement alert get-summary --groupby "severity,alertstate"', - checks=[]) - self.cmd('az alertsmanagement alert get-all', - checks=[]) From bc37331031ae0d9189b5cb162371400997fd4f80 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 10 Mar 2020 22:51:40 +0800 Subject: [PATCH 13/41] update help --- .../azext_alertsmanagement/_help.py | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index 64b68a34611..a386c426b1e 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -16,42 +16,39 @@ helps['alertsmanagement action-rule create'] = """ type: command - short-summary: Creates/Updates a specific action rule + short-summary: Create an action rule examples: - - name: Create an action rule. + - name: Create an action rule with suppression type text: |- - az alertsmanagement action-rule create --resource-group "alertscorrelationrg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --start-date 12/09/2018 --end-date 12/18/2018 --start-time 06:00:00 --end-time 14:00:00 + az alertsmanagement action-rule create --resource-group "rg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --start-date 12/09/2018 --end-date 12/18/2018 --start-time 06:00:00 --end-time 14:00:00 """ helps['alertsmanagement action-rule update'] = """ type: command - short-summary: Creates/Updates a specific action rule + short-summary: Update an action rule examples: - - name: Update an action rule. + - name: Update an action rule text: |- - az alertsmanagement action-rule update --resource-group "alertscorrelationrg" --name \\ - "WeeklySuppression" --status "Disabled" + az alertsmanagement action-rule update --resource-group "rg" --name "rule" --status "Disabled" """ helps['alertsmanagement action-rule delete'] = """ type: command - short-summary: Delete a given action rule + short-summary: Delete an action rule examples: - - name: DeleteActionRule + - name: Delete an action rule text: |- - az alertsmanagement action-rule delete --resource-group "alertscorrelationrg" --name \\ - "DailySuppression" + az alertsmanagement action-rule delete --resource-group "rg" --name "rule" """ helps['alertsmanagement action-rule show'] = """ type: command short-summary: Get a specific action rule examples: - - name: GetActionRuleById + - name: Get a specific action rule text: |- - az alertsmanagement action-rule show --resource-group "alertscorrelationrg" --name \\ - "DailySuppression" + az alertsmanagement action-rule show --resource-group "rg" --name "rule" """ helps['alertsmanagement action-rule list'] = """ @@ -63,5 +60,5 @@ az alertsmanagement action-rule list - name: List action rules of the resource group text: |- - az alertsmanagement action-rule list --resource-group "alertscorrelationrg" + az alertsmanagement action-rule list --resource-group "rg" """ From b937b4f12c5c4cac8cb12b099765d08f73b8aba5 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 10 Mar 2020 23:27:41 +0800 Subject: [PATCH 14/41] update name, rg --- .../azext_alertsmanagement/_params.py | 11 +++------ .../azext_alertsmanagement/custom.py | 24 +++++++++---------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 04dd3eb7c3a..86959ce9254 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -23,8 +23,7 @@ def load_arguments(self, _): id_part='name') with self.argument_context('alertsmanagement action-rule create') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', action_rule_name) + c.argument('action_rule_name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') @@ -46,22 +45,18 @@ def load_arguments(self, _): c.argument('end_time', help='End date for suppression') with self.argument_context('alertsmanagement action-rule update') as c: - c.argument('resource_group', resource_group_name_type) c.argument('action_rule_name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') with self.argument_context('alertsmanagement action-rule delete') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', action_rule_name) + c.argument('action_rule_name', action_rule_name) with self.argument_context('alertsmanagement action-rule show') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', action_rule_name) + c.argument('action_rule_name', action_rule_name) with self.argument_context('alertsmanagement action-rule list') as c: - c.argument('resource_group', resource_group_name_type) c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index d7967404230..960f079f0f7 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -130,8 +130,8 @@ def _transform_condition(condition): def create_alertsmanagement_action_rule(cmd, client, - resource_group, - name, + resource_group_name, + action_rule_name, location, rule_type, description=None, @@ -199,7 +199,7 @@ def create_alertsmanagement_action_rule(cmd, client, } body['properties'] = properties - return client.create_update(resource_group_name=resource_group, action_rule_name=name, action_rule=body) + return client.create_update(resource_group_name=resource_group_name, action_rule_name=action_rule_name, action_rule=body) def update_alertsmanagement_action_rule(instance, client, @@ -216,19 +216,19 @@ def update_alertsmanagement_action_rule(instance, client, def delete_alertsmanagement_action_rule(cmd, client, - resource_group, - name): - return client.delete(resource_group_name=resource_group, action_rule_name=name) + resource_group_name, + action_rule_name): + return client.delete(resource_group_name=resource_group_name, action_rule_name=action_rule_name) def get_alertsmanagement_action_rule(cmd, client, - resource_group, - name): - return client.get_by_name(resource_group_name=resource_group, action_rule_name=name) + resource_group_name, + action_rule_name): + return client.get_by_name(resource_group_name=resource_group_name, action_rule_name=action_rule_name) def list_alertsmanagement_action_rule(cmd, client, - resource_group=None, + resource_group_name=None, target_resource_group=None, target_resource_type=None, target_resource=None, @@ -239,8 +239,8 @@ def list_alertsmanagement_action_rule(cmd, client, alert_rule_id=None, action_group=None, name=None): - if resource_group is not None and target_resource_group is not None and target_resource_type is not None and target_resource is not None and severity is not None and monitor_service is not None and impacted_scope is not None and description is not None and alert_rule_id is not None and action_group is not None and name is not None: - return client.list_by_resource_group(resource_group_name=resource_group, target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) + if resource_group_name is not None and target_resource_group is not None and target_resource_type is not None and target_resource is not None and severity is not None and monitor_service is not None and impacted_scope is not None and description is not None and alert_rule_id is not None and action_group is not None and name is not None: + return client.list_by_resource_group(resource_group_name=resource_group_name, target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) return client.list_by_subscription(target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) From 052a855245ac2253985e882d6ce546b6cfd40dba Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 10 Mar 2020 23:30:07 +0800 Subject: [PATCH 15/41] update help --- src/alertsmanagement/azext_alertsmanagement/_params.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 86959ce9254..74d837575a7 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -62,8 +62,8 @@ def load_arguments(self, _): c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') - c.argument('impacted_scope', id_part=None, help='filter by impacted/target scope (provide comma separated list for multiple scopes). The value should be an well constructed ARM id of the scope.') - c.argument('description', id_part=None, help='filter by alert rule description') - c.argument('alert_rule_id', id_part=None, help='filter by alert rule id') - c.argument('action_group', id_part=None, help='filter by action group configured as part of action rule') - c.argument('name', id_part=None, help='filter by action rule name') + c.argument('impacted_scope', id_part=None, help='Filter by impacted/target scope (provide comma separated list for multiple scopes). The value should be an well constructed ARM id of the scope.') + c.argument('description', id_part=None, help='Filter by alert rule description') + c.argument('alert_rule_id', id_part=None, help='Filter by alert rule id') + c.argument('action_group', id_part=None, help='Filter by action group configured as part of action rule') + c.argument('name', id_part=None, help='Filter by action rule name') From 95b7898c58f4ea3c4d076252cfd1f5e88bc3d103 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 10 Mar 2020 23:39:34 +0800 Subject: [PATCH 16/41] list --- .../azext_alertsmanagement/custom.py | 27 +++++++++++-- .../test_alertsmanagement_action_rule.yaml | 38 +++++++++---------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 960f079f0f7..aad3ae2b3c4 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -239,9 +239,30 @@ def list_alertsmanagement_action_rule(cmd, client, alert_rule_id=None, action_group=None, name=None): - if resource_group_name is not None and target_resource_group is not None and target_resource_type is not None and target_resource is not None and severity is not None and monitor_service is not None and impacted_scope is not None and description is not None and alert_rule_id is not None and action_group is not None and name is not None: - return client.list_by_resource_group(resource_group_name=resource_group_name, target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) - return client.list_by_subscription(target_resource_group=target_resource_group, target_resource_type=target_resource_type, target_resource=target_resource, severity=severity, monitor_service=monitor_service, impacted_scope=impacted_scope, description=description, alert_rule_id=alert_rule_id, action_group=action_group, name=name) + if resource_group_name is not None: + return client.list_by_resource_group( + resource_group_name=resource_group_name, + target_resource_group=target_resource_group, + target_resource_type=target_resource_type, + target_resource=target_resource, + severity=severity, + monitor_service=monitor_service, + impacted_scope=impacted_scope, + description=description, + alert_rule_id=alert_rule_id, + action_group=action_group, + name=name) + return client.list_by_subscription( + target_resource_group=target_resource_group, + target_resource_type=target_resource_type, + target_resource=target_resource, + severity=severity, + monitor_service=monitor_service, + impacted_scope=impacted_scope, + description=description, + alert_rule_id=alert_rule_id, + action_group=action_group, + name=name) def create_alertsmanagement_smart_detector_alert_rule(cmd, client, diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index 629486e28bf..05f54e2e7a1 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -36,7 +36,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:20.7032795Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:24.0616721Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -47,7 +47,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 09:21:21 GMT + - Tue, 10 Mar 2020 15:37:24 GMT expires: - '-1' pragma: @@ -90,7 +90,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:20.7032795Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:24.0616721Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -101,7 +101,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 09:21:24 GMT + - Tue, 10 Mar 2020 15:37:28 GMT expires: - '-1' pragma: @@ -144,7 +144,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:20.7032795Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:24.0616721Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -155,7 +155,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 09:21:26 GMT + - Tue, 10 Mar 2020 15:37:33 GMT expires: - '-1' pragma: @@ -210,7 +210,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:29.0366385Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:35.3276562Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -221,7 +221,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 09:21:28 GMT + - Tue, 10 Mar 2020 15:37:35 GMT expires: - '-1' pragma: @@ -235,7 +235,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1199' + - '1198' x-xss-protection: - 1; mode=block status: @@ -262,19 +262,18 @@ interactions: response: body: string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:16:24.6085711Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:16:24.6085711Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:29.0366385Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:35.3276562Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' headers: cache-control: - no-store, no-cache content-length: - - '2198' + - '1173' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 09:21:31 GMT + - Tue, 10 Mar 2020 15:37:38 GMT expires: - '-1' pragma: @@ -313,23 +312,22 @@ interactions: accept-language: - en-US method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/actionRules?api-version=2019-05-05-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules?api-version=2019-05-05-preview response: body: string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:16:24.6085711Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:16:24.6085711Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T09:21:20.7032795Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T09:21:29.0366385Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:35.3276562Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' headers: cache-control: - no-store, no-cache content-length: - - '2198' + - '1173' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 09:21:33 GMT + - Tue, 10 Mar 2020 15:37:40 GMT expires: - '-1' pragma: @@ -343,7 +341,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' + - '997' x-xss-protection: - 1; mode=block status: @@ -384,7 +382,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 09:21:42 GMT + - Tue, 10 Mar 2020 15:37:46 GMT expires: - '-1' pragma: From b4d4c0a476154695d11134dba58323e2fdd79bdf Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 00:07:03 +0800 Subject: [PATCH 17/41] --status --- src/alertsmanagement/azext_alertsmanagement/_params.py | 6 +++--- src/alertsmanagement/azext_alertsmanagement/custom.py | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 74d837575a7..d41276d3713 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -5,7 +5,7 @@ # pylint: disable=line-too-long # pylint: disable=too-many-lines # pylint: disable=too-many-statements - +from azext_alertsmanagement.vendored_sdks.alertsmanagement.models import ActionRuleStatus from azure.cli.core.commands.parameters import ( tags_type, get_enum_type, @@ -26,8 +26,8 @@ def load_arguments(self, _): c.argument('action_rule_name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) - c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') - c.argument('rule_type', arg_type=get_enum_type(['Suppression', 'ActionGroup', 'Diagnostics']), help='Indicates type of action rule') + c.argument('status', arg_type=get_enum_type(ActionRuleStatus), id_part=None, help='Indicate if the given action rule is enabled or disabled. Default to enabled.') + c.argument('rule_type', arg_type=get_enum_type(['Suppression', 'ActionGroup', 'Diagnostics']), help='Indicate type of action rule') c.argument('description', help='Description of action rule') c.argument('scope_type', help='Type of target scope', arg_type=get_enum_type(['ResourceGroup', 'Resource'])) c.argument('scope', nargs='+', help='List of ARM IDs (space-delimited) of the given scope type which will be the target of the given action rule.') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index aad3ae2b3c4..8b80d829824 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -151,9 +151,7 @@ def create_alertsmanagement_action_rule(cmd, client, end_date=None, start_time=None, end_time=None): - body = {} - body['location'] = location # str - body['tags'] = tags # unknown-primary[object] + body = {'location': location, 'tags': tags} properties = {} if status is not None: From 4763e8b9b57bb67f2ed11143a89862dfc5af009f Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 18:43:40 +0800 Subject: [PATCH 18/41] recurrence_type --- src/alertsmanagement/azext_alertsmanagement/_params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index d41276d3713..a39418ddfdc 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -5,7 +5,7 @@ # pylint: disable=line-too-long # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from azext_alertsmanagement.vendored_sdks.alertsmanagement.models import ActionRuleStatus +from azext_alertsmanagement.vendored_sdks.alertsmanagement.models import ActionRuleStatus, SuppressionType from azure.cli.core.commands.parameters import ( tags_type, get_enum_type, @@ -38,7 +38,7 @@ def load_arguments(self, _): c.argument('alert_rule_id', nargs='+', help='Filter alerts by alert rule ID') c.argument('alert_description', nargs='+', help='Filter alerts by alert rule description') c.argument('alert_context', nargs='+', help='Filter alerts by alert context (payload)') - c.argument('recurrence_type', arg_type=get_enum_type(['Always', 'Once', 'Daily', 'Weekly', 'Monthly']), help='Specifies when the suppression should be applied') + c.argument('recurrence_type', arg_type=get_enum_type(SuppressionType), help='Specifies when the suppression should be applied') c.argument('start_date', help='Start date for suppression') c.argument('end_date', help='End date for suppression') c.argument('start_time', help='Start time for suppression') From 10424e0987969194f6efa7184bf1bb98031d07e4 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 21:29:47 +0800 Subject: [PATCH 19/41] alert_rule --- .../azext_alertsmanagement/_params.py | 2 +- .../azext_alertsmanagement/custom.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index a39418ddfdc..741994e5a74 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -35,7 +35,7 @@ def load_arguments(self, _): c.argument('monitor_service', nargs='+', help='Filter alerts by monitor service') c.argument('monitor_condition', nargs='+', help='Filter alerts by monitor condition') c.argument('target_resource_type', nargs='+', help='Filter alerts by target resource type') - c.argument('alert_rule_id', nargs='+', help='Filter alerts by alert rule ID') + c.argument('alert_rule', nargs='+', help='Filter alerts by alert rule name or ID') c.argument('alert_description', nargs='+', help='Filter alerts by alert rule description') c.argument('alert_context', nargs='+', help='Filter alerts by alert context (payload)') c.argument('recurrence_type', arg_type=get_enum_type(SuppressionType), help='Specifies when the suppression should be applied') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 8b80d829824..000f03937d6 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -129,6 +129,15 @@ def _transform_condition(condition): } +def _alert_rule_id(subscription, resource_group, alert): + if alert is None: + return None + from msrestazure.tools import resource_id, is_valid_resource_id + if not is_valid_resource_id(alert): + return resource_id(subscription=subscription, resource_group=resource_group, + namespace='microsoft.insights', type='alertrules', name=alert) + + def create_alertsmanagement_action_rule(cmd, client, resource_group_name, action_rule_name, @@ -141,7 +150,7 @@ def create_alertsmanagement_action_rule(cmd, client, monitor_service=None, monitor_condition=None, target_resource_type=None, - alert_rule_id=None, + alert_rule=None, alert_description=None, alert_context=None, tags=None, @@ -168,7 +177,8 @@ def create_alertsmanagement_action_rule(cmd, client, monitor_service = _transform_condition(monitor_service) monitor_condition = _transform_condition(monitor_condition) target_resource_type = _transform_condition(target_resource_type) - alert_rule_id = _transform_condition(alert_rule_id) + alert_rule = _alert_rule_id(client.config.subscription_id, resource_group_name, alert_rule) + alert_rule = _transform_condition(alert_rule) alert_description = _transform_condition(alert_description) alert_context = _transform_condition(alert_context) properties['conditions'] = {} @@ -180,8 +190,8 @@ def create_alertsmanagement_action_rule(cmd, client, properties['conditions']['monitorCondition'] = monitor_condition if target_resource_type is not None: properties['conditions']['targetResourceType'] = target_resource_type - if alert_rule_id is not None: - properties['conditions']['alertRuleId'] = alert_rule_id + if alert_rule is not None: + properties['conditions']['alertRuleId'] = alert_rule if alert_description is not None: properties['conditions']['description'] = alert_description if alert_context is not None: From fa8b90fdcaf228a5cbc18962498044792ea4c6f8 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 22:36:22 +0800 Subject: [PATCH 20/41] SuppressionSchedule --- .../azext_alertsmanagement/_help.py | 2 +- .../azext_alertsmanagement/_params.py | 8 ++++---- .../azext_alertsmanagement/custom.py | 16 ++++++++-------- .../latest/test_alertsmanagement_scenario.py | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index a386c426b1e..d79bd04aa38 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -20,7 +20,7 @@ examples: - name: Create an action rule with suppression type text: |- - az alertsmanagement action-rule create --resource-group "rg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --start-date 12/09/2018 --end-date 12/18/2018 --start-time 06:00:00 --end-time 14:00:00 + az alertsmanagement action-rule create --resource-group "rg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --suppression-start-date 12/09/2018 --suppression-end-date 12/18/2018 --suppression-start-time 06:00:00 --suppression-end-time 14:00:00 """ diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 741994e5a74..fc6e4db07cf 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -39,10 +39,10 @@ def load_arguments(self, _): c.argument('alert_description', nargs='+', help='Filter alerts by alert rule description') c.argument('alert_context', nargs='+', help='Filter alerts by alert context (payload)') c.argument('recurrence_type', arg_type=get_enum_type(SuppressionType), help='Specifies when the suppression should be applied') - c.argument('start_date', help='Start date for suppression') - c.argument('end_date', help='End date for suppression') - c.argument('start_time', help='Start time for suppression') - c.argument('end_time', help='End date for suppression') + c.argument('suppression_start_date', help='Start date for suppression. Format: MM/DD/YYYY') + c.argument('suppression_end_date', help='End date for suppression. Format: MM/DD/YYYY') + c.argument('suppression_start_time', help='Start time for suppression. Format: hh:mm:ss') + c.argument('suppression_end_time', help='End time for suppression. Format: hh:mm:ss') with self.argument_context('alertsmanagement action-rule update') as c: c.argument('action_rule_name', action_rule_name) diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 000f03937d6..a658c47c799 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -156,10 +156,10 @@ def create_alertsmanagement_action_rule(cmd, client, tags=None, status=None, recurrence_type=None, - start_date=None, - end_date=None, - start_time=None, - end_time=None): + suppression_start_date=None, + suppression_end_date=None, + suppression_start_time=None, + suppression_end_time=None): body = {'location': location, 'tags': tags} properties = {} @@ -199,10 +199,10 @@ def create_alertsmanagement_action_rule(cmd, client, properties['suppressionConfig'] = { 'recurrenceType': recurrence_type, 'schedule': { - 'startDate': start_date, - 'endDate': end_date, - 'startTime': start_time, - 'endTime': end_time + 'startDate': suppression_start_date, + 'endDate': suppression_end_date, + 'startTime': suppression_start_time, + 'endTime': suppression_end_time } } body['properties'] = properties diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 2d802403850..6aadd41139b 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -35,10 +35,10 @@ def test_alertsmanagement_action_rule(self, resource_group): '--monitor-condition Equals Fired ' '--target-resource-type NotEquals Microsoft.Compute/VirtualMachines ' '--recurrence-type Daily ' - '--start-date 12/09/2018 ' - '--end-date 12/18/2018 ' - '--start-time 06:00:00 ' - '--end-time 14:00:00', + '--suppression-start-date 12/09/2018 ' + '--suppression-end-date 12/18/2018 ' + '--suppression-start-time 06:00:00 ' + '--suppression-end-time 14:00:00', checks=[]) self.cmd('az alertsmanagement action-rule show ' From 6d384ca129aa9cdbce15f26c4f3fcdd6154b13b5 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 22:39:58 +0800 Subject: [PATCH 21/41] remove rubbish code --- .../azext_alertsmanagement/_validators.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_validators.py b/src/alertsmanagement/azext_alertsmanagement/_validators.py index 01e8fe71d5a..34913fb394d 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_validators.py +++ b/src/alertsmanagement/azext_alertsmanagement/_validators.py @@ -2,17 +2,3 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - - -def example_name_or_id_validator(cmd, namespace): - from azure.cli.core.commands.client_factory import get_subscription_id - from msrestazure.tools import is_valid_resource_id, resource_id - if namespace.storage_account: - if not is_valid_resource_id(namespace.RESOURCE): - namespace.storage_account = resource_id( - subscription=get_subscription_id(cmd.cli_ctx), - resource_group=namespace.resource_group_name, - namespace='Microsoft.Storage', - type='storageAccounts', - name=namespace.storage_account - ) From b4ff21e4257a1575bef8e47973cc1cc213a01b6a Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 22:44:37 +0800 Subject: [PATCH 22/41] update setup.py --- src/alertsmanagement/setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/alertsmanagement/setup.py b/src/alertsmanagement/setup.py index a675fc1673f..89b4172aded 100644 --- a/src/alertsmanagement/setup.py +++ b/src/alertsmanagement/setup.py @@ -25,12 +25,11 @@ 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License', ] From 204fed82a5e6b5626344dd8de84222ed037d9da6 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 23:11:51 +0800 Subject: [PATCH 23/41] refactor --- .../azext_alertsmanagement/custom.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index a658c47c799..6c79d909ca0 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -46,7 +46,13 @@ def get_all_alertsmanagement_alert(cmd, client, select=None, time_range=None, custom_time_range=None): - return client.get_all(target_resource=target_resource, target_resource_type=target_resource_type, target_resource_group=target_resource_group, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, alert_rule=alert_rule, smart_group_id=smart_group_id, include_context=include_context, include_egress_config=include_egress_config, page_count=page_count, sort_by=sort_by, sort_order=sort_order, select=select, time_range=time_range, custom_time_range=custom_time_range) + return client.get_all(target_resource=target_resource, target_resource_type=target_resource_type, + target_resource_group=target_resource_group, monitor_service=monitor_service, + monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, + alert_rule=alert_rule, smart_group_id=smart_group_id, include_context=include_context, + include_egress_config=include_egress_config, page_count=page_count, sort_by=sort_by, + sort_order=sort_order, select=select, time_range=time_range, + custom_time_range=custom_time_range) def get_by_id_alertsmanagement_alert(cmd, client, @@ -72,7 +78,11 @@ def get_summary_alertsmanagement_alert(cmd, client, alert_rule=None, time_range=None, custom_time_range=None): - return client.get_summary(groupby=groupby, include_smart_groups_count=include_smart_groups_count, target_resource=target_resource, target_resource_type=target_resource_type, target_resource_group=target_resource_group, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, alert_rule=alert_rule, time_range=time_range, custom_time_range=custom_time_range) + return client.get_summary(groupby=groupby, include_smart_groups_count=include_smart_groups_count, + target_resource=target_resource, target_resource_type=target_resource_type, + target_resource_group=target_resource_group, monitor_service=monitor_service, + monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, + alert_rule=alert_rule, time_range=time_range, custom_time_range=custom_time_range) def change_state_alertsmanagement_smart_group(cmd, client, @@ -93,7 +103,10 @@ def get_all_alertsmanagement_smart_group(cmd, client, page_count=None, sort_by=None, sort_order=None): - return client.get_all(target_resource=target_resource, target_resource_group=target_resource_group, target_resource_type=target_resource_type, monitor_service=monitor_service, monitor_condition=monitor_condition, severity=severity, smart_group_state=smart_group_state, time_range=time_range, page_count=page_count, sort_by=sort_by, sort_order=sort_order) + return client.get_all(target_resource=target_resource, target_resource_group=target_resource_group, + target_resource_type=target_resource_type, monitor_service=monitor_service, + monitor_condition=monitor_condition, severity=severity, smart_group_state=smart_group_state, + time_range=time_range, page_count=page_count, sort_by=sort_by, sort_order=sort_order) def get_by_id_alertsmanagement_smart_group(cmd, client, @@ -207,7 +220,8 @@ def create_alertsmanagement_action_rule(cmd, client, } body['properties'] = properties - return client.create_update(resource_group_name=resource_group_name, action_rule_name=action_rule_name, action_rule=body) + return client.create_update(resource_group_name=resource_group_name, action_rule_name=action_rule_name, + action_rule=body) def update_alertsmanagement_action_rule(instance, client, From ffa3e579550a85a2bafe1cfa731307ae8093737b Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Wed, 11 Mar 2020 23:23:32 +0800 Subject: [PATCH 24/41] remove trash --- .../azext_alertsmanagement/custom.py | 186 ------------------ 1 file changed, 186 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 6c79d909ca0..aed48677772 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -13,112 +13,6 @@ from knack.util import CLIError -def list_alertsmanagement_operation(cmd, client): - return client.list() - - -def change_state_alertsmanagement_alert(cmd, client, - alert_id, - new_state=None): - return client.change_state(alert_id=alert_id, new_state=new_state) - - -def meta_data_alertsmanagement_alert(cmd, client, - identifier=None): - return client.meta_data(identifier=identifier) - - -def get_all_alertsmanagement_alert(cmd, client, - target_resource=None, - target_resource_type=None, - target_resource_group=None, - monitor_service=None, - monitor_condition=None, - severity=None, - alert_state=None, - alert_rule=None, - smart_group_id=None, - include_context=None, - include_egress_config=None, - page_count=None, - sort_by=None, - sort_order=None, - select=None, - time_range=None, - custom_time_range=None): - return client.get_all(target_resource=target_resource, target_resource_type=target_resource_type, - target_resource_group=target_resource_group, monitor_service=monitor_service, - monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, - alert_rule=alert_rule, smart_group_id=smart_group_id, include_context=include_context, - include_egress_config=include_egress_config, page_count=page_count, sort_by=sort_by, - sort_order=sort_order, select=select, time_range=time_range, - custom_time_range=custom_time_range) - - -def get_by_id_alertsmanagement_alert(cmd, client, - alert_id): - return client.get_by_id(alert_id=alert_id) - - -def get_history_alertsmanagement_alert(cmd, client, - alert_id): - return client.get_history(alert_id=alert_id) - - -def get_summary_alertsmanagement_alert(cmd, client, - groupby, - include_smart_groups_count=None, - target_resource=None, - target_resource_type=None, - target_resource_group=None, - monitor_service=None, - monitor_condition=None, - severity=None, - alert_state=None, - alert_rule=None, - time_range=None, - custom_time_range=None): - return client.get_summary(groupby=groupby, include_smart_groups_count=include_smart_groups_count, - target_resource=target_resource, target_resource_type=target_resource_type, - target_resource_group=target_resource_group, monitor_service=monitor_service, - monitor_condition=monitor_condition, severity=severity, alert_state=alert_state, - alert_rule=alert_rule, time_range=time_range, custom_time_range=custom_time_range) - - -def change_state_alertsmanagement_smart_group(cmd, client, - smart_group_id, - new_state=None): - return client.change_state(smart_group_id=smart_group_id, new_state=new_state) - - -def get_all_alertsmanagement_smart_group(cmd, client, - target_resource=None, - target_resource_group=None, - target_resource_type=None, - monitor_service=None, - monitor_condition=None, - severity=None, - smart_group_state=None, - time_range=None, - page_count=None, - sort_by=None, - sort_order=None): - return client.get_all(target_resource=target_resource, target_resource_group=target_resource_group, - target_resource_type=target_resource_type, monitor_service=monitor_service, - monitor_condition=monitor_condition, severity=severity, smart_group_state=smart_group_state, - time_range=time_range, page_count=page_count, sort_by=sort_by, sort_order=sort_order) - - -def get_by_id_alertsmanagement_smart_group(cmd, client, - smart_group_id): - return client.get_by_id(smart_group_id=smart_group_id) - - -def get_history_alertsmanagement_smart_group(cmd, client, - smart_group_id): - return client.get_history(smart_group_id=smart_group_id) - - def _transform_condition(condition): """ ['Equals', 'Sev0', 'Sev2'] -> @@ -285,83 +179,3 @@ def list_alertsmanagement_action_rule(cmd, client, alert_rule_id=alert_rule_id, action_group=action_group, name=name) - - -def create_alertsmanagement_smart_detector_alert_rule(cmd, client, - resource_group, - name, - location=None, - tags=None, - description=None, - state=None, - severity=None, - frequency=None, - action_groups=None, - throttling=None, - detector=None, - scope=None): - body = {} - body['location'] = location # str - body['tags'] = tags # unknown-primary[object] - body['description'] = description # str - body['state'] = state # str - body['severity'] = severity # str - body['frequency'] = frequency # unknown-primary[timeSpan] - # body['action_groups'] = json.loads(action_groups) if isinstance(action_groups, str) else action_groups - body['action_groups'] = {'groupIds': action_groups} - body['throttling'] = json.loads(throttling) if isinstance(throttling, str) else throttling - body['detector'] = {'id': detector} - body['scope'] = scope - return client.create_or_update(resource_group_name=resource_group, alert_rule_name=name, parameters=body) - - -def update_alertsmanagement_smart_detector_alert_rule(cmd, client, - resource_group, - name, - location=None, - tags=None, - description=None, - state=None, - severity=None, - frequency=None, - action_groups=None, - throttling=None): - body = {} - if location is not None: - body['location'] = location # str - if tags is not None: - body['tags'] = tags # unknown-primary[object] - if description is not None: - body['description'] = description # str - if state is not None: - body['state'] = state # str - if severity is not None: - body['severity'] = severity # str - if frequency is not None: - body['frequency'] = frequency # unknown-primary[timeSpan] - if action_groups is not None: - body['action_groups'] = json.loads(action_groups) if isinstance(action_groups, str) else action_groups - if throttling is not None: - body['throttling'] = json.loads(throttling) if isinstance(throttling, str) else throttling - return client.create_or_update(resource_group_name=resource_group, alert_rule_name=name, parameters=body) - - -def delete_alertsmanagement_smart_detector_alert_rule(cmd, client, - resource_group, - name): - return client.delete(resource_group_name=resource_group, alert_rule_name=name) - - -def get_alertsmanagement_smart_detector_alert_rule(cmd, client, - resource_group, - name, - expand_detector=None): - return client.get(resource_group_name=resource_group, alert_rule_name=name, expand_detector=expand_detector) - - -def list_alertsmanagement_smart_detector_alert_rule(cmd, client, - resource_group=None, - expand_detector=None): - if resource_group is not None and expand_detector is not None: - return client.list_by_resource_group(resource_group_name=resource_group, expand_detector=expand_detector) - return client.list(expand_detector=expand_detector) From 9f36459d731909ca0aa396fd8036455c8a50b8eb Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 12 Mar 2020 01:00:21 +0800 Subject: [PATCH 25/41] Rename alertsmanagement to monitor --- .../azext_alertsmanagement/_help.py | 26 +++++++++---------- .../azext_alertsmanagement/_params.py | 10 +++---- .../azext_alertsmanagement/commands.py | 2 +- .../latest/test_alertsmanagement_scenario.py | 12 ++++----- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index d79bd04aa38..5409fa545e4 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -9,56 +9,56 @@ from knack.help_files import helps # pylint: disable=unused-import -helps['alertsmanagement action-rule'] = """ +helps['monitor action-rule'] = """ type: group - short-summary: Commands to manage alertsmanagement action rule. + short-summary: Commands to manage action rule. """ -helps['alertsmanagement action-rule create'] = """ +helps['monitor action-rule create'] = """ type: command short-summary: Create an action rule examples: - name: Create an action rule with suppression type text: |- - az alertsmanagement action-rule create --resource-group "rg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --suppression-start-date 12/09/2018 --suppression-end-date 12/18/2018 --suppression-start-time 06:00:00 --suppression-end-time 14:00:00 + az monitor action-rule create --resource-group "rg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --suppression-start-date 12/09/2018 --suppression-end-date 12/18/2018 --suppression-start-time 06:00:00 --suppression-end-time 14:00:00 """ -helps['alertsmanagement action-rule update'] = """ +helps['monitor action-rule update'] = """ type: command short-summary: Update an action rule examples: - name: Update an action rule text: |- - az alertsmanagement action-rule update --resource-group "rg" --name "rule" --status "Disabled" + az monitor action-rule update --resource-group "rg" --name "rule" --status "Disabled" """ -helps['alertsmanagement action-rule delete'] = """ +helps['monitor action-rule delete'] = """ type: command short-summary: Delete an action rule examples: - name: Delete an action rule text: |- - az alertsmanagement action-rule delete --resource-group "rg" --name "rule" + az monitor action-rule delete --resource-group "rg" --name "rule" """ -helps['alertsmanagement action-rule show'] = """ +helps['monitor action-rule show'] = """ type: command short-summary: Get a specific action rule examples: - name: Get a specific action rule text: |- - az alertsmanagement action-rule show --resource-group "rg" --name "rule" + az monitor action-rule show --resource-group "rg" --name "rule" """ -helps['alertsmanagement action-rule list'] = """ +helps['monitor action-rule list'] = """ type: command short-summary: List all action rules of the subscription, created in given resource group and given input filters examples: - name: List action rules of the subscription text: |- - az alertsmanagement action-rule list + az monitor action-rule list - name: List action rules of the resource group text: |- - az alertsmanagement action-rule list --resource-group "rg" + az monitor action-rule list --resource-group "rg" """ diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index fc6e4db07cf..09777457666 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -22,7 +22,7 @@ def load_arguments(self, _): action_rule_name = CLIArgumentType(overrides=name_arg_type, help='Name of action rule.', id_part='name') - with self.argument_context('alertsmanagement action-rule create') as c: + with self.argument_context('monitor action-rule create') as c: c.argument('action_rule_name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) @@ -44,19 +44,19 @@ def load_arguments(self, _): c.argument('suppression_start_time', help='Start time for suppression. Format: hh:mm:ss') c.argument('suppression_end_time', help='End time for suppression. Format: hh:mm:ss') - with self.argument_context('alertsmanagement action-rule update') as c: + with self.argument_context('monitor action-rule update') as c: c.argument('action_rule_name', action_rule_name) c.argument('location', arg_type=get_location_type(self.cli_ctx)) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(['Enabled', 'Disabled']), id_part=None, help='Indicates if the given action rule is enabled or disabled') - with self.argument_context('alertsmanagement action-rule delete') as c: + with self.argument_context('monitor action-rule delete') as c: c.argument('action_rule_name', action_rule_name) - with self.argument_context('alertsmanagement action-rule show') as c: + with self.argument_context('monitor action-rule show') as c: c.argument('action_rule_name', action_rule_name) - with self.argument_context('alertsmanagement action-rule list') as c: + with self.argument_context('monitor action-rule list') as c: c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') diff --git a/src/alertsmanagement/azext_alertsmanagement/commands.py b/src/alertsmanagement/azext_alertsmanagement/commands.py index 045e39a8f0f..40849689380 100644 --- a/src/alertsmanagement/azext_alertsmanagement/commands.py +++ b/src/alertsmanagement/azext_alertsmanagement/commands.py @@ -16,7 +16,7 @@ def load_command_table(self, _): alertsmanagement_action_rules = CliCommandType( operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._action_rules_operations#ActionRulesOperations.{}', client_factory=cf_action_rules) - with self.command_group('alertsmanagement action-rule', alertsmanagement_action_rules, client_factory=cf_action_rules) as g: + with self.command_group('monitor action-rule', alertsmanagement_action_rules, client_factory=cf_action_rules) as g: g.custom_command('create', 'create_alertsmanagement_action_rule') g.generic_update_command('update', custom_func_name='update_alertsmanagement_action_rule', setter_arg_name='action_rule', getter_name='get_by_name', diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 6aadd41139b..7fdc86c915d 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -22,7 +22,7 @@ def test_alertsmanagement_action_rule(self, resource_group): self.kwargs.update({ 'rg_id': rg_id }) - self.cmd('az alertsmanagement action-rule create ' + self.cmd('az monitor action-rule create ' '--resource-group {rg} ' '--name rule1 ' '--location Global ' @@ -41,7 +41,7 @@ def test_alertsmanagement_action_rule(self, resource_group): '--suppression-end-time 14:00:00', checks=[]) - self.cmd('az alertsmanagement action-rule show ' + self.cmd('az monitor action-rule show ' '--resource-group {rg} ' '--name "rule1"', checks=[ @@ -64,7 +64,7 @@ def test_alertsmanagement_action_rule(self, resource_group): self.check('properties.suppressionConfig.schedule.startTime', '06:00:00'), ]) - self.cmd('az alertsmanagement action-rule update ' + self.cmd('az monitor action-rule update ' '--resource-group {rg} ' '--name "rule1" ' '--status Disabled', @@ -72,10 +72,10 @@ def test_alertsmanagement_action_rule(self, resource_group): self.check('properties.status', 'Disabled') ]) - self.cmd('az alertsmanagement action-rule list', + self.cmd('az monitor action-rule list', checks=self.check('[0].name', 'rule1')) - self.cmd('az alertsmanagement action-rule list -g {rg}', + self.cmd('az monitor action-rule list -g {rg}', checks=self.check('[0].name', 'rule1')) - self.cmd('az alertsmanagement action-rule delete -g {rg} -n rule1') + self.cmd('az monitor action-rule delete -g {rg} -n rule1') From 00f11d179a6973048229243dd5e125493144fd9c Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 12 Mar 2020 13:39:27 +0800 Subject: [PATCH 26/41] style --- src/alertsmanagement/azext_alertsmanagement/_params.py | 1 - src/alertsmanagement/azext_alertsmanagement/custom.py | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 09777457666..78591de2f96 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -9,7 +9,6 @@ from azure.cli.core.commands.parameters import ( tags_type, get_enum_type, - resource_group_name_type, get_location_type ) from knack.arguments import CLIArgumentType diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index aed48677772..6088d5033cb 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -8,7 +8,6 @@ # pylint: disable=too-many-locals # pylint: disable=unused-argument # pylint: disable=too-many-boolean-expressions -import json from knack.util import CLIError @@ -37,12 +36,20 @@ def _transform_condition(condition): def _alert_rule_id(subscription, resource_group, alert): + """ + Transform alert rule name or ID to alert rule ID + :param subscription: + :param resource_group: + :param alert: + :return: alert rule ID + """ if alert is None: return None from msrestazure.tools import resource_id, is_valid_resource_id if not is_valid_resource_id(alert): return resource_id(subscription=subscription, resource_group=resource_group, namespace='microsoft.insights', type='alertrules', name=alert) + return alert def create_alertsmanagement_action_rule(cmd, client, From 8b3d1491c622f1700ce6cbffe9ff7029f6a7368e Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Fri, 13 Mar 2020 15:00:36 +0800 Subject: [PATCH 27/41] recurrence pattern; add 3 examples --- .../azext_alertsmanagement/_help.py | 11 +++- .../azext_alertsmanagement/_params.py | 3 +- .../azext_alertsmanagement/custom.py | 16 +++-- .../test_alertsmanagement_action_rule.yaml | 61 ++++++++++--------- .../latest/test_alertsmanagement_scenario.py | 2 +- 5 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index 5409fa545e4..233e3879fd4 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -18,10 +18,15 @@ type: command short-summary: Create an action rule examples: - - name: Create an action rule with suppression type + - name: Create an action rule to suppress notifications for all Sev4 alerts on all VMs within the subscription every weekend text: |- - az monitor action-rule create --resource-group "rg" --name "rule" --location "Global" --status "Enabled" --rule-type Suppression --severity Equals Sev0 Sev2 --recurrence-type Daily --suppression-start-date 12/09/2018 --suppression-end-date 12/18/2018 --suppression-start-time 06:00:00 --suppression-end-time 14:00:00 - + az monitor action-rule create --resource-group rg --name rule --location Global --status Enabled --rule-type Suppression --severity Equals Sev4 --target-resource-type Equals Microsoft.Compute/VirtualMachines --suppression-recurrence-type Weekly --suppression-recurrence 0 6 --suppression-start-date 12/09/2018 --suppression-end-date 12/18/2018 --suppression-start-time 06:00:00 --suppression-end-time 14:00:00 + - name: Create an action rule to suppress notifications for all log alerts generated for Computer-01 in subscription indefinitely as it's going through maintenance + text: |- + az monitor action-rule create --resource-group rg --name rule --location Global --status Enabled --rule-type Suppression --suppression-recurrence-type Always --alert-context Contains Computer-01 --monitor-service Equals "Log Analytics" + - name: Create an action rule to suppress notifications in a resource group + text: |- + az monitor action-rule create --resource-group rg --name rule --location Global --status Enabled --rule-type Suppression --scope-type ResourceGroup --scope /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/rg --suppression-recurrence-type Always --alert-context Contains Computer-01 --monitor-service Equals "Log Analytics" """ helps['monitor action-rule update'] = """ diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 78591de2f96..7ea8037aed7 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -37,11 +37,12 @@ def load_arguments(self, _): c.argument('alert_rule', nargs='+', help='Filter alerts by alert rule name or ID') c.argument('alert_description', nargs='+', help='Filter alerts by alert rule description') c.argument('alert_context', nargs='+', help='Filter alerts by alert context (payload)') - c.argument('recurrence_type', arg_type=get_enum_type(SuppressionType), help='Specifies when the suppression should be applied') + c.argument('suppression_recurrence_type', arg_type=get_enum_type(SuppressionType), help='Specifies when the suppression should be applied') c.argument('suppression_start_date', help='Start date for suppression. Format: MM/DD/YYYY') c.argument('suppression_end_date', help='End date for suppression. Format: MM/DD/YYYY') c.argument('suppression_start_time', help='Start time for suppression. Format: hh:mm:ss') c.argument('suppression_end_time', help='End time for suppression. Format: hh:mm:ss') + c.argument('suppression_recurrence', nargs='+', help='List of recurrence pattern values, delimited by space. If recurrence type is weekly, 0 stands for Sunday, 1 stands for Monday, and so on.') with self.argument_context('monitor action-rule update') as c: c.argument('action_rule_name', action_rule_name) diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index 6088d5033cb..e2600186a70 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -69,11 +69,12 @@ def create_alertsmanagement_action_rule(cmd, client, alert_context=None, tags=None, status=None, - recurrence_type=None, + suppression_recurrence_type=None, suppression_start_date=None, suppression_end_date=None, suppression_start_time=None, - suppression_end_time=None): + suppression_end_time=None, + suppression_recurrence=None): body = {'location': location, 'tags': tags} properties = {} @@ -111,14 +112,17 @@ def create_alertsmanagement_action_rule(cmd, client, if alert_context is not None: properties['conditions']['alertContext'] = alert_context properties['suppressionConfig'] = { - 'recurrenceType': recurrence_type, - 'schedule': { + 'recurrenceType': suppression_recurrence_type + } + if suppression_recurrence_type not in ['Always', 'Once']: + properties['suppressionConfig']['schedule'] = { 'startDate': suppression_start_date, 'endDate': suppression_end_date, 'startTime': suppression_start_time, - 'endTime': suppression_end_time + 'endTime': suppression_end_time, + 'recurrenceValues': suppression_recurrence } - } + body['properties'] = properties return client.create_update(resource_group_name=resource_group_name, action_rule_name=action_rule_name, diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index 05f54e2e7a1..d0694cd1f84 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -15,7 +15,7 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule create + - monitor action-rule create Connection: - keep-alive Content-Length: @@ -24,8 +24,8 @@ interactions: - application/json; charset=utf-8 ParameterSetName: - --resource-group --name --location --status --rule-type --scope-type --scope - --severity --monitor-service --monitor-condition --target-resource-type --recurrence-type - --start-date --end-date --start-time --end-time + --severity --monitor-service --monitor-condition --target-resource-type --suppression-recurrence-type + --suppression-start-date --suppression-end-date --suppression-start-time --suppression-end-time User-Agent: - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 @@ -36,7 +36,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:24.0616721Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:46.7753339Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -47,7 +47,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 15:37:24 GMT + - Fri, 13 Mar 2020 06:56:47 GMT expires: - '-1' pragma: @@ -61,7 +61,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1199' + - '1197' x-xss-protection: - 1; mode=block status: @@ -75,7 +75,7 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule show + - monitor action-rule show Connection: - keep-alive ParameterSetName: @@ -90,7 +90,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:24.0616721Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:46.7753339Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -101,7 +101,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 15:37:28 GMT + - Fri, 13 Mar 2020 06:56:50 GMT expires: - '-1' pragma: @@ -129,7 +129,7 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule update + - monitor action-rule update Connection: - keep-alive ParameterSetName: @@ -144,7 +144,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:24.0616721Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:46.7753339Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -155,7 +155,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 15:37:33 GMT + - Fri, 13 Mar 2020 06:56:53 GMT expires: - '-1' pragma: @@ -169,7 +169,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '998' + - '999' x-xss-protection: - 1; mode=block status: @@ -191,7 +191,7 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule update + - monitor action-rule update Connection: - keep-alive Content-Length: @@ -210,7 +210,7 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:35.3276562Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:55.3373756Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache @@ -221,7 +221,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 15:37:35 GMT + - Fri, 13 Mar 2020 06:56:55 GMT expires: - '-1' pragma: @@ -235,7 +235,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1198' + - '1199' x-xss-protection: - 1; mode=block status: @@ -249,7 +249,7 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule list + - monitor action-rule list Connection: - keep-alive User-Agent: @@ -261,19 +261,22 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/actionRules?api-version=2019-05-05-preview response: body: - string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:35.3276562Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + string: '{"value":[{"properties":{"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"03/13/2020","endDate":"03/14/2020","startTime":"05:54:56","endTime":"05:54:56","recurrenceValues":[0,1,2,4,5,6]}},"description":"","createdAt":"2020-03-13T06:21:58.0932972Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:21:58.0932972Z","lastModifiedBy":"fey@microsoft.com"},"location":"global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:55.3373756Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00","recurrenceValues":[0,6]}},"createdAt":"2020-03-13T06:29:08.1868672Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:29:08.1868672Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule2","type":"Microsoft.AlertsManagement/actionRules","name":"rule2"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev4"]},"targetResourceType":{"operator":"Equals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00","recurrenceValues":[0,6]}},"createdAt":"2020-03-13T06:34:23.1716761Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:34:23.1716761Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule3","type":"Microsoft.AlertsManagement/actionRules","name":"rule3"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log + Analytics"]},"alertContext":{"operator":"Contains","values":["Computer-01"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Always"},"description":"","createdAt":"2020-03-13T06:49:24.1672254Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:49:24.1672254Z","lastModifiedBy":"fey@microsoft.com"},"location":"global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule4","type":"Microsoft.AlertsManagement/actionRules","name":"rule4"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log + Analytics"]},"alertContext":{"operator":"Contains","values":["Computer-01"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Always"},"createdAt":"2020-03-13T06:51:55.0195146Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:51:55.0195146Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule5","type":"Microsoft.AlertsManagement/actionRules","name":"rule5"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log + Analytics"]},"alertContext":{"operator":"Contains","values":["Computer-01"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg"]},"suppressionConfig":{"recurrenceType":"Always"},"createdAt":"2020-03-13T06:55:49.5585692Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:55:49.5585692Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule6","type":"Microsoft.AlertsManagement/actionRules","name":"rule6"}]}' headers: cache-control: - no-store, no-cache content-length: - - '1173' + - '5294' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 15:37:38 GMT + - Fri, 13 Mar 2020 06:56:57 GMT expires: - '-1' pragma: @@ -287,7 +290,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' + - '998' x-xss-protection: - 1; mode=block status: @@ -301,7 +304,7 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule list + - monitor action-rule list Connection: - keep-alive ParameterSetName: @@ -316,7 +319,7 @@ interactions: response: body: string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-10T15:37:24.0616721Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-10T15:37:35.3276562Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:55.3373756Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' headers: cache-control: - no-store, no-cache @@ -327,7 +330,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 15:37:40 GMT + - Fri, 13 Mar 2020 06:56:59 GMT expires: - '-1' pragma: @@ -341,7 +344,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '997' + - '999' x-xss-protection: - 1; mode=block status: @@ -355,7 +358,7 @@ interactions: Accept-Encoding: - gzip, deflate CommandName: - - alertsmanagement action-rule delete + - monitor action-rule delete Connection: - keep-alive Content-Length: @@ -382,7 +385,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 10 Mar 2020 15:37:46 GMT + - Fri, 13 Mar 2020 06:57:06 GMT expires: - '-1' pragma: diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py index 7fdc86c915d..f34111b9151 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/test_alertsmanagement_scenario.py @@ -34,7 +34,7 @@ def test_alertsmanagement_action_rule(self, resource_group): '--monitor-service Equals Platform "Application Insights" ' '--monitor-condition Equals Fired ' '--target-resource-type NotEquals Microsoft.Compute/VirtualMachines ' - '--recurrence-type Daily ' + '--suppression-recurrence-type Daily ' '--suppression-start-date 12/09/2018 ' '--suppression-end-date 12/18/2018 ' '--suppression-start-time 06:00:00 ' From 8fc8e1211427e8a8ed39f140d2210c94a25ec50c Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Fri, 13 Mar 2020 15:51:58 +0800 Subject: [PATCH 28/41] readme --- src/alertsmanagement/README.md | 46 +++++++++++++++++++ src/alertsmanagement/README.rst | 5 -- .../azext_alertsmanagement/_help.py | 12 ++--- src/alertsmanagement/setup.py | 2 +- 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 src/alertsmanagement/README.md delete mode 100644 src/alertsmanagement/README.rst diff --git a/src/alertsmanagement/README.md b/src/alertsmanagement/README.md new file mode 100644 index 00000000000..55e13f6a2b8 --- /dev/null +++ b/src/alertsmanagement/README.md @@ -0,0 +1,46 @@ +# Azure CLI alertsmanagement Extension + +This extension can manage alert related resources. Currently, it supports +action rule management. + +### How to use +Install this extension using the below CLI command +``` +az extension add --name alertsmanagement +``` + +### Action rule +Action rule documentation: https://docs.microsoft.com/en-us/azure/azure-monitor/platform/alerts-action-rules. + +Create an action rule to suppress notifications for all Sev4 alerts on all VMs within the subscription every weekend. +``` +az monitor action-rule create --resource-group rg --name rule --location Global --status Enabled --rule-type Suppression --severity Equals Sev4 --target-resource-type Equals Microsoft.Compute/VirtualMachines --suppression-recurrence-type Weekly --suppression-recurrence 0 6 --suppression-start-date 12/09/2018 --suppression-end-date 12/18/2018 --suppression-start-time 06:00:00 --suppression-end-time 14:00:00 +``` +Create an action rule to suppress notifications for all log alerts generated for Computer-01 in subscription indefinitely as it's going through maintenance. +``` +az monitor action-rule create --resource-group rg --name rule --location Global --status Enabled --rule-type Suppression --suppression-recurrence-type Always --alert-context Contains Computer-01 --monitor-service Equals "Log Analytics" +``` +Create an action rule to suppress notifications in a resource group +``` +az monitor action-rule create --resource-group rg --name rule --location Global --status Enabled --rule-type Suppression --scope-type ResourceGroup --scope /subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/rg --suppression-recurrence-type Always --alert-context Contains Computer-01 --monitor-service Equals "Log Analytics" +``` +Update an action rule +``` +az monitor action-rule update --resource-group rg --name rule --status Disabled +``` +Delete an action rule +``` +az monitor action-rule delete --resource-group rg --name rule +``` +Get an action rule +``` +az monitor action-rule show --resource-group rg --name rule +``` +List action rules of the subscription +``` +az monitor action-rule list +``` +List action rules of the resource group +``` +az monitor action-rule list --resource-group rg +``` \ No newline at end of file diff --git a/src/alertsmanagement/README.rst b/src/alertsmanagement/README.rst deleted file mode 100644 index 6e0cde7f019..00000000000 --- a/src/alertsmanagement/README.rst +++ /dev/null @@ -1,5 +0,0 @@ -Microsoft Azure CLI 'alertsmanagement' Extension -========================================== - -This package is for the 'alertsmanagement' extension. -i.e. 'az alertsmanagement' diff --git a/src/alertsmanagement/azext_alertsmanagement/_help.py b/src/alertsmanagement/azext_alertsmanagement/_help.py index 233e3879fd4..56f5f34529d 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_help.py +++ b/src/alertsmanagement/azext_alertsmanagement/_help.py @@ -35,7 +35,7 @@ examples: - name: Update an action rule text: |- - az monitor action-rule update --resource-group "rg" --name "rule" --status "Disabled" + az monitor action-rule update --resource-group rg --name rule --status Disabled """ helps['monitor action-rule delete'] = """ @@ -44,16 +44,16 @@ examples: - name: Delete an action rule text: |- - az monitor action-rule delete --resource-group "rg" --name "rule" + az monitor action-rule delete --resource-group rg --name rule """ helps['monitor action-rule show'] = """ type: command - short-summary: Get a specific action rule + short-summary: Get an action rule examples: - - name: Get a specific action rule + - name: Get an action rule text: |- - az monitor action-rule show --resource-group "rg" --name "rule" + az monitor action-rule show --resource-group rg --name rule """ helps['monitor action-rule list'] = """ @@ -65,5 +65,5 @@ az monitor action-rule list - name: List action rules of the resource group text: |- - az monitor action-rule list --resource-group "rg" + az monitor action-rule list --resource-group rg """ diff --git a/src/alertsmanagement/setup.py b/src/alertsmanagement/setup.py index 89b4172aded..cde4c6b8d68 100644 --- a/src/alertsmanagement/setup.py +++ b/src/alertsmanagement/setup.py @@ -36,7 +36,7 @@ # TODO: Add any additional SDK dependencies here DEPENDENCIES = [] -with open('README.rst', 'r', encoding='utf-8') as f: +with open('README.md', 'r', encoding='utf-8') as f: README = f.read() with open('HISTORY.rst', 'r', encoding='utf-8') as f: HISTORY = f.read() From e3e75778ed3450d2aa31f4128482d34c42874e8b Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Fri, 13 Mar 2020 22:56:26 +0800 Subject: [PATCH 29/41] preview --- src/alertsmanagement/azext_alertsmanagement/commands.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/commands.py b/src/alertsmanagement/azext_alertsmanagement/commands.py index 40849689380..9a9ce0d2d2b 100644 --- a/src/alertsmanagement/azext_alertsmanagement/commands.py +++ b/src/alertsmanagement/azext_alertsmanagement/commands.py @@ -14,9 +14,11 @@ def load_command_table(self, _): from ._client_factory import cf_action_rules alertsmanagement_action_rules = CliCommandType( - operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._action_rules_operations#ActionRulesOperations.{}', + operations_tmpl='azext_alertsmanagement.vendored_sdks.alertsmanagement.operations._action_rules_operations' + '#ActionRulesOperations.{}', client_factory=cf_action_rules) - with self.command_group('monitor action-rule', alertsmanagement_action_rules, client_factory=cf_action_rules) as g: + with self.command_group('monitor action-rule', alertsmanagement_action_rules, client_factory=cf_action_rules, + is_preview=True) as g: g.custom_command('create', 'create_alertsmanagement_action_rule') g.generic_update_command('update', custom_func_name='update_alertsmanagement_action_rule', setter_arg_name='action_rule', getter_name='get_by_name', From ff05aaaa1eb3ef4179be011fbdb89135f844b1a0 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Mon, 16 Mar 2020 14:14:43 +0800 Subject: [PATCH 30/41] help --- src/alertsmanagement/azext_alertsmanagement/_params.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 7ea8037aed7..02ed038267c 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -42,7 +42,10 @@ def load_arguments(self, _): c.argument('suppression_end_date', help='End date for suppression. Format: MM/DD/YYYY') c.argument('suppression_start_time', help='Start time for suppression. Format: hh:mm:ss') c.argument('suppression_end_time', help='End time for suppression. Format: hh:mm:ss') - c.argument('suppression_recurrence', nargs='+', help='List of recurrence pattern values, delimited by space. If recurrence type is weekly, 0 stands for Sunday, 1 stands for Monday, and so on.') + c.argument('suppression_recurrence', nargs='+', + help='List of recurrence pattern values, delimited by space. If recurrence type is Weekly, values ' + 'should range from 0 to 6. 0 stands for Sunday, 1 stands for Monday, ..., 6 stands for Saturday. ' + 'If recurrence type is Monthly, values should range from 1 to 31') with self.argument_context('monitor action-rule update') as c: c.argument('action_rule_name', action_rule_name) From 16f508c14d2bc5f6b8e7d36f8325b81029ad777b Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 17 Mar 2020 10:33:38 +0800 Subject: [PATCH 31/41] help --- src/alertsmanagement/azext_alertsmanagement/_params.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 02ed038267c..008dc03e12e 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -43,9 +43,10 @@ def load_arguments(self, _): c.argument('suppression_start_time', help='Start time for suppression. Format: hh:mm:ss') c.argument('suppression_end_time', help='End time for suppression. Format: hh:mm:ss') c.argument('suppression_recurrence', nargs='+', - help='List of recurrence pattern values, delimited by space. If recurrence type is Weekly, values ' - 'should range from 0 to 6. 0 stands for Sunday, 1 stands for Monday, ..., 6 stands for Saturday. ' - 'If recurrence type is Monthly, values should range from 1 to 31') + help='List of recurrence pattern values, delimited by space. If --suppression-recurrence-type is ' + 'Weekly, allowed values range from 0 to 6. 0 stands for Sunday, 1 stands for Monday, ..., 6 ' + 'stands for Saturday. If --suppression-recurrence-type is Monthly, allowed values range from ' + '1 to 31, stands for day of month') with self.argument_context('monitor action-rule update') as c: c.argument('action_rule_name', action_rule_name) From b8468f78497644a906cae83743a5f47d71840e07 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 17 Mar 2020 11:07:23 +0800 Subject: [PATCH 32/41] fix --- .../azext_alertsmanagement/_params.py | 9 +-- .../azext_alertsmanagement/custom.py | 2 +- .../test_alertsmanagement_action_rule.yaml | 63 ++++++++++--------- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 008dc03e12e..cdecafbc146 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -11,6 +11,7 @@ get_enum_type, get_location_type ) +from azure.cli.core.commands.validators import get_default_location_from_resource_group from knack.arguments import CLIArgumentType @@ -23,7 +24,7 @@ def load_arguments(self, _): with self.argument_context('monitor action-rule create') as c: c.argument('action_rule_name', action_rule_name) - c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group) c.argument('tags', tags_type) c.argument('status', arg_type=get_enum_type(ActionRuleStatus), id_part=None, help='Indicate if the given action rule is enabled or disabled. Default to enabled.') c.argument('rule_type', arg_type=get_enum_type(['Suppression', 'ActionGroup', 'Diagnostics']), help='Indicate type of action rule') @@ -63,11 +64,11 @@ def load_arguments(self, _): with self.argument_context('monitor action-rule list') as c: c.argument('target_resource_group', id_part=None, help='Filter by target resource group name. Default value is select all.') c.argument('target_resource_type', id_part=None, help='Filter by target resource type. Default value is select all.') - c.argument('target_resource', id_part=None, help='Filter by target resource( which is full ARM ID) Default value is select all.') - c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') + c.argument('target_resource', id_part=None, help='Filter by target resource (which is full ARM ID). Default value is select all.') + c.argument('severity', id_part=None, help='Filter by severity. Default value is select all.') c.argument('monitor_service', id_part=None, help='Filter by monitor service which generates the alert instance. Default value is select all.') c.argument('impacted_scope', id_part=None, help='Filter by impacted/target scope (provide comma separated list for multiple scopes). The value should be an well constructed ARM id of the scope.') c.argument('description', id_part=None, help='Filter by alert rule description') - c.argument('alert_rule_id', id_part=None, help='Filter by alert rule id') + c.argument('alert_rule_id', id_part=None, help='Filter by alert rule ID') c.argument('action_group', id_part=None, help='Filter by action group configured as part of action rule') c.argument('name', id_part=None, help='Filter by action rule name') diff --git a/src/alertsmanagement/azext_alertsmanagement/custom.py b/src/alertsmanagement/azext_alertsmanagement/custom.py index e2600186a70..d3e9920c777 100644 --- a/src/alertsmanagement/azext_alertsmanagement/custom.py +++ b/src/alertsmanagement/azext_alertsmanagement/custom.py @@ -55,8 +55,8 @@ def _alert_rule_id(subscription, resource_group, alert): def create_alertsmanagement_action_rule(cmd, client, resource_group_name, action_rule_name, - location, rule_type, + location=None, description=None, scope_type=None, scope=None, diff --git a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml index d0694cd1f84..dc956f53bd7 100644 --- a/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml +++ b/src/alertsmanagement/azext_alertsmanagement/tests/latest/recordings/test_alertsmanagement_action_rule.yaml @@ -27,7 +27,7 @@ interactions: --severity --monitor-service --monitor-condition --target-resource-type --suppression-recurrence-type --suppression-start-date --suppression-end-date --suppression-start-time --suppression-end-time User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US @@ -36,18 +36,18 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:46.7753339Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-17T02:49:50.29547Z","createdBy":"User","lastModifiedAt":"2020-03-17T02:49:50.29547Z","lastModifiedBy":"User"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '1160' + - '1130' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Fri, 13 Mar 2020 06:56:47 GMT + - Tue, 17 Mar 2020 02:49:51 GMT expires: - '-1' pragma: @@ -61,7 +61,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1197' + - '1198' x-xss-protection: - 1; mode=block status: @@ -81,7 +81,7 @@ interactions: ParameterSetName: - --resource-group --name User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US @@ -90,18 +90,18 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:46.7753339Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-17T02:49:50.29547Z","createdBy":"User","lastModifiedAt":"2020-03-17T02:49:50.29547Z","lastModifiedBy":"User"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '1160' + - '1130' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Fri, 13 Mar 2020 06:56:50 GMT + - Tue, 17 Mar 2020 02:49:54 GMT expires: - '-1' pragma: @@ -135,7 +135,7 @@ interactions: ParameterSetName: - --resource-group --name --status User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US @@ -144,18 +144,18 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:46.7753339Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-17T02:49:50.29547Z","createdBy":"User","lastModifiedAt":"2020-03-17T02:49:50.29547Z","lastModifiedBy":"User"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '1160' + - '1130' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Fri, 13 Mar 2020 06:56:53 GMT + - Tue, 17 Mar 2020 02:49:57 GMT expires: - '-1' pragma: @@ -201,7 +201,7 @@ interactions: ParameterSetName: - --resource-group --name --status User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US @@ -210,18 +210,18 @@ interactions: response: body: string: '{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:55.3373756Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-17T02:49:50.29547Z","createdBy":"User","lastModifiedAt":"2020-03-17T02:50:00.8682607Z","lastModifiedBy":"User"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}' headers: cache-control: - no-store, no-cache content-length: - - '1161' + - '1133' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Fri, 13 Mar 2020 06:56:55 GMT + - Tue, 17 Mar 2020 02:50:00 GMT expires: - '-1' pragma: @@ -235,7 +235,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1199' + - '1198' x-xss-protection: - 1; mode=block status: @@ -253,7 +253,7 @@ interactions: Connection: - keep-alive User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US @@ -261,8 +261,9 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AlertsManagement/actionRules?api-version=2019-05-05-preview response: body: - string: '{"value":[{"properties":{"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"03/13/2020","endDate":"03/14/2020","startTime":"05:54:56","endTime":"05:54:56","recurrenceValues":[0,1,2,4,5,6]}},"description":"","createdAt":"2020-03-13T06:21:58.0932972Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:21:58.0932972Z","lastModifiedBy":"fey@microsoft.com"},"location":"global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:55.3373756Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00","recurrenceValues":[0,6]}},"createdAt":"2020-03-13T06:29:08.1868672Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:29:08.1868672Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule2","type":"Microsoft.AlertsManagement/actionRules","name":"rule2"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev4"]},"targetResourceType":{"operator":"Equals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00","recurrenceValues":[0,6]}},"createdAt":"2020-03-13T06:34:23.1716761Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:34:23.1716761Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule3","type":"Microsoft.AlertsManagement/actionRules","name":"rule3"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log + string: '{"value":[{"properties":{"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"03/13/2020","endDate":"03/14/2020","startTime":"05:54:56","endTime":"05:54:56","recurrenceValues":[0,1,2,4,5,6]}},"description":"","createdAt":"2020-03-13T06:21:58.0932972Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:21:58.0932972Z","lastModifiedBy":"fey@microsoft.com"},"location":"global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log + Analytics"]},"alertContext":{"operator":"Contains","values":["Computer-01"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Always"},"createdAt":"2020-03-17T02:48:49.5945669Z","createdBy":"User","lastModifiedAt":"2020-03-17T02:48:49.5945669Z","lastModifiedBy":"User"},"location":"global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest2/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-17T02:49:50.29547Z","createdBy":"User","lastModifiedAt":"2020-03-17T02:50:00.8682607Z","lastModifiedBy":"User"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00","recurrenceValues":[0,6]}},"createdAt":"2020-03-13T06:29:08.1868672Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:29:08.1868672Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule2","type":"Microsoft.AlertsManagement/actionRules","name":"rule2"},{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev4"]},"targetResourceType":{"operator":"Equals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Weekly","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00","recurrenceValues":[0,6]}},"createdAt":"2020-03-13T06:34:23.1716761Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:34:23.1716761Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule3","type":"Microsoft.AlertsManagement/actionRules","name":"rule3"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log Analytics"]},"alertContext":{"operator":"Contains","values":["Computer-01"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Always"},"description":"","createdAt":"2020-03-13T06:49:24.1672254Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:49:24.1672254Z","lastModifiedBy":"fey@microsoft.com"},"location":"global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule4","type":"Microsoft.AlertsManagement/actionRules","name":"rule4"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log Analytics"]},"alertContext":{"operator":"Contains","values":["Computer-01"]}},"status":"Enabled","type":"Suppression","suppressionConfig":{"recurrenceType":"Always"},"createdAt":"2020-03-13T06:51:55.0195146Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:51:55.0195146Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule5","type":"Microsoft.AlertsManagement/actionRules","name":"rule5"},{"properties":{"conditions":{"monitorService":{"operator":"Equals","values":["Log Analytics"]},"alertContext":{"operator":"Contains","values":["Computer-01"]}},"status":"Enabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg"]},"suppressionConfig":{"recurrenceType":"Always"},"createdAt":"2020-03-13T06:55:49.5585692Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:55:49.5585692Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/fytest/providers/Microsoft.AlertsManagement/actionRules/rule6","type":"Microsoft.AlertsManagement/actionRules","name":"rule6"}]}' @@ -270,13 +271,13 @@ interactions: cache-control: - no-store, no-cache content-length: - - '5294' + - '5870' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Fri, 13 Mar 2020 06:56:57 GMT + - Tue, 17 Mar 2020 02:50:04 GMT expires: - '-1' pragma: @@ -290,7 +291,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '998' + - '999' x-xss-protection: - 1; mode=block status: @@ -310,7 +311,7 @@ interactions: ParameterSetName: - -g User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US @@ -319,18 +320,18 @@ interactions: response: body: string: '{"value":[{"properties":{"conditions":{"severity":{"operator":"Equals","values":["Sev0","Sev2"]},"monitorService":{"operator":"Equals","values":["Platform","Application - Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-13T06:56:46.7753339Z","createdBy":"fey@microsoft.com","lastModifiedAt":"2020-03-13T06:56:55.3373756Z","lastModifiedBy":"fey@microsoft.com"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' + Insights"]},"monitorCondition":{"operator":"Equals","values":["Fired"]},"targetResourceType":{"operator":"NotEquals","values":["Microsoft.Compute/VirtualMachines"]}},"status":"Disabled","type":"Suppression","scope":{"scopeType":"ResourceGroup","values":["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001"]},"suppressionConfig":{"recurrenceType":"Daily","schedule":{"startDate":"12/09/2018","endDate":"12/18/2018","startTime":"06:00:00","endTime":"14:00:00"}},"createdAt":"2020-03-17T02:49:50.29547Z","createdBy":"User","lastModifiedAt":"2020-03-17T02:50:00.8682607Z","lastModifiedBy":"User"},"location":"Global","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_alertsmanagement_action_rule_000001/providers/Microsoft.AlertsManagement/actionRules/rule1","type":"Microsoft.AlertsManagement/actionRules","name":"rule1"}]}' headers: cache-control: - no-store, no-cache content-length: - - '1173' + - '1145' content-security-policy: - script-src 'self' content-type: - application/json; charset=utf-8 date: - - Fri, 13 Mar 2020 06:56:59 GMT + - Tue, 17 Mar 2020 02:50:07 GMT expires: - '-1' pragma: @@ -344,7 +345,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-resource-requests: - - '999' + - '998' x-xss-protection: - 1; mode=block status: @@ -366,7 +367,7 @@ interactions: ParameterSetName: - -g -n User-Agent: - - python/3.8.1 (Windows-10-10.0.17763-SP0) msrest/0.6.10 msrest_azure/0.6.2 + - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2 azure-mgmt-alertsmanagement/0.2.0rc2 Azure-SDK-For-Python AZURECLI/2.2.0 accept-language: - en-US @@ -385,7 +386,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Fri, 13 Mar 2020 06:57:06 GMT + - Tue, 17 Mar 2020 02:50:14 GMT expires: - '-1' pragma: From 8d95d4e80a1b24558eb3984bf1d8b02a28ac467b Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 2 Apr 2020 14:12:32 +0800 Subject: [PATCH 33/41] Add experimental tag --- src/alertsmanagement/azext_alertsmanagement/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/commands.py b/src/alertsmanagement/azext_alertsmanagement/commands.py index 9a9ce0d2d2b..77b7ce025b4 100644 --- a/src/alertsmanagement/azext_alertsmanagement/commands.py +++ b/src/alertsmanagement/azext_alertsmanagement/commands.py @@ -18,7 +18,7 @@ def load_command_table(self, _): '#ActionRulesOperations.{}', client_factory=cf_action_rules) with self.command_group('monitor action-rule', alertsmanagement_action_rules, client_factory=cf_action_rules, - is_preview=True) as g: + is_experimental=True) as g: g.custom_command('create', 'create_alertsmanagement_action_rule') g.generic_update_command('update', custom_func_name='update_alertsmanagement_action_rule', setter_arg_name='action_rule', getter_name='get_by_name', From bedc15eda8107b2ddd6ae74bb8359c619f5d02c9 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 2 Apr 2020 14:16:28 +0800 Subject: [PATCH 34/41] remove python 3.5; change min version --- src/alertsmanagement/azext_alertsmanagement/azext_metadata.json | 2 +- src/alertsmanagement/setup.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json index 55c81bf3328..1c0e70d1a64 100644 --- a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json +++ b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isPreview": true, - "azext.minCliCoreVersion": "2.0.67" + "azext.minCliCoreVersion": "2.3.0" } \ No newline at end of file diff --git a/src/alertsmanagement/setup.py b/src/alertsmanagement/setup.py index cde4c6b8d68..9d4fd85a920 100644 --- a/src/alertsmanagement/setup.py +++ b/src/alertsmanagement/setup.py @@ -26,7 +26,6 @@ 'Intended Audience :: System Administrators', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', From 1c3e2751d373aac8aa33b53439100abae36959fa Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 2 Apr 2020 14:18:49 +0800 Subject: [PATCH 35/41] Fix merge mistake --- .github/CODEOWNERS | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 450b51f919b..d6a3414c290 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -82,8 +82,6 @@ /src/alertsmanagement/ @qwordy -/src/alertsmanagement/ @qwordy - /src/synapse/ @idear1203 @aim-for-better /src/stream-analytics/ @arrownj From 9429ea5357710db708189433ea2a4d2004d4f987 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 2 Apr 2020 16:15:31 +0800 Subject: [PATCH 36/41] update min cli core verison --- src/alertsmanagement/azext_alertsmanagement/azext_metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json index 1c0e70d1a64..8cfc6da9485 100644 --- a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json +++ b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isPreview": true, - "azext.minCliCoreVersion": "2.3.0" + "azext.minCliCoreVersion": "2.3.1" } \ No newline at end of file From 12160978cdba1a670ddcd381175761c58361f4c5 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Thu, 2 Apr 2020 16:18:39 +0800 Subject: [PATCH 37/41] experimental --- src/alertsmanagement/azext_alertsmanagement/azext_metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json index 8cfc6da9485..13025150393 100644 --- a/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json +++ b/src/alertsmanagement/azext_alertsmanagement/azext_metadata.json @@ -1,4 +1,4 @@ { - "azext.isPreview": true, + "azext.isExperimental": true, "azext.minCliCoreVersion": "2.3.1" } \ No newline at end of file From 49915105e42f257105f6d4990827768849317dcf Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 7 Apr 2020 21:41:27 +0800 Subject: [PATCH 38/41] {Pipeline} print stacktrace when exception --- scripts/ci/index_ref_doc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/ci/index_ref_doc.py b/scripts/ci/index_ref_doc.py index 90ba08ee794..a814bd95e80 100644 --- a/scripts/ci/index_ref_doc.py +++ b/scripts/ci/index_ref_doc.py @@ -10,9 +10,10 @@ import os import sys import tempfile +import traceback import unittest import shutil -from subprocess import check_call +from subprocess import check_call, CalledProcessError from pkg_resources import parse_version, get_distribution from six import with_metaclass @@ -57,7 +58,11 @@ def test(self): os.mkdir(ref_doc_out_dir) script_args = [sys.executable, REF_GEN_SCRIPT, '--extension-file', ext_file, '--output-dir', ref_doc_out_dir] - check_call(script_args) + try: + check_call(script_args) + except CalledProcessError as e: + traceback.print_exc(e) + raise e return test for ext_name, ext_url, filename in ALL_TESTS: From 77cf51f407e967f0eee23ee74e62014395466072 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 7 Apr 2020 23:42:18 +0800 Subject: [PATCH 39/41] {Alertsmanagement} Fix import problem. It only happens in CI --- src/alertsmanagement/azext_alertsmanagement/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index cdecafbc146..90ac47e5b84 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -5,7 +5,7 @@ # pylint: disable=line-too-long # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from azext_alertsmanagement.vendored_sdks.alertsmanagement.models import ActionRuleStatus, SuppressionType +from .vendored_sdks.alertsmanagement.models import ActionRuleStatus, SuppressionType from azure.cli.core.commands.parameters import ( tags_type, get_enum_type, From 66e3d0b3f56ad39f771b03b2fed9b32aa07ca65d Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 7 Apr 2020 23:45:59 +0800 Subject: [PATCH 40/41] revert --- scripts/ci/index_ref_doc.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/ci/index_ref_doc.py b/scripts/ci/index_ref_doc.py index a814bd95e80..90ba08ee794 100644 --- a/scripts/ci/index_ref_doc.py +++ b/scripts/ci/index_ref_doc.py @@ -10,10 +10,9 @@ import os import sys import tempfile -import traceback import unittest import shutil -from subprocess import check_call, CalledProcessError +from subprocess import check_call from pkg_resources import parse_version, get_distribution from six import with_metaclass @@ -58,11 +57,7 @@ def test(self): os.mkdir(ref_doc_out_dir) script_args = [sys.executable, REF_GEN_SCRIPT, '--extension-file', ext_file, '--output-dir', ref_doc_out_dir] - try: - check_call(script_args) - except CalledProcessError as e: - traceback.print_exc(e) - raise e + check_call(script_args) return test for ext_name, ext_url, filename in ALL_TESTS: From acbcdcaaad24bf1d055831d6655379964ad59d28 Mon Sep 17 00:00:00 2001 From: Feiyue Yu Date: Tue, 7 Apr 2020 23:51:21 +0800 Subject: [PATCH 41/41] fix style --- src/alertsmanagement/azext_alertsmanagement/_params.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/alertsmanagement/azext_alertsmanagement/_params.py b/src/alertsmanagement/azext_alertsmanagement/_params.py index 90ac47e5b84..f8b40c19430 100644 --- a/src/alertsmanagement/azext_alertsmanagement/_params.py +++ b/src/alertsmanagement/azext_alertsmanagement/_params.py @@ -5,7 +5,7 @@ # pylint: disable=line-too-long # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from .vendored_sdks.alertsmanagement.models import ActionRuleStatus, SuppressionType + from azure.cli.core.commands.parameters import ( tags_type, get_enum_type, @@ -13,6 +13,7 @@ ) from azure.cli.core.commands.validators import get_default_location_from_resource_group from knack.arguments import CLIArgumentType +from .vendored_sdks.alertsmanagement.models import ActionRuleStatus, SuppressionType def load_arguments(self, _):