1010from azure .cli .core .commands .validators import get_default_location_from_resource_group
1111
1212from azure .cli .command_modules .monitor .actions import (
13- AlertAddAction , AlertRemoveAction , ConditionAction ,
1413 AutoscaleScaleAction , AutoscaleConditionAction , get_period_type , AutoscaleCreateAction ,
1514 timezone_offset_type , timezone_name_type , MetricAlertConditionAction , MetricAlertAddAction )
16- from azure .cli .command_modules .monitor .util import get_operator_map , get_aggregation_map
1715from azure .cli .command_modules .monitor .validators import (
1816 validate_loganalytics_workspace_search_table_name , validate_loganalytics_workspace_restore_table_name ,
1917 validate_autoscale_recurrence , validate_autoscale_timegrain , get_action_group_validator ,
2523
2624# pylint: disable=line-too-long, too-many-statements
2725def load_arguments (self , _ ):
28- from azure .mgmt .monitor .models import ConditionOperator , TimeAggregationOperator , EventData , PredictiveAutoscalePolicyScaleMode
26+ from azure .mgmt .monitor .models import EventData , PredictiveAutoscalePolicyScaleMode
2927 from .grammar .metric_alert .MetricAlertConditionValidator import dim_op_conversion , agg_conversion , op_conversion , sens_conversion
3028 name_arg_type = CLIArgumentType (options_list = ['--name' , '-n' ], metavar = 'NAME' )
3129
@@ -37,54 +35,6 @@ def load_arguments(self, _):
3735 c .argument ('location' , get_location_type (self .cli_ctx ), validator = get_default_location_from_resource_group )
3836 c .argument ('tags' , tags_type )
3937
40- # region Alerts
41- with self .argument_context ('monitor alert' ) as c :
42- c .argument ('rule_name' , name_arg_type , id_part = 'name' , help = 'Name of the alert rule.' )
43-
44- with self .argument_context ('monitor alert create' ) as c :
45- c .resource_parameter ('target' , arg_group = 'Target Resource' , alias = 'target' , preserve_resource_group_parameter = True )
46- c .argument ('rule_name' , name_arg_type , id_part = 'name' , help = 'Name of the alert rule.' )
47- c .argument ('disabled' , arg_type = get_three_state_flag ())
48- c .argument ('condition' , action = ConditionAction , nargs = '+' )
49-
50- with self .argument_context ('monitor alert create' , arg_group = 'Action' ) as c :
51- c .argument ('custom_emails' , nargs = '+' )
52- c .argument ('email_service_owners' , arg_type = get_three_state_flag ())
53- c .argument ('actions' , options_list = ['--action' , '-a' ], action = AlertAddAction , nargs = '+' )
54-
55- with self .argument_context ('monitor alert create' , arg_group = 'Condition' ) as c :
56- c .argument ('metric_name' )
57- c .argument ('operator' , arg_type = get_enum_type (ConditionOperator ))
58- c .argument ('threshold' )
59- c .argument ('time_aggregation' , arg_type = get_enum_type (TimeAggregationOperator ))
60- c .argument ('window_size' )
61-
62- with self .argument_context ('monitor alert update' ) as c :
63- c .argument ('rule_name' , name_arg_type , id_part = 'name' , help = 'Name of the alert rule.' )
64- c .resource_parameter ('target' , arg_group = 'Target Resource' , required = False , preserve_resource_group_parameter = True )
65-
66- with self .argument_context ('monitor alert update' , arg_group = 'Action' ) as c :
67- c .argument ('email_service_owners' , arg_type = get_three_state_flag ())
68- c .argument ('add_actions' , options_list = ['--add-action' , '-a' ], nargs = '+' , action = AlertAddAction )
69- c .argument ('remove_actions' , options_list = ['--remove-action' , '-r' ], nargs = '+' , action = AlertRemoveAction )
70-
71- with self .argument_context ('monitor alert update' , arg_group = 'Condition' ) as c :
72- c .argument ('condition' , action = ConditionAction , nargs = '+' )
73- c .argument ('metric' )
74- c .argument ('operator' , arg_type = get_enum_type (get_operator_map ().keys ()))
75- c .argument ('threshold' )
76- c .argument ('aggregation' , arg_type = get_enum_type (get_aggregation_map ().keys ()))
77- c .argument ('period' , type = get_period_type ())
78-
79- for scope in ['monitor alert show-incident' , 'monitor alert list-incidents' ]:
80- with self .argument_context (scope ) as c :
81- c .argument ('rule_name' , options_list = ['--rule-name' ], id_part = 'name' )
82- c .argument ('incident_name' , name_arg_type , id_part = 'child_name_1' )
83-
84- with self .argument_context ('monitor alert list-incidents' ) as c :
85- c .argument ('rule_name' , options_list = ['--rule-name' ], id_part = None )
86- # endregion
87-
8838 # region Metrics
8939 with self .argument_context ('monitor metrics' ) as c :
9040 c .argument ('metricnamespace' , options_list = ['--namespace' ], help = 'Namespace to query metric definitions for.' )
0 commit comments