1# --------------------------------------------------------------------------------------------
2# Copyright (c) Microsoft Corporation. All rights reserved.
3# Licensed under the MIT License. See License.txt in the project root for license information.
4# --------------------------------------------------------------------------------------------
5
6from knack.arguments import CLIArgumentType
7
8from azure.cli.core.commands.parameters import \
9    (get_enum_type,
10     get_resource_name_completion_list)
11
12from ._validators import \
13    (validate_include_or_exclude,
14     validate_ids_or_names,
15     validate_ids_or_resource_group,
16     validate_threshold_or_resource_group)
17
18
19def load_arguments(self, _):
20    ids_arg_type = CLIArgumentType(nargs='+', options_list=['--ids'],
21                                   help='One or more resource IDs (space-delimited). If provided, no other '
22                                        '"Resource Id" arguments should be specified.')
23
24    name_arg_type = CLIArgumentType(options_list=['--name', '-n'],
25                                    help='The name of the recommendation as output by the list command.',
26                                    completer=get_resource_name_completion_list('Microsoft.Advisor/recommendations'))
27
28    with self.argument_context('advisor recommendation list') as c:
29        c.argument('ids', ids_arg_type, validator=validate_ids_or_resource_group)
30        c.argument('category', options_list=['--category', '-c'], help='Name of recommendation category.',
31                   arg_type=get_enum_type(['Cost', 'HighAvailability', 'Performance', 'Security']))
32        c.argument('refresh', options_list=['--refresh', '-r'], action='store_true',
33                   help='Generate new recommendations.')
34
35    with self.argument_context('advisor recommendation disable') as c:
36        c.argument('ids', ids_arg_type, arg_group="Resource Id", validator=validate_ids_or_names)
37        c.argument('recommendation_name', name_arg_type, arg_group="Resource Id")
38        c.argument('resource_group_name', arg_group="Resource Id")
39        c.argument('days', options_list=['--days', '-d'], type=int,
40                   help='Number of days to disable. If not specified, the recommendation is disabled forever.')
41
42    with self.argument_context('advisor recommendation enable') as c:
43        c.argument('ids', ids_arg_type, arg_group="Resource Id", validator=validate_ids_or_names)
44        c.argument('resource_group_name', arg_group="Resource Id")
45        c.argument('recommendation_name', name_arg_type, arg_group="Resource Id")
46
47    with self.argument_context('advisor configuration update') as c:
48        c.argument('low_cpu_threshold', options_list=['--low-cpu-threshold', '-l'],
49                   help='Value for low CPU threshold.', arg_type=get_enum_type(['5', '10', '15', '20']),
50                   validator=validate_threshold_or_resource_group)
51        c.argument('exclude', options_list=['--exclude', '-e'], action='store_true',
52                   help='Exclude from recommendation generation.')
53        c.argument('include', options_list=['--include', '-i'], action='store_true',
54                   help='Include in recommendation generation.', validator=validate_include_or_exclude)
55        c.argument('configuration_name', help='Advisor configuration name. Value must be "default"')
56