Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
418b2a1
Introduce LocationBasedServices command_module
jp94 Feb 23, 2018
8bbcd51
Introduce test cases for LocationBasedServices command_module
jp94 Feb 23, 2018
18d9384
[Refactor] Renamed lbs to locationbasedservices
jp94 Feb 24, 2018
cb738db
[Refactor] Renamed lbs to locationbasedservices
jp94 Feb 24, 2018
b74cb79
[Legal] Add the Preview Terms agreement requirement
jp94 Feb 24, 2018
409b03b
[Test] Add more strict assertion rule for key validation.
jp94 Feb 26, 2018
ed3ca01
[Test] Add test for tags parameter
jp94 Feb 26, 2018
81e4fb5
[Test] Added an additional resource group.
jp94 Feb 26, 2018
0d11a6d
[Test] Init recordings
jp94 Feb 26, 2018
87accc7
Merge remote-tracking branch 'upstream/dev' into dev
jp94 Feb 26, 2018
9e5051f
[Pylint] Specify string format arguments as logging function parameters
jp94 Feb 26, 2018
77a9f22
[Refactor] Update description in _help to match the general template
jp94 Feb 27, 2018
98d973e
[Refactor] General template mismatch fix for 'key'
jp94 Feb 27, 2018
5853331
[Feature] Introduce search by ids
jp94 Feb 28, 2018
4d930f8
[Temporary] Throw an exception on 'account show' command, when nonexist
jp94 Feb 28, 2018
d36abf9
[Test] 'account show' on non-existent account should not return empty.
jp94 Feb 28, 2018
b79cb10
[Feature] Introduce update command
jp94 Mar 1, 2018
75795e6
[Test] Add test for update and search by id
jp94 Mar 1, 2018
100df29
Merge remote-tracking branch 'upstream/dev' into dev
jp94 Mar 20, 2018
1fd7bef
[Refactor] Rename generic client (sync with updated Swagger)
jp94 Mar 21, 2018
1aee6b2
[Refactor] Use default SDK's function
jp94 Mar 21, 2018
35976e7
[Refactor] Remove Preview Terms & docs in custom.py
jp94 Mar 21, 2018
e7784a1
[Maps] Rename LocationBasedServices to Maps
jp94 May 7, 2018
f9ca47d
[Maps] Use Maps SDK from LocationBasedServices SDK
jp94 May 7, 2018
52b9dde
[Maps] Update dependencies
jp94 May 7, 2018
c0c8bb8
[Maps] Resolving build error (doc_source_map)
jp94 May 7, 2018
498ca9c
Merge remote-tracking branch 'upstream/dev' into rename
jp94 May 8, 2018
4176c07
Merge remote-tracking branch 'upstream/dev' into rename
jp94 May 9, 2018
c6c5c02
[Maps] Resolving PR issues.
jp94 May 9, 2018
31f7a3a
[Maps] Revise help text
jp94 May 9, 2018
d49f8ad
[Maps] Adding back help docs for maps account
jp94 May 9, 2018
1f3d2c1
Merge remote-tracking branch 'upstream/dev' into rename
jp94 May 12, 2018
19b2fe9
[Load Test] replace sql with servicefabric
jp94 May 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/sphinx/azhelpgen/doc_source_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"iot": "src/command_modules/azure-cli-iot/azure/cli/command_modules/iot/_help.py",
"keyvault": "src/command_modules/azure-cli-keyvault/azure/cli/command_modules/keyvault/_help.py",
"lab": "src/command_modules/azure-cli-lab/azure/cli/command_modules/lab/_help.py",
"maps": "src/command_modules/azure-cli-maps/azure/cli/command_modules/maps/_help.py",
"monitor": "src/command_modules/azure-cli-monitor/azure/cli/command_modules/monitor/_help.py",
"network": "src/command_modules/azure-cli-network/azure/cli/command_modules/network/_help.py",
"policy": "src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py",
Expand Down
8 changes: 8 additions & 0 deletions src/command_modules/azure-cli-maps/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

Release History
===============

0.1.0
+++++
* Initial release
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-maps/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include *.rst
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-maps/README.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'


4 changes: 4 additions & 0 deletions src/command_modules/azure-cli-maps/__init__.py
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.
# --------------------------------------------------------------------------------------------
6 changes: 6 additions & 0 deletions src/command_modules/azure-cli-maps/azure/__init__.py
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__)
6 changes: 6 additions & 0 deletions src/command_modules/azure-cli-maps/azure/cli/__init__.py
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: |
Copy link
Contributor

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-description is always a supplement to short-description.

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: |
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

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'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the help for this argument pulled from elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help is being pulled from the Azure Python SDK (Maps).

Command
    az maps account keys renew: Renew either the primary or secondary key for use with the maps
    APIs.
        This command immediately invalidates old API keys. Only the renewed keys can be used to
        connect to maps.

Arguments
    --key     [Required]: Whether the operation refers to the primary or secondary key.  Allowed
                          values: primary, secondary.
    --name -n [Required]: The name of the maps account.
    --resource-group -g : Resource group name.

Copy link
Contributor

Choose a reason for hiding this comment

The 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__)
Loading