-
Notifications
You must be signed in to change notification settings - Fork 3.3k
On-board Maps #6303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On-board Maps #6303
Changes from all commits
418b2a1
8bbcd51
18d9384
cb738db
b74cb79
409b03b
ed3ca01
81e4fb5
0d11a6d
87accc7
9e5051f
77a9f22
98d973e
5853331
4d930f8
d36abf9
b79cb10
75795e6
100df29
1fd7bef
1aee6b2
35976e7
e7784a1
f9ca47d
52b9dde
c0c8bb8
498ca9c
4176c07
c6c5c02
31f7a3a
d49f8ad
1f3d2c1
19b2fe9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .. :changelog: | ||
|
|
||
| Release History | ||
| =============== | ||
|
|
||
| 0.1.0 | ||
| +++++ | ||
| * Initial release |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include *.rst |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Microsoft Azure CLI 'maps' Command Module | ||
| ==================================================== | ||
|
|
||
| This package is for the 'maps' module. | ||
| i.e. 'az maps' | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import pkg_resources | ||
| pkg_resources.declare_namespace(__name__) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import pkg_resources | ||
| pkg_resources.declare_namespace(__name__) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import pkg_resources | ||
| pkg_resources.declare_namespace(__name__) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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.maps._help # pylint: disable=unused-import | ||
| from azure.cli.command_modules.maps._client_factory import cf_accounts | ||
|
|
||
|
|
||
| class MapsCommandsLoader(AzCommandsLoader): | ||
|
|
||
| def __init__(self, cli_ctx=None): | ||
| from azure.cli.core.commands import CliCommandType | ||
| custom_type = CliCommandType( | ||
| operations_tmpl='azure.cli.command_modules.maps.custom#{}', | ||
| client_factory=cf_accounts) | ||
| super(MapsCommandsLoader, self).__init__(cli_ctx=cli_ctx, | ||
| custom_command_type=custom_type) | ||
|
|
||
| def load_command_table(self, args): | ||
| from azure.cli.command_modules.maps.commands import load_command_table | ||
| load_command_table(self, args) | ||
| return self.command_table | ||
|
|
||
| def load_arguments(self, command): | ||
| from azure.cli.command_modules.maps._params import load_arguments | ||
| load_arguments(self, command) | ||
|
|
||
|
|
||
| COMMAND_LOADER_CLS = MapsCommandsLoader |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def cf_maps(cli_ctx, *_): | ||
| from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
| from azure.mgmt.maps import MapsManagementClient | ||
| return get_mgmt_service_client(cli_ctx, MapsManagementClient) | ||
|
|
||
|
|
||
| def cf_accounts(cli_ctx, *_): | ||
| return cf_maps(cli_ctx).accounts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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 | ||
|
|
||
| helps['maps'] = """ | ||
| type: group | ||
| short-summary: Manage Azure Maps. | ||
| """ | ||
|
|
||
| helps['maps account'] = """ | ||
| type: group | ||
| short-summary: Manage Azure Maps accounts. | ||
| """ | ||
|
|
||
| helps['maps account keys'] = """ | ||
| type: group | ||
| short-summary: Manage Azure Maps account keys. | ||
| """ | ||
|
|
||
| helps['maps account show'] = """ | ||
| type: command | ||
| short-summary: Show the details of a maps account. | ||
| """ | ||
|
|
||
| helps['maps account list'] = """ | ||
| type: command | ||
| short-summary: Show all maps accounts in a subscription or in a resource group. | ||
| """ | ||
|
|
||
| helps['maps account create'] = """ | ||
| type: command | ||
| short-summary: Create a maps account. | ||
| """ | ||
|
|
||
| helps['maps account update'] = """ | ||
| type: command | ||
| short-summary: Update the properties of a maps account. | ||
| """ | ||
|
|
||
| helps['maps account delete'] = """ | ||
| type: command | ||
| short-summary: Delete a maps account. | ||
| """ | ||
|
|
||
| helps['maps account keys list'] = """ | ||
| type: command | ||
| short-summary: List the keys to use with the Maps APIs. | ||
| long-summary: | | ||
| A key is used to authenticate and authorize access to the Maps REST APIs. Only one key is needed at a time; two are given to provide seamless key regeneration. | ||
| """ | ||
|
|
||
| helps['maps account keys renew'] = """ | ||
| type: command | ||
| short-summary: Renew either the primary or secondary key for use with the Maps APIs. | ||
| long-summary: | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewrite as |
||
| This command immediately invalidates old API keys. Only the renewed keys can be used to connect to maps. | ||
| """ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from knack.arguments import CLIArgumentType | ||
|
|
||
| from azure.cli.core.commands.parameters import ( | ||
| get_enum_type, | ||
| get_resource_name_completion_list, | ||
| resource_group_name_type, | ||
| tags_type) | ||
|
|
||
| from azure.mgmt.maps.models.maps_management_client_enums import KeyType | ||
|
|
||
|
|
||
| def load_arguments(self, _): | ||
| # Argument Definition | ||
| maps_name_type = CLIArgumentType(options_list=['--name', '-n'], | ||
| completer=get_resource_name_completion_list('Microsoft.Maps/accounts'), | ||
| help='The name of the maps account') | ||
|
|
||
| # Parameter Registration | ||
| with self.argument_context('maps') as c: | ||
| c.argument('resource_group_name', | ||
| arg_type=resource_group_name_type, | ||
| id_part='resource_group', | ||
| help='Resource group name') | ||
| c.argument('account_name', | ||
| id_part='name', | ||
| arg_type=maps_name_type) | ||
|
|
||
| with self.argument_context('maps account') as c: | ||
| c.argument('sku_name', | ||
| options_list=['--sku', '-s'], | ||
| help='The name of the SKU.', | ||
| arg_type=get_enum_type(['S0'])) | ||
| c.argument('tags', | ||
| arg_type=tags_type) | ||
|
|
||
| # Prevent --ids argument in keys with id_part=None | ||
| with self.argument_context('maps account keys') as c: | ||
| c.argument('account_name', | ||
| id_part=None, | ||
| arg_type=maps_name_type) | ||
|
|
||
| with self.argument_context('maps account keys renew') as c: | ||
| c.argument('key_type', | ||
| options_list=['--key'], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the help for this argument pulled from elsewhere?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This help is being pulled from the Azure Python SDK (Maps).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good to me. |
||
| arg_type=get_enum_type(KeyType)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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.commands import CliCommandType | ||
| from azure.cli.core.util import empty_on_404 | ||
| from azure.cli.command_modules.maps._client_factory import cf_accounts | ||
|
|
||
|
|
||
| def load_command_table(self, _): | ||
| mgmt_type = CliCommandType( | ||
| operations_tmpl='azure.mgmt.maps.operations.accounts_operations#AccountsOperations.{}', | ||
| client_factory=cf_accounts) | ||
|
|
||
| with self.command_group('maps account', mgmt_type) as g: | ||
| g.command('show', 'get', exception_handler=empty_on_404) | ||
| g.custom_command('list', 'list_accounts') | ||
| g.custom_command('create', 'create_account') | ||
| g.command('delete', 'delete') | ||
| g.generic_update_command('update', | ||
| getter_name='get', | ||
| setter_arg_name='maps_account_create_parameters', | ||
| custom_func_name='generic_update_account') | ||
|
|
||
| with self.command_group('maps account keys', mgmt_type) as g: | ||
| g.command('renew', 'regenerate_keys') | ||
| g.command('list', 'list_keys') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # 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 | ||
|
|
||
| from azure.mgmt.maps.models import ( | ||
| MapsAccountCreateParameters, | ||
| Sku) | ||
|
|
||
| ACCOUNT_LOCATION = 'global' | ||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| def create_account(client, resource_group_name, account_name, sku_name='S0', tags=None): | ||
| sku = Sku(name=sku_name) | ||
| maps_account_create_params = MapsAccountCreateParameters(location=ACCOUNT_LOCATION, sku=sku, tags=tags) | ||
| return client.create_or_update(resource_group_name, account_name, maps_account_create_params) | ||
|
|
||
|
|
||
| def list_accounts(client, resource_group_name=None): | ||
| # Retrieve accounts via subscription | ||
| if resource_group_name is None: | ||
| return client.list_by_subscription() | ||
| # Retrieve accounts via resource group | ||
| return client.list_by_resource_group(resource_group_name) | ||
|
|
||
|
|
||
| def generic_update_account(instance, sku_name=None, tags=None): | ||
| # Pre-populate with old instance | ||
| maps_account_create_params = MapsAccountCreateParameters(location=ACCOUNT_LOCATION, sku=instance.sku, | ||
| tags=instance.tags) | ||
| # Update fields with new parameter values | ||
| if sku_name: | ||
| maps_account_create_params.sku.name = sku_name | ||
| if tags: | ||
| maps_account_create_params.tags = tags | ||
| return maps_account_create_params |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import pkg_resources | ||
| pkg_resources.declare_namespace(__name__) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import pkg_resources | ||
| pkg_resources.declare_namespace(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the first sentence.
long-descriptionis always a supplement toshort-description.