{Rest} az rest: Add examples to --url-parameters (#13868)

* Add examples to --url-parameters

* Update doc/use_cli_effectively.md

Co-authored-by: Jiashuo Li <jiasli@microsoft.com>

* Update src/azure-cli/azure/cli/command_modules/util/_help.py

Co-authored-by: Jiashuo Li <jiasli@microsoft.com>

* Update src/azure-cli/azure/cli/command_modules/util/_params.py

Co-authored-by: Jiashuo Li <jiasli@microsoft.com>

* Fix anomalous-backslash-in-string

Co-authored-by: Jiashuo Li <jiasli@microsoft.com>
This commit is contained in:
Xing Zhou 2020-06-19 08:41:02 +08:00 коммит произвёл GitHub
Родитель c23670281c
Коммит eea8a3f6bd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -122,6 +122,8 @@ az rest --method PATCH
--body '{"web":{"redirectUris":["https://myapp.com"]}}'
```
When using `--url-parameters` for requests in the form of OData, please make sure to escape `$` in different environments: in `Bash`, escape `$` as `\$` and in `PowerShell`, escape `$` as `` `$``
## Quoting issues
This becomes an issue because when the command shell (Bash, Zsh, Windows Command Prompt, PowerShell, etc) parses the CLI command, it will interpret the quotes and spaces. Always refer to the documents when you are uncertain about the usage of a shell:

Просмотреть файл

@ -5,7 +5,7 @@
# --------------------------------------------------------------------------------------------
from knack.help_files import helps # pylint: disable=unused-import
# pylint: disable=line-too-long, too-many-lines
# pylint: disable=line-too-long, too-many-lines, anomalous-backslash-in-string
helps['rest'] = """
type: command
@ -31,6 +31,9 @@ examples:
- name: Create a public IP address from body.json file
text: >
az rest --method put --url https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}?api-version=2019-09-01 --body @body.json
- name: List the top three resources (Bash)
text: >
az rest --method get --url https://management.azure.com/subscriptions/{subscriptionId}/resources?api-version=2019-07-01 --url-parameters \\$top=3
"""
helps['version'] = """

Просмотреть файл

@ -21,7 +21,8 @@ def load_arguments(self, _):
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')
help='Query parameters in the URL. 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, '