Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b0f7e30
Initial commit
qwordy Dec 31, 2019
3657360
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Jan 16, 2020
0b5607a
Update
qwordy Jan 17, 2020
007bf40
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Jan 17, 2020
698d6e5
smart-detector-alert-rule
qwordy Jan 17, 2020
53d7eb9
Add smart group, alert commands
qwordy Jan 20, 2020
4db5e86
Merge branch 'master' into alertsmanagement
qwordy Feb 17, 2020
81ba2ae
Update
qwordy Feb 17, 2020
5c288ea
action-rule create
qwordy Feb 18, 2020
203baba
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Feb 18, 2020
187facd
action-rule create / udpate
qwordy Feb 19, 2020
e9bf874
Fix style
qwordy Feb 19, 2020
ba2b67b
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Feb 19, 2020
0be79cf
add code owner
qwordy Feb 20, 2020
7feafc4
merge
qwordy Mar 5, 2020
24155fd
Merge branch 'master' of github.com:Azure/azure-cli-extensions into a…
qwordy Mar 9, 2020
eebe4ee
test
qwordy Mar 9, 2020
48dc0b0
remove rubbish code
qwordy Mar 10, 2020
0a41eaa
Merge branch 'master' of github.com:Azure/azure-cli-extensions into a…
qwordy Mar 10, 2020
7fb3654
Only reserve action-rule commands
qwordy Mar 10, 2020
bc37331
update help
qwordy Mar 10, 2020
b937b4f
update name, rg
qwordy Mar 10, 2020
052a855
update help
qwordy Mar 10, 2020
95b7898
list
qwordy Mar 10, 2020
b4d4c0a
--status
qwordy Mar 10, 2020
4763e8b
recurrence_type
qwordy Mar 11, 2020
10424e0
alert_rule
qwordy Mar 11, 2020
fa8b90f
SuppressionSchedule
qwordy Mar 11, 2020
6d384ca
remove rubbish code
qwordy Mar 11, 2020
b4ff21e
update setup.py
qwordy Mar 11, 2020
204fed8
refactor
qwordy Mar 11, 2020
ffa3e57
remove trash
qwordy Mar 11, 2020
9f36459
Rename alertsmanagement to monitor
qwordy Mar 11, 2020
00f11d1
style
qwordy Mar 12, 2020
7e2b69f
merge
qwordy Mar 12, 2020
8b3d149
recurrence pattern; add 3 examples
qwordy Mar 13, 2020
8fc8e12
readme
qwordy Mar 13, 2020
e3e7577
preview
qwordy Mar 13, 2020
ff05aaa
help
qwordy Mar 16, 2020
e0c4a1e
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Mar 16, 2020
16f508c
help
qwordy Mar 17, 2020
b8468f7
fix
qwordy Mar 17, 2020
01909cc
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Mar 17, 2020
60a2029
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Apr 2, 2020
8d95d4e
Add experimental tag
qwordy Apr 2, 2020
bedc15e
remove python 3.5; change min version
qwordy Apr 2, 2020
1c3e275
Fix merge mistake
qwordy Apr 2, 2020
9429ea5
update min cli core verison
qwordy Apr 2, 2020
1216097
experimental
qwordy Apr 2, 2020
575cbb3
Merge branch 'master' into alertsmanagement-phase1
qwordy Apr 3, 2020
0683907
Merge branch 'master' into alertsmanagement-phase1
qwordy Apr 3, 2020
3db13d8
Merge branch 'master' into alertsmanagement-phase1
qwordy Apr 5, 2020
7b05846
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
qwordy Apr 7, 2020
4991510
{Pipeline} print stacktrace when exception
qwordy Apr 7, 2020
4d7fd2e
Merge branch 'alertsmanagement-phase1' of https://github.com/qwordy/a…
qwordy Apr 7, 2020
77cf51f
{Alertsmanagement} Fix import problem. It only happens in CI
qwordy Apr 7, 2020
66e3d0b
revert
qwordy Apr 7, 2020
acbcdca
fix style
qwordy Apr 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
action-rule create / udpate
  • Loading branch information
qwordy committed Feb 19, 2020
commit 187facdaabb0388b7960c042d1d486b2147ffe72
7 changes: 6 additions & 1 deletion src/alertsmanagement/azext_alertsmanagement/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion src/alertsmanagement/azext_alertsmanagement/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
78 changes: 48 additions & 30 deletions src/alertsmanagement/azext_alertsmanagement/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,56 +144,74 @@ 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)
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
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,
Expand Down
Loading