diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 60d0b455659..ef5db6645e1 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -42,3 +42,4 @@ /src/azure-cli/azure/cli/command_modules/apim/ @kevinhillinger @jonlester /src/azure-cli/azure/cli/command_modules/iot/ @digimaun /src/azure-cli/azure/cli/command_modules/aro/ @mjudeikis @jim-minter +/src/azure-cli/azure/cli/command_modules/util/ @jiasli @Juliehzl @zhoxing-ms diff --git a/doc/sphinx/azhelpgen/doc_source_map.json b/doc/sphinx/azhelpgen/doc_source_map.json index 73872c7aa06..7d761b235c9 100644 --- a/doc/sphinx/azhelpgen/doc_source_map.json +++ b/doc/sphinx/azhelpgen/doc_source_map.json @@ -72,5 +72,6 @@ "netappfiles": "src/azure-cli/azure/cli/command_modules/netappfiles/_help.py", "managedservices": "src/azure-cli/azure/cli/command_modules/managedservices/_help.py", "apim": "src/azure-cli/azure/cli/command_modules/apim/_help.py", - "aro": "src/azure-cli/azure/cli/command_modules/aro/_help.py" + "aro": "src/azure-cli/azure/cli/command_modules/aro/_help.py", + "util": "src/azure-cli/azure/cli/command_modules/util/_help.py" } diff --git a/scripts/ci/credscan/CredScanSuppressions.json b/scripts/ci/credscan/CredScanSuppressions.json index e907d344d3b..cc0ab662b29 100644 --- a/scripts/ci/credscan/CredScanSuppressions.json +++ b/scripts/ci/credscan/CredScanSuppressions.json @@ -379,6 +379,12 @@ { "placeholder": "Pass123!@#", "_justification": "hard-code dummy password in test_sf_cluster.py" + }, + { + "file": [ + "src/azure-cli/azure/cli/command_modules/util/tests/latest/recordings/test_rest.yaml" + ], + "_justification": "one-time sas token" } ] } diff --git a/src/azure-cli/azure/cli/command_modules/resource/_help.py b/src/azure-cli/azure/cli/command_modules/resource/_help.py index 53ca4960b80..5a07fe907d6 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_help.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_help.py @@ -1916,33 +1916,6 @@ crafted: true """ -helps['rest'] = """ -type: command -short-summary: Invoke a custom request. -long-summary: > - This command automatically authenticates using the credential logged in: If Authorization header is not set, it - attaches header `Authorization: Bearer `, where `` is retrieved from AAD. The target resource of the - token is derived from --url if --url starts with an endpoint from `az cloud show --query endpoints`. You may also - use --resource for a custom resource. - - If Content-Type header is not set and --body is a valid JSON string, Content-Type header will default to - application/json. -examples: - - name: Get Audit log through Microsoft Graph - text: > - az rest --method get --uri https://graph.microsoft.com/beta/auditLogs/directoryAudits - - name: Update a Azure Active Directory Graph User's display name - text: > - az rest --method patch --uri "https://graph.microsoft.com/v1.0/users/johndoe@azuresdkteam.onmicrosoft.com" --body "{\\"displayName\\": \\"jondoe2\\"}" - - name: Get a virtual machine - text: > - az rest --method get --uri /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2019-03-01 - - name: Create a public IP address from body.json file - text: > - az rest --method put --uri https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}?api-version=2019-09-01 --body @body.json -""" - - helps['tag'] = """ type: group short-summary: Manage resource tags. @@ -1974,8 +1947,3 @@ text: > az tag delete --name MyTag """ - -helps['version'] = """ -type: command -short-summary: Show the versions of Azure CLI modules and extensions in JSON format by default or format configured by --output -""" diff --git a/src/azure-cli/azure/cli/command_modules/resource/_params.py b/src/azure-cli/azure/cli/command_modules/resource/_params.py index 0dbc20492d7..ed8b852ac6d 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_params.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_params.py @@ -454,20 +454,3 @@ def load_arguments(self, _): with self.argument_context('account management-group update') as c: c.argument('display_name', options_list=['--display-name', '-d']) c.argument('parent_id', options_list=['--parent', '-p']) - - with self.argument_context('rest') as c: - c.argument('method', options_list=['--method', '-m'], arg_type=get_enum_type(['head', 'get', 'put', 'post', 'delete', 'options', 'patch'], default='get'), - help='HTTP request method') - c.argument('uri', options_list=['--url', '--uri', '-u'], help='Request URL. If it doesn\'t start with a host, ' - 'CLI assumes it as an Azure resource ID and prefixes it with the ARM endpoint of the current ' - 'cloud shown by `az cloud show --query endpoints.resourceManager`. Common token {subscriptionId} ' - 'will be replaced with the current subscription ID specified by `az account set`') - c.argument('headers', nargs='+', help="Space-separated headers in KEY=VALUE format or JSON string. Use @{file} to load from a file") - c.argument('uri_parameters', nargs='+', help='Space-separated queries in KEY=VALUE format or JSON string. Use @{file} to load from a file') - c.argument('skip_authorization_header', action='store_true', help='Do not auto-append Authorization header') - c.argument('body', options_list=['--body', '-b'], help='Request body. Use @{file} to load from a file. For quoting issues in different terminals, see https://github.com/Azure/azure-cli/blob/dev/doc/use_cli_effectively.md#quoting-issues') - c.argument('output_file', help='save response payload to a file') - c.argument('resource', help='Resource url for which CLI should acquire a token from AAD in order to access ' - 'the service. The token will be placed in the Authorization header. By default, ' - 'CLI can figure this out based on --url argument, unless you use ones not in the list ' - 'of "az cloud show --query endpoints"') diff --git a/src/azure-cli/azure/cli/command_modules/resource/commands.py b/src/azure-cli/azure/cli/command_modules/resource/commands.py index 289ad9db065..bfafa7fa58b 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/commands.py +++ b/src/azure-cli/azure/cli/command_modules/resource/commands.py @@ -409,9 +409,3 @@ def load_command_table(self, _): with self.command_group('account management-group subscription', resource_managementgroups_subscriptions_sdk, client_factory=cf_management_group_subscriptions) as g: g.custom_command('add', 'cli_managementgroups_subscription_add') g.custom_command('remove', 'cli_managementgroups_subscription_remove') - - with self.command_group('') as g: - g.custom_command('rest', 'rest_call') - - with self.command_group('') as g: - g.custom_command('version', 'show_version') diff --git a/src/azure-cli/azure/cli/command_modules/resource/custom.py b/src/azure-cli/azure/cli/command_modules/resource/custom.py index 9d8fd7dd5c0..4e0156d1356 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/custom.py @@ -2450,26 +2450,6 @@ def list_resource_links(cmd, scope=None, filter_string=None): # endregion -def rest_call(cmd, uri, method=None, headers=None, uri_parameters=None, - body=None, skip_authorization_header=False, resource=None, output_file=None): - from azure.cli.core.util import send_raw_request - r = send_raw_request(cmd.cli_ctx, method, uri, headers, uri_parameters, body, - skip_authorization_header, resource, output_file) - if not output_file and r.content: - try: - return r.json() - except ValueError: - logger.warning('Not a json response, outputting to stdout. For binary data ' - 'suggest use "--output-file" to write to a file') - print(r.text) - - -def show_version(cmd): - from azure.cli.core.util import get_az_version_json - versions = get_az_version_json() - return versions - - class _ResourceUtils(object): # pylint: disable=too-many-instance-attributes def __init__(self, cli_ctx, resource_group_name=None, resource_provider_namespace=None, diff --git a/src/azure-cli/azure/cli/command_modules/util/__init__.py b/src/azure-cli/azure/cli/command_modules/util/__init__.py new file mode 100644 index 00000000000..cf0dce49a4a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/util/__init__.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------------------------- +# 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 +import azure.cli.command_modules.util._help # pylint: disable=unused-import + + +class UtilCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + util_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.util.custom#{}') + super(UtilCommandsLoader, self).__init__(cli_ctx=cli_ctx, custom_command_type=util_custom) + + def load_command_table(self, args): + from azure.cli.command_modules.util.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azure.cli.command_modules.util._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = UtilCommandsLoader diff --git a/src/azure-cli/azure/cli/command_modules/util/_help.py b/src/azure-cli/azure/cli/command_modules/util/_help.py new file mode 100644 index 00000000000..fecd0525057 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/util/_help.py @@ -0,0 +1,39 @@ +# 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. +# -------------------------------------------------------------------------------------------- + +from knack.help_files import helps # pylint: disable=unused-import +# pylint: disable=line-too-long, too-many-lines + +helps['rest'] = """ +type: command +short-summary: Invoke a custom request. +long-summary: > + This command automatically authenticates using the credential logged in: If Authorization header is not set, it + attaches header `Authorization: Bearer `, where `` is retrieved from AAD. The target resource of the + token is derived from --url if --url starts with an endpoint from `az cloud show --query endpoints`. You may also + use --resource for a custom resource. + + If Content-Type header is not set and --body is a valid JSON string, Content-Type header will default to + application/json. +examples: + - name: Get Audit log through Microsoft Graph + text: > + az rest --method get --uri https://graph.microsoft.com/beta/auditLogs/directoryAudits + - name: Update a Azure Active Directory Graph User's display name + text: > + az rest --method patch --uri "https://graph.microsoft.com/v1.0/users/johndoe@azuresdkteam.onmicrosoft.com" --body "{\\"displayName\\": \\"jondoe2\\"}" + - name: Get a virtual machine + text: > + az rest --method get --uri /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2019-03-01 + - name: Create a public IP address from body.json file + text: > + az rest --method put --uri https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}?api-version=2019-09-01 --body @body.json +""" + +helps['version'] = """ +type: command +short-summary: Show the versions of Azure CLI modules and extensions in JSON format by default or format configured by --output +""" diff --git a/src/azure-cli/azure/cli/command_modules/util/_params.py b/src/azure-cli/azure/cli/command_modules/util/_params.py new file mode 100644 index 00000000000..32c97a649d1 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/util/_params.py @@ -0,0 +1,34 @@ +# -------------------------------------------------------------------------------------------- +# 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 +def load_arguments(self, _): + from azure.cli.core.commands.parameters import get_enum_type + + with self.argument_context('rest') as c: + c.argument('method', options_list=['--method', '-m'], + arg_type=get_enum_type(['head', 'get', 'put', 'post', 'delete', 'options', 'patch'], default='get'), + help='HTTP request method') + c.argument('url', options_list=['--url', '--uri', '-u'], + help='Request URL. If it doesn\'t start with a host, ' + 'CLI assumes it as an Azure resource ID and prefixes it with the ARM endpoint of the current ' + 'cloud shown by `az cloud show --query endpoints.resourceManager`. Common token ' + '{subscriptionId} will be replaced with the current subscription ID specified by `az account ' + 'set`') + c.argument('headers', nargs='+', + help="Space-separated headers in KEY=VALUE format or JSON string. Use @{file} to load from a file") + c.argument('uri_parameters', options_list=['--uri-parameters', '--url-parameters'], nargs='+', + help='Space-separated queries in KEY=VALUE format or JSON string. Use @{file} to load from a file') + c.argument('skip_authorization_header', action='store_true', help='Do not auto-append Authorization header') + c.argument('body', options_list=['--body', '-b'], + help='Request body. Use @{file} to load from a file. For quoting issues in different terminals, ' + 'see https://github.com/Azure/azure-cli/blob/dev/doc/use_cli_effectively.md#quoting-issues') + c.argument('output_file', help='save response payload to a file') + c.argument('resource', + help='Resource url for which CLI should acquire a token from AAD in order to access ' + 'the service. The token will be placed in the Authorization header. By default, ' + 'CLI can figure this out based on --url argument, unless you use ones not in the list ' + 'of "az cloud show --query endpoints"') diff --git a/src/azure-cli/azure/cli/command_modules/util/commands.py b/src/azure-cli/azure/cli/command_modules/util/commands.py new file mode 100644 index 00000000000..cf4ea6ac7d4 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/util/commands.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def load_command_table(self, _): + + with self.command_group('') as g: + g.custom_command('rest', 'rest_call') + + with self.command_group('') as g: + g.custom_command('version', 'show_version') diff --git a/src/azure-cli/azure/cli/command_modules/util/custom.py b/src/azure-cli/azure/cli/command_modules/util/custom.py new file mode 100644 index 00000000000..8051264ef11 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/util/custom.py @@ -0,0 +1,29 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from knack.log import get_logger + +logger = get_logger(__name__) + + +def rest_call(cmd, url, method=None, headers=None, uri_parameters=None, + body=None, skip_authorization_header=False, resource=None, output_file=None): + from azure.cli.core.util import send_raw_request + r = send_raw_request(cmd.cli_ctx, method, url, headers, uri_parameters, body, + skip_authorization_header, resource, output_file) + if not output_file and r.content: + try: + return r.json() + except ValueError: + logger.warning('Not a json response, outputting to stdout. For binary data ' + 'suggest use "--output-file" to write to a file') + print(r.text) + return None + + +def show_version(cmd): # pylint: disable=unused-argument + from azure.cli.core.util import get_az_version_json + versions = get_az_version_json() + return versions diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_rest.yaml b/src/azure-cli/azure/cli/command_modules/util/tests/latest/recordings/test_rest.yaml similarity index 86% rename from src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_rest.yaml rename to src/azure-cli/azure/cli/command_modules/util/tests/latest/recordings/test_rest.yaml index 9f9ecaf0910..571c8b6bfe9 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_rest.yaml +++ b/src/azure-cli/azure/cli/command_modules/util/tests/latest/recordings/test_rest.yaml @@ -19,7 +19,7 @@ interactions: ParameterSetName: - -m -u -b User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: PUT uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002?api-version=2019-06-01 response: @@ -33,11 +33,11 @@ interactions: content-type: - text/plain; charset=utf-8 date: - - Thu, 19 Mar 2020 10:48:08 GMT + - Tue, 02 Jun 2020 05:07:05 GMT expires: - '-1' location: - - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/eastus/asyncoperations/dab7b7f8-200d-464a-a10a-e7cdf3217ece?monitor=true&api-version=2019-06-01 + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/eastus/asyncoperations/82259b35-7f4d-449b-9a92-0221fa63f7a2?monitor=true&api-version=2019-06-01 pragma: - no-cache server: @@ -47,7 +47,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1198' + - '1199' status: code: 202 message: Accepted @@ -65,12 +65,12 @@ interactions: ParameterSetName: - -m -u User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002?api-version=2019-06-01 response: body: - string: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002","name":"tmpst000002","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"privateEndpointConnections":[],"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-03-19T10:48:09.3362917Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-03-19T10:48:09.3362917Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"ResolvingDns","creationTime":"2020-03-19T10:48:09.2581552Z","primaryEndpoints":{"blob":"https://tmpst000002.blob.core.windows.net/","queue":"https://tmpst000002.queue.core.windows.net/","table":"https://tmpst000002.table.core.windows.net/","file":"https://tmpst000002.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}' + string: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002","name":"tmpst000002","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"privateEndpointConnections":[],"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-06-02T05:07:05.9645742Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-06-02T05:07:05.9645742Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"ResolvingDns","creationTime":"2020-06-02T05:07:05.8551744Z","primaryEndpoints":{"blob":"https://tmpst000002.blob.core.windows.net/","queue":"https://tmpst000002.queue.core.windows.net/","table":"https://tmpst000002.table.core.windows.net/","file":"https://tmpst000002.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}' headers: cache-control: - no-cache @@ -79,7 +79,7 @@ interactions: content-type: - application/json date: - - Thu, 19 Mar 2020 10:48:15 GMT + - Tue, 02 Jun 2020 05:07:12 GMT expires: - '-1' pragma: @@ -111,12 +111,12 @@ interactions: ParameterSetName: - -m -u User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002?api-version=2019-06-01 response: body: - string: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002","name":"tmpst000002","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"privateEndpointConnections":[],"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-03-19T10:48:09.3362917Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-03-19T10:48:09.3362917Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"ResolvingDns","creationTime":"2020-03-19T10:48:09.2581552Z","primaryEndpoints":{"blob":"https://tmpst000002.blob.core.windows.net/","queue":"https://tmpst000002.queue.core.windows.net/","table":"https://tmpst000002.table.core.windows.net/","file":"https://tmpst000002.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}' + string: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002","name":"tmpst000002","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"privateEndpointConnections":[],"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-06-02T05:07:05.9645742Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-06-02T05:07:05.9645742Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"ResolvingDns","creationTime":"2020-06-02T05:07:05.8551744Z","primaryEndpoints":{"blob":"https://tmpst000002.blob.core.windows.net/","queue":"https://tmpst000002.queue.core.windows.net/","table":"https://tmpst000002.table.core.windows.net/","file":"https://tmpst000002.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}' headers: cache-control: - no-cache @@ -125,7 +125,7 @@ interactions: content-type: - application/json date: - - Thu, 19 Mar 2020 10:48:22 GMT + - Tue, 02 Jun 2020 05:07:18 GMT expires: - '-1' pragma: @@ -157,12 +157,12 @@ interactions: ParameterSetName: - -m -u User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002?api-version=2019-06-01 response: body: - string: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002","name":"tmpst000002","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"privateEndpointConnections":[],"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-03-19T10:48:09.3362917Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-03-19T10:48:09.3362917Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"Succeeded","creationTime":"2020-03-19T10:48:09.2581552Z","primaryEndpoints":{"blob":"https://tmpst000002.blob.core.windows.net/","queue":"https://tmpst000002.queue.core.windows.net/","table":"https://tmpst000002.table.core.windows.net/","file":"https://tmpst000002.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}' + string: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002","name":"tmpst000002","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"privateEndpointConnections":[],"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-06-02T05:07:05.9645742Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2020-06-02T05:07:05.9645742Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"Succeeded","creationTime":"2020-06-02T05:07:05.8551744Z","primaryEndpoints":{"blob":"https://tmpst000002.blob.core.windows.net/","queue":"https://tmpst000002.queue.core.windows.net/","table":"https://tmpst000002.table.core.windows.net/","file":"https://tmpst000002.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}' headers: cache-control: - no-cache @@ -171,7 +171,7 @@ interactions: content-type: - application/json date: - - Thu, 19 Mar 2020 10:48:28 GMT + - Tue, 02 Jun 2020 05:07:24 GMT expires: - '-1' pragma: @@ -210,21 +210,21 @@ interactions: ParameterSetName: - -m -u -b User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: POST uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002/ListAccountSas?api-version=2019-06-01 response: body: - string: '{"accountSasToken":"sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D"}' + string: '{"accountSasToken":"sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D"}' headers: cache-control: - no-cache content-length: - - '197' + - '199' content-type: - application/json date: - - Thu, 19 Mar 2020 10:48:30 GMT + - Tue, 02 Jun 2020 05:07:25 GMT expires: - '-1' pragma: @@ -240,7 +240,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1197' + - '1199' status: code: 200 message: OK @@ -260,9 +260,9 @@ interactions: ParameterSetName: - -m -u --skip-authorization-header User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: PUT - uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D + uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D response: body: string: '' @@ -270,11 +270,11 @@ interactions: content-length: - '0' date: - - Thu, 19 Mar 2020 10:48:32 GMT + - Tue, 02 Jun 2020 05:07:26 GMT etag: - - '"0x8D7CBF311734FC6"' + - '"0x8D806B2D82D65CE"' last-modified: - - Thu, 19 Mar 2020 10:48:32 GMT + - Tue, 02 Jun 2020 05:07:27 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -296,9 +296,9 @@ interactions: ParameterSetName: - -m -u --skip-authorization-header User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: HEAD - uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D + uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D response: body: string: '' @@ -306,11 +306,11 @@ interactions: content-length: - '0' date: - - Thu, 19 Mar 2020 10:48:33 GMT + - Tue, 02 Jun 2020 05:07:28 GMT etag: - - '"0x8D7CBF311734FC6"' + - '"0x8D806B2D82D65CE"' last-modified: - - Thu, 19 Mar 2020 10:48:32 GMT + - Tue, 02 Jun 2020 05:07:27 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-lease-state: @@ -340,11 +340,11 @@ interactions: ParameterSetName: - -m -u --headers --skip-authorization-header --body User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 x-ms-blob-type: - BlockBlob method: PUT - uri: https://tmpst000002.blob.core.windows.net/mycontainer/myblob?sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D + uri: https://tmpst000002.blob.core.windows.net/mycontainer/myblob?sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D response: body: string: '' @@ -354,11 +354,11 @@ interactions: content-md5: - XrY7u+Ae7tCTyyK7j1rNww== date: - - Thu, 19 Mar 2020 10:48:35 GMT + - Tue, 02 Jun 2020 05:07:29 GMT etag: - - '"0x8D7CBF313627243"' + - '"0x8D806B2D9DDCE11"' last-modified: - - Thu, 19 Mar 2020 10:48:35 GMT + - Tue, 02 Jun 2020 05:07:30 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -380,9 +380,9 @@ interactions: ParameterSetName: - -m -u --skip-authorization-header User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: GET - uri: https://tmpst000002.blob.core.windows.net/mycontainer/myblob?sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D + uri: https://tmpst000002.blob.core.windows.net/mycontainer/myblob?sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D response: body: string: hello world @@ -396,11 +396,11 @@ interactions: content-type: - text/plain; charset=UTF-8 date: - - Thu, 19 Mar 2020 10:48:37 GMT + - Tue, 02 Jun 2020 05:07:30 GMT etag: - - '"0x8D7CBF313627243"' + - '"0x8D806B2D9DDCE11"' last-modified: - - Thu, 19 Mar 2020 10:48:35 GMT + - Tue, 02 Jun 2020 05:07:30 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-blob-type: @@ -428,14 +428,14 @@ interactions: ParameterSetName: - -m -u --skip-authorization-header User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: GET - uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&comp=list&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D + uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&comp=list&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D response: body: string: "\uFEFFmyblobThu, - 19 Mar 2020 10:48:35 GMT0x8D7CBF31362724311text/plain; + ServiceEndpoint=\"https://tmpst000002.blob.core.windows.net/\" ContainerName=\"mycontainer\">myblobTue, + 02 Jun 2020 05:07:30 GMT0x8D806B2D9DDCE1111text/plain; charset=UTF-8XrY7u+Ae7tCTyyK7j1rNww==BlockBlobunlockedavailable" @@ -443,7 +443,7 @@ interactions: content-type: - application/xml date: - - Thu, 19 Mar 2020 10:48:39 GMT + - Tue, 02 Jun 2020 05:07:32 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 transfer-encoding: @@ -469,9 +469,9 @@ interactions: ParameterSetName: - -m -u --skip-authorization-header User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: DELETE - uri: https://tmpst000002.blob.core.windows.net/mycontainer/myblob?sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D + uri: https://tmpst000002.blob.core.windows.net/mycontainer/myblob?sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D response: body: string: '' @@ -479,7 +479,7 @@ interactions: content-length: - '0' date: - - Thu, 19 Mar 2020 10:48:40 GMT + - Tue, 02 Jun 2020 05:07:33 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -503,9 +503,9 @@ interactions: ParameterSetName: - -m -u --skip-authorization-header User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: DELETE - uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=VUQT3MtZf6SyFl9XT0OINA5crfT0e1eQlMMSVMUmFsE%3D + uri: https://tmpst000002.blob.core.windows.net/mycontainer?restype=container&sv=2015-04-05&ss=b&srt=sco&sp=rwdlacu&st=2017-05-24T10%3A42%3A03.1567373Z&se=2030-05-24T11%3A42%3A03.1567373Z&spr=https,http&sig=bBKwGxVLzSgkr1KhDnTiMnf%2FuP9b9KgEU0F5pbwh9gI%3D response: body: string: '' @@ -513,7 +513,7 @@ interactions: content-length: - '0' date: - - Thu, 19 Mar 2020 10:48:42 GMT + - Tue, 02 Jun 2020 05:07:35 GMT server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 x-ms-version: @@ -537,7 +537,7 @@ interactions: ParameterSetName: - -m -u User-Agent: - - AZURECLI/2.2.0 + - AZURECLI/2.7.0 method: DELETE uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_rest000001/providers/Microsoft.Storage/storageAccounts/tmpst000002?api-version=2019-06-01 response: @@ -551,7 +551,7 @@ interactions: content-type: - text/plain; charset=utf-8 date: - - Thu, 19 Mar 2020 10:48:48 GMT + - Tue, 02 Jun 2020 05:07:40 GMT expires: - '-1' pragma: diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/rest_storage_account_create_body.json b/src/azure-cli/azure/cli/command_modules/util/tests/latest/rest_storage_account_create_body.json similarity index 100% rename from src/azure-cli/azure/cli/command_modules/resource/tests/latest/rest_storage_account_create_body.json rename to src/azure-cli/azure/cli/command_modules/util/tests/latest/rest_storage_account_create_body.json diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/rest_storage_account_sas_body.json b/src/azure-cli/azure/cli/command_modules/util/tests/latest/rest_storage_account_sas_body.json similarity index 100% rename from src/azure-cli/azure/cli/command_modules/resource/tests/latest/rest_storage_account_sas_body.json rename to src/azure-cli/azure/cli/command_modules/util/tests/latest/rest_storage_account_sas_body.json diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_rest.py b/src/azure-cli/azure/cli/command_modules/util/tests/latest/test_rest.py similarity index 100% rename from src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_rest.py rename to src/azure-cli/azure/cli/command_modules/util/tests/latest/test_rest.py