diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 2cd679ccf1d..8016525d11e 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -105,7 +105,6 @@ setup( EOL for name in $(ls src/command_modules | grep azure-cli-); do - if [ "$name" == "azure-cli-advisor" ]; then continue; fi if [ "$name" == "azure-cli-appservice" ]; then continue; fi if [ "$name" == "azure-cli-backup" ]; then continue; fi if [ "$name" == "azure-cli-batchai" ]; then continue; fi diff --git a/scripts/ci/test_static.sh b/scripts/ci/test_static.sh index 67dd476ffad..c08589afdeb 100755 --- a/scripts/ci/test_static.sh +++ b/scripts/ci/test_static.sh @@ -36,7 +36,7 @@ set +e run_style azure.cli.core run_style azure.cli.command_modules.acr run_style azure.cli.command_modules.acs -#run_style azure.cli.command_modules.advisor +run_style azure.cli.command_modules.advisor #run_style azure.cli.command_modules.appservice #run_style azure.cli.command_modules.backup run_style azure.cli.command_modules.batch diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/__init__.py b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/__init__.py index 736d06f030f..5a0d41472f8 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/__init__.py +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/__init__.py @@ -3,12 +3,27 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +from azure.cli.core import AzCommandsLoader + import azure.cli.command_modules.advisor._help # pylint: disable=unused-import -def load_params(_): - import azure.cli.command_modules.advisor._params # pylint: disable=redefined-outer-name, unused-variable +class AdvisorCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + advisor_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.advisor.custom#{}') + super(AdvisorCommandsLoader, self).__init__(cli_ctx=cli_ctx, custom_command_type=advisor_custom, + min_profile='2017-03-10-profile') + + def load_command_table(self, args): + from azure.cli.command_modules.advisor.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azure.cli.command_modules.advisor._params import load_arguments + load_arguments(self, command) -def load_commands(): - import azure.cli.command_modules.advisor.commands # pylint: disable=redefined-outer-name, unused-variable +COMMAND_LOADER_CLS = AdvisorCommandsLoader diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_client_factory.py b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_client_factory.py index ab036d72f28..cb70b508dac 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_client_factory.py +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_client_factory.py @@ -4,23 +4,23 @@ # -------------------------------------------------------------------------------------------- -def cf_advisor(**_): +def cf_advisor(cli_ctx, **_): from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.mgmt.advisor import AdvisorManagementClient - return get_mgmt_service_client(AdvisorManagementClient) + return get_mgmt_service_client(cli_ctx, AdvisorManagementClient) -def advisor_mgmt_client_factory(kwargs): - return cf_advisor(**kwargs) +def advisor_mgmt_client_factory(cli_ctx, kwargs): + return cf_advisor(cli_ctx, **kwargs) -def recommendations_mgmt_client_factory(kwargs): - return cf_advisor(**kwargs).recommendations +def recommendations_mgmt_client_factory(cli_ctx, kwargs): + return cf_advisor(cli_ctx, **kwargs).recommendations -def suppressions_mgmt_client_factory(kwargs): - return cf_advisor(**kwargs).suppressions +def suppressions_mgmt_client_factory(cli_ctx, kwargs): + return cf_advisor(cli_ctx, **kwargs).suppressions -def configurations_mgmt_client_factory(kwargs): - return cf_advisor(**kwargs).configurations +def configurations_mgmt_client_factory(cli_ctx, kwargs): + return cf_advisor(cli_ctx, **kwargs).configurations diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_params.py b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_params.py index 9d4fa75f920..f62b71a4ee4 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_params.py +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_params.py @@ -3,103 +3,33 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.cli.core.commands import register_cli_argument -from azure.cli.core.commands.parameters import \ - (resource_group_name_type, enum_choice_list) -from azure.cli.core.util import CLIError - - -def validate_include_or_exclude(namespace): - if namespace.include and namespace.exclude: - raise CLIError('usage error: --include | --exclude') - - -def validate_ids_or_resource_group(namespace): - if namespace.ids and namespace.resource_group_name: - raise CLIError('usage error: --ids | --resource-group') - - -register_cli_argument( - 'advisor recommendation list', - 'ids', - nargs='+', - options_list=('--ids'), - help='One or more resource IDs (space delimited). If provided, no other "Resource Id" arguments should be specified.' # pylint: disable=line-too-long -) - -register_cli_argument( - 'advisor recommendation list', - 'resource_group_name', - resource_group_name_type, - validator=validate_ids_or_resource_group -) - -register_cli_argument( - 'advisor recommendation list', - 'category', - options_list=('--category', '-c'), - help='Name of recommendation category.', - **enum_choice_list(['Cost', 'HighAvailability', 'Performance', 'Security']) -) - -register_cli_argument( - 'advisor recommendation disable', - 'ids', - nargs='+', - options_list=('--ids'), - help='One or more resource IDs (space delimited). If provided, no other "Resource Id" arguments should be specified.' # pylint: disable=line-too-long -) - -register_cli_argument( - 'advisor recommendation disable', - 'days', - options_list=('--days', '-d'), - type=int, - help='Number of days to disable. If not specified, the recommendation is disabled forever.' -) - -register_cli_argument( - 'advisor recommendation enable', - 'ids', - nargs='+', - options_list=('--ids'), - help='One or more resource IDs (space delimited). If provided, no other "Resource Id" arguments should be specified.' # pylint: disable=line-too-long -) - -register_cli_argument( - 'advisor configuration get', - 'resource_group_name', - resource_group_name_type -) - -register_cli_argument( - 'advisor configuration set', - 'resource_group_name', - resource_group_name_type -) - -register_cli_argument( - 'advisor configuration set', - 'low_cpu_threshold', - options_list=('--low-cpu-threshold', '-l'), - help='Value for low CPU threshold.', - **enum_choice_list(['5', '10', '15', '20']) -) - -register_cli_argument( - 'advisor configuration set', - 'exclude', - options_list=('--exclude', '-e'), - action='store_true', - help='Exclude from recommendation generation.', - validator=validate_include_or_exclude -) - -register_cli_argument( - 'advisor configuration set', - 'include', - options_list=('--include', '-i'), - action='store_true', - help='Include in recommendation generation.', - validator=validate_include_or_exclude -) +from azure.cli.core.commands.parameters import get_enum_type +from knack.arguments import CLIArgumentType +from ._validators import validate_include_or_exclude, validate_ids_or_resource_group + + +def load_arguments(self, _): + ids_arg_type = CLIArgumentType(nargs='+', options_list=['--ids'], + help='One or more resource IDs (space delimited). If provided, no other ' + '"Resource Id" arguments should be specified.') + + with self.argument_context('advisor recommendation list') as c: + c.argument('ids', ids_arg_type, validator=validate_ids_or_resource_group) + c.argument('category', options_list=['--category', '-c'], help='Name of recommendation category.', + arg_type=get_enum_type(['Cost', 'HighAvailability', 'Performance', 'Security'])) + + with self.argument_context('advisor recommendation disable') as c: + c.argument('ids', ids_arg_type) + c.argument('days', options_list=['--days', '-d'], type=int, + help='Number of days to disable. If not specified, the recommendation is disabled forever.') + + with self.argument_context('advisor recommendation enable') as c: + c.argument('ids', ids_arg_type) + + with self.argument_context('advisor configuration set') as c: + c.argument('low_cpu_threshold', options_list=['--low-cpu-threshold', '-l'], + help='Value for low CPU threshold.', arg_type=get_enum_type(['5', '10', '15', '20'])) + c.argument('exclude', options_list=['--exclude', '-e'], action='store_true', + help='Exclude from recommendation generation.') + c.argument('include', options_list=['--include', '-i'], action='store_true', + help='Include in recommendation generation.', validator=validate_include_or_exclude) diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_validators.py b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_validators.py new file mode 100644 index 00000000000..e2c697e076c --- /dev/null +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/_validators.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from knack.util import CLIError + + +def validate_include_or_exclude(namespace): + if namespace.include and namespace.exclude: + raise CLIError('usage error: --include | --exclude') + + +def validate_ids_or_resource_group(namespace): + if namespace.ids and namespace.resource_group_name: + raise CLIError('usage error: --ids | --resource-group') diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/commands.py b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/commands.py index c88d33dd215..9ec5514805c 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/commands.py +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/commands.py @@ -3,53 +3,24 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from azure.cli.core.commands import cli_command from azure.cli.command_modules.advisor._client_factory import \ (advisor_mgmt_client_factory, recommendations_mgmt_client_factory, suppressions_mgmt_client_factory, configurations_mgmt_client_factory) -custom_path = 'azure.cli.command_modules.advisor.custom#' -cli_command( - __name__, - 'advisor recommendation generate', - custom_path + 'cli_advisor_generate_recommendations', - recommendations_mgmt_client_factory -) - -cli_command( - __name__, - 'advisor recommendation list', - custom_path + 'cli_advisor_list_recommendations', - recommendations_mgmt_client_factory -) - -cli_command( - __name__, - 'advisor recommendation disable', - custom_path + 'cli_advisor_disable_recommendations', - suppressions_mgmt_client_factory -) - -cli_command( - __name__, - 'advisor recommendation enable', - custom_path + 'cli_advisor_enable_recommendations', - advisor_mgmt_client_factory # using advisor client here because this spans recommendations and suppressions -) - -cli_command( - __name__, - 'advisor configuration get', - custom_path + 'cli_advisor_get_configurations', - configurations_mgmt_client_factory -) - -cli_command( - __name__, - 'advisor configuration set', - custom_path + 'cli_advisor_set_configurations', - configurations_mgmt_client_factory -) +def load_command_table(self, _): + with self.command_group('advisor recommendation') as g: + g.custom_command('generate', 'cli_advisor_generate_recommendations', + client_factory=recommendations_mgmt_client_factory) + g.custom_command('list', 'cli_advisor_list_recommendations', + client_factory=recommendations_mgmt_client_factory) + g.custom_command('disable', 'cli_advisor_disable_recommendations', + client_factory=suppressions_mgmt_client_factory) + g.custom_command('enable', 'cli_advisor_enable_recommendations', + client_factory=advisor_mgmt_client_factory) + + with self.command_group('advisor configuration', client_factory=configurations_mgmt_client_factory) as g: + g.custom_command('get', 'cli_advisor_get_configurations') + g.custom_command('set', 'cli_advisor_set_configurations') diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_generate_recommendations.yaml b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_generate_recommendations.yaml index 4049ca9b6e6..85eccf2611d 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_generate_recommendations.yaml +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_generate_recommendations.yaml @@ -8,8 +8,8 @@ interactions: Connection: [keep-alive] Content-Length: ['0'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations?api-version=2017-04-19 @@ -18,14 +18,14 @@ interactions: headers: cache-control: [no-cache] content-length: ['0'] - date: ['Tue, 28 Nov 2017 22:33:03 GMT'] + date: ['Mon, 11 Dec 2017 22:58:43 GMT'] expires: ['-1'] - location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations/cea1a32d-00e8-4c7f-be70-8c0bf790908b?api-version=2017-04-19'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations/0dba36fb-1faf-41f6-a711-37b7f57a29bd?api-version=2017-04-19'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-content-type-options: [nosniff] - x-ms-ratelimit-remaining-subscription-writes: ['1199'] + x-ms-ratelimit-remaining-subscription-writes: ['1196'] status: {code: 202, message: Accepted} - request: body: null @@ -35,22 +35,21 @@ interactions: CommandName: [advisor recommendation generate] Connection: [keep-alive] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations/cea1a32d-00e8-4c7f-be70-8c0bf790908b?api-version=2017-04-19 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations/0dba36fb-1faf-41f6-a711-37b7f57a29bd?api-version=2017-04-19 response: body: {string: ''} headers: cache-control: [no-cache] - content-length: ['0'] - date: ['Tue, 28 Nov 2017 22:33:03 GMT'] + date: ['Mon, 11 Dec 2017 22:58:43 GMT'] expires: ['-1'] - location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/generateRecommendations/cea1a32d-00e8-4c7f-be70-8c0bf790908b?api-version=2017-04-19'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-content-type-options: [nosniff] - status: {code: 202, message: Accepted} + x-ms-ratelimit-remaining-subscription-resource-requests: ['359'] + status: {code: 204, message: No Content} version: 1 diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_resource_group.yaml b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_resource_group.yaml index 55ebccb4af5..a58e2291dd7 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_resource_group.yaml +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_resource_group.yaml @@ -8,8 +8,8 @@ interactions: Connection: [keep-alive] Content-Length: ['50'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 resourcemanagementclient/1.2.1 Azure-SDK-For-Python + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 resourcemanagementclient/1.2.1 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: PUT @@ -20,7 +20,7 @@ interactions: cache-control: [no-cache] content-length: ['328'] content-type: [application/json; charset=utf-8] - date: ['Tue, 28 Nov 2017 22:33:04 GMT'] + date: ['Mon, 11 Dec 2017 22:58:45 GMT'] expires: ['-1'] pragma: [no-cache] strict-transport-security: [max-age=31536000; includeSubDomains] @@ -34,18 +34,18 @@ interactions: CommandName: [advisor configuration get] Connection: [keep-alive] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisor000001","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisor000001","properties":{"exclude":false}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor000001","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor000001","properties":{"exclude":false}}]}'} headers: cache-control: [no-cache] content-length: ['514'] content-type: [application/json; charset=utf-8] - date: ['Tue, 28 Nov 2017 22:33:07 GMT'] + date: ['Mon, 11 Dec 2017 22:58:46 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] @@ -53,6 +53,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-resource-requests: ['599'] status: {code: 200, message: OK} - request: body: '{"properties": {"exclude": true}}' @@ -63,8 +64,8 @@ interactions: Connection: [keep-alive] Content-Length: ['33'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 @@ -72,13 +73,13 @@ interactions: body: {string: ''} headers: cache-control: [no-cache] - date: ['Tue, 28 Nov 2017 22:33:08 GMT'] + date: ['Mon, 11 Dec 2017 22:58:47 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-content-type-options: [nosniff] - x-ms-ratelimit-remaining-subscription-writes: ['1199'] + x-ms-ratelimit-remaining-subscription-resource-requests: ['199'] status: {code: 204, message: No Content} - request: body: null @@ -88,18 +89,18 @@ interactions: CommandName: [advisor configuration get] Connection: [keep-alive] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisor000001","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisor000001","properties":{"exclude":true}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor000001","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor000001","properties":{"exclude":true}}]}'} headers: cache-control: [no-cache] content-length: ['513'] content-type: [application/json; charset=utf-8] - date: ['Tue, 28 Nov 2017 22:33:10 GMT'] + date: ['Mon, 11 Dec 2017 22:58:47 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] @@ -107,6 +108,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-resource-requests: ['599'] status: {code: 200, message: OK} - request: body: '{"properties": {"exclude": false}}' @@ -117,8 +119,8 @@ interactions: Connection: [keep-alive] Content-Length: ['34'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 @@ -126,13 +128,13 @@ interactions: body: {string: ''} headers: cache-control: [no-cache] - date: ['Tue, 28 Nov 2017 22:33:10 GMT'] + date: ['Mon, 11 Dec 2017 22:58:48 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-content-type-options: [nosniff] - x-ms-ratelimit-remaining-subscription-writes: ['1199'] + x-ms-ratelimit-remaining-subscription-resource-requests: ['199'] status: {code: 204, message: No Content} - request: body: null @@ -142,18 +144,18 @@ interactions: CommandName: [advisor configuration get] Connection: [keep-alive] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisor000001","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisor000001","properties":{"exclude":false}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor000001/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor000001","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor000001","properties":{"exclude":false}}]}'} headers: cache-control: [no-cache] content-length: ['514'] content-type: [application/json; charset=utf-8] - date: ['Tue, 28 Nov 2017 22:33:11 GMT'] + date: ['Mon, 11 Dec 2017 22:58:49 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] @@ -161,6 +163,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-resource-requests: ['599'] status: {code: 200, message: OK} - request: body: null @@ -171,8 +174,8 @@ interactions: Connection: [keep-alive] Content-Length: ['0'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 resourcemanagementclient/1.2.1 Azure-SDK-For-Python + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 resourcemanagementclient/1.2.1 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: DELETE @@ -182,9 +185,9 @@ interactions: headers: cache-control: [no-cache] content-length: ['0'] - date: ['Tue, 28 Nov 2017 22:33:12 GMT'] + date: ['Mon, 11 Dec 2017 22:58:50 GMT'] expires: ['-1'] - location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTEk6NUZURVNUOjVGQURWSVNPUkFMUlYyUlIzQ1pVQVM0VTI3MkU1R1E3U0NaWXxBQjI3RDgxRkQxN0Y0NEY2LVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2017-05-10'] + location: ['https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTEk6NUZURVNUOjVGQURWSVNPUkRRUlczT1FSM0RYVVRUQU9JWDQ3R0pNU1k3V3wxOEMxRjE5RjRFRDcyQTdDLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2017-05-10'] pragma: [no-cache] strict-transport-security: [max-age=31536000; includeSubDomains] x-ms-ratelimit-remaining-subscription-writes: ['1199'] diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_subscription.yaml b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_subscription.yaml index 816e72ce181..61f086806eb 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_subscription.yaml +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/recordings/latest/test_get_set_configurations_subscription.yaml @@ -7,18 +7,18 @@ interactions: CommandName: [advisor configuration get] Connection: [keep-alive] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61","properties":{"low_cpu_threshold":"5","exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut","properties":{"exclude":false}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","properties":{"low_cpu_threshold":"5","exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf","properties":{"exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae","properties":{"exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot","properties":{"exclude":false}}]}'} headers: cache-control: [no-cache] - content-length: ['798'] + content-length: ['1804'] content-type: [application/json; charset=utf-8] - date: ['Tue, 28 Nov 2017 22:33:14 GMT'] + date: ['Mon, 11 Dec 2017 22:58:51 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] @@ -26,6 +26,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-resource-requests: ['599'] status: {code: 200, message: OK} - request: body: '{"properties": {"low_cpu_threshold": "20"}}' @@ -36,8 +37,8 @@ interactions: Connection: [keep-alive] Content-Length: ['43'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 @@ -45,13 +46,13 @@ interactions: body: {string: ''} headers: cache-control: [no-cache] - date: ['Tue, 28 Nov 2017 22:33:16 GMT'] + date: ['Mon, 11 Dec 2017 22:58:52 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-content-type-options: [nosniff] - x-ms-ratelimit-remaining-subscription-writes: ['1199'] + x-ms-ratelimit-remaining-subscription-resource-requests: ['199'] status: {code: 204, message: No Content} - request: body: null @@ -61,18 +62,18 @@ interactions: CommandName: [advisor configuration get] Connection: [keep-alive] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61","properties":{"low_cpu_threshold":"20","exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut","properties":{"exclude":false}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","properties":{"low_cpu_threshold":"20","exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf","properties":{"exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae","properties":{"exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot","properties":{"exclude":false}}]}'} headers: cache-control: [no-cache] - content-length: ['799'] + content-length: ['1805'] content-type: [application/json; charset=utf-8] - date: ['Tue, 28 Nov 2017 22:33:17 GMT'] + date: ['Mon, 11 Dec 2017 22:58:52 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] @@ -80,6 +81,7 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-resource-requests: ['599'] status: {code: 200, message: OK} - request: body: '{"properties": {"low_cpu_threshold": "5"}}' @@ -90,8 +92,8 @@ interactions: Connection: [keep-alive] Content-Length: ['42'] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 @@ -99,13 +101,13 @@ interactions: body: {string: ''} headers: cache-control: [no-cache] - date: ['Tue, 28 Nov 2017 22:33:18 GMT'] + date: ['Mon, 11 Dec 2017 22:58:53 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] strict-transport-security: [max-age=31536000; includeSubDomains] x-content-type-options: [nosniff] - x-ms-ratelimit-remaining-subscription-writes: ['1199'] + x-ms-ratelimit-remaining-subscription-resource-requests: ['199'] status: {code: 204, message: No Content} - request: body: null @@ -115,18 +117,18 @@ interactions: CommandName: [advisor configuration get] Connection: [keep-alive] Content-Type: [application/json; charset=utf-8] - User-Agent: [python/3.6.3 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.18 - msrest_azure/0.4.15 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] + User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.4 msrest/0.4.19 + msrest_azure/0.4.18 azure-mgmt-advisor/0.1.0 Azure-SDK-For-Python AZURECLI/2.0.22] accept-language: [en-US] method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations?api-version=2017-04-19 response: - body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61","properties":{"low_cpu_threshold":"5","exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut/providers/Microsoft.Advisor/configurations/70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut","type":"Microsoft.Advisor/Configurations","name":"70b0b95c-8a41-41c0-8e3f-3ed8351a2d61-cli_test_advisoralrv2rr3czuas4u272e5gq7sczyz5sk7dfnkp7mt5qgildyebpzr3ghy5ut","properties":{"exclude":false}}]}'} + body: {string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590","properties":{"low_cpu_threshold":"5","exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisor3tc7naqncit26etevdevprlutrwgwqzpjs6slm5rhn2r3cjgdtszuz6xydf","properties":{"exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisorlepjmsh25motlwqzm2mjudwlcscnfv7mrjnxggtmdez5hcx64k55mrrf4ae","properties":{"exclude":false}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot/providers/Microsoft.Advisor/configurations/0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot","type":"Microsoft.Advisor/Configurations","name":"0b1f6471-1bf0-4dda-aec3-cb9272f09590-cli_test_advisordqrw3oqr3dxuttaoix47gjmsy7wbe3xftynrokgje65kc7kuturgcr5d2ot","properties":{"exclude":false}}]}'} headers: cache-control: [no-cache] - content-length: ['798'] + content-length: ['1804'] content-type: [application/json; charset=utf-8] - date: ['Tue, 28 Nov 2017 22:33:19 GMT'] + date: ['Mon, 11 Dec 2017 22:58:53 GMT'] expires: ['-1'] pragma: [no-cache] server: [Microsoft-HTTPAPI/2.0] @@ -134,5 +136,6 @@ interactions: transfer-encoding: [chunked] vary: [Accept-Encoding] x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-subscription-resource-requests: ['599'] status: {code: 200, message: OK} version: 1 diff --git a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/test_advisor_commands.py b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/test_advisor_commands.py index 6f4a175487f..42f6a97d414 100644 --- a/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/test_advisor_commands.py +++ b/src/command_modules/azure-cli-advisor/azure/cli/command_modules/advisor/tests/test_advisor_commands.py @@ -44,12 +44,17 @@ def test_parse_recommendation_uri(self): class AzureAdvisorLiveScenarioTest(LiveScenarioTest): def test_list_disable_enable_recommendations(self): + self.cmd('advisor recommendation generate') output = self.cmd('advisor recommendation list').get_output_in_json() self.assertGreater(len(output), 1) output = self.cmd('advisor recommendation list --category cost').get_output_in_json() self.assertGreater(len(output), 0) - disableCmd = 'advisor recommendation disable --ids {} --days 1'.format(output[0]['id']) - enableCmd = 'advisor recommendation enable --ids {}'.format(output[0]['id']) + + self.kwargs.update({ + 'recommendation_id': output[0]['id'] + }) + disableCmd = 'advisor recommendation disable --ids {recommendation_id} --days 1' + enableCmd = 'advisor recommendation enable --ids {recommendation_id}' output = self.cmd(disableCmd).get_output_in_json() self.assertEqual(output[0]['ttl'], '1.00:00:00') self.cmd(enableCmd) @@ -79,14 +84,14 @@ def test_get_set_configurations_subscription(self): @ResourceGroupPreparer(name_prefix='cli_test_advisor') def test_get_set_configurations_resource_group(self, resource_group): - output = self.cmd('advisor configuration get --resource-group {}'.format(resource_group)).get_output_in_json() + output = self.cmd('advisor configuration get --resource-group {rg}').get_output_in_json() self.assertGreater(len(output), 0) - self.cmd('advisor configuration set --exclude --resource-group {}'.format(resource_group)) - output = self.cmd('advisor configuration get --resource-group {}'.format(resource_group)).get_output_in_json() + self.cmd('advisor configuration set --exclude --resource-group {rg}') + output = self.cmd('advisor configuration get --resource-group {rg}').get_output_in_json() self.assertGreater(len(output), 0) self.assertTrue(output['value'][0]['properties']['exclude']) - self.cmd('advisor configuration set --include --resource-group {}'.format(resource_group)) - output = self.cmd('advisor configuration get --resource-group {}'.format(resource_group)).get_output_in_json() + self.cmd('advisor configuration set --include --resource-group {rg}') + output = self.cmd('advisor configuration get --resource-group {rg}').get_output_in_json() self.assertGreater(len(output), 0) self.assertTrue(not output['value'][0]['properties']['exclude'])