Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 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
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
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 'location based services' Command Module
====================================================

This package is for the 'location based services' module.
i.e. 'az locationbasedservices'


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.locationbasedservices._help # pylint: disable=unused-import
from azure.cli.command_modules.locationbasedservices._client_factory import cf_accounts


class LocationBasedServicesCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
custom_type = CliCommandType(
operations_tmpl='azure.cli.command_modules.locationbasedservices.custom#{}',
client_factory=cf_accounts)
super(LocationBasedServicesCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=custom_type)

def load_command_table(self, args):
from azure.cli.command_modules.locationbasedservices.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
from azure.cli.command_modules.locationbasedservices._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = LocationBasedServicesCommandsLoader
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_locationbasedservices(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.mgmt.locationbasedservices import LocationBasedServicesManagementClient
return get_mgmt_service_client(cli_ctx, LocationBasedServicesManagementClient)


def cf_accounts(cli_ctx, *_):
return cf_locationbasedservices(cli_ctx).accounts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# --------------------------------------------------------------------------------------------
# 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['locationbasedservices'] = """
type: group
short-summary: Manage Azure Location Based Services accounts.
"""

helps['locationbasedservices account'] = """
type: group
short-summary: Manage Azure Location Based Services accounts.
"""

helps['locationbasedservices account keys'] = """
type: group
short-summary: Manage Azure Location Based Services account keys.
"""

helps['locationbasedservices account show'] = """
type: command
short-summary: Show the details of a Location Based Services account.
"""

helps['locationbasedservices account list'] = """
type: command
short-summary: Show all Location Based Services accounts in a Subscription or in a Resource Group.
"""

helps['locationbasedservices account create'] = """
type: command
short-summary: Create a Location Based Services account.
long-summary: |
Create a Location Based Services account. A Location Based Services account holds the keys which allow access to the Location Based Services REST APIs.
"""

helps['locationbasedservices account update'] = """
type: command
short-summary: Update the properties of a Location Based Services account.
"""

helps['locationbasedservices account delete'] = """
type: command
short-summary: Delete a Location Based Services account.
"""

helps['locationbasedservices account keys list'] = """
type: command
short-summary: List the keys to use with the Location Based Services APIs.
long-summary: |
List the keys to use with the Location Based Services APIs. A key is used to authenticate and authorize access to the Location Based Services REST APIs. Only one key is needed at a time; two are given to provide seamless key regeneration.
"""

helps['locationbasedservices account keys renew'] = """
type: command
short-summary: Renew either the primary or secondary key for use with the Location Based Services APIs.
long-summary: |
Renew either the primary or secondary key for use with the Location Based Services APIs. The old key will stop working immediately.
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# --------------------------------------------------------------------------------------------
# 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.cli.command_modules.locationbasedservices.validators import validate_account_name
from azure.mgmt.locationbasedservices.models.location_based_services_management_client_enums import KeyType


def load_arguments(self, _):
# Argument Definition
locationbasedservices_name_type = CLIArgumentType(options_list=['--name', '-n'],
completer=get_resource_name_completion_list(
'Microsoft.LocationBasedServices/accounts'),
help='The name of the Location Based Services Account',
validator=validate_account_name)

# Parameter Registration
with self.argument_context('locationbasedservices') 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=locationbasedservices_name_type)

with self.argument_context('locationbasedservices account') as c:
c.argument('sku_name',
options_list=['--sku', '-s'],
help='The name of the SKU, in standard format (such as S0).',
arg_type=get_enum_type(['S0']),
required=False)
c.argument('tags',
arg_type=tags_type)

# Prevent --ids argument in keys with id_part=None
with self.argument_context('locationbasedservices account keys') as c:
c.argument('account_name',
id_part=None,
arg_type=locationbasedservices_name_type)

with self.argument_context('locationbasedservices account keys renew') as c:
c.argument('key_type',
options_list=['--key'],
arg_type=get_enum_type(KeyType))
Original file line number Diff line number Diff line change
@@ -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.commands import CliCommandType
from azure.cli.command_modules.locationbasedservices._client_factory import cf_accounts


def load_command_table(self, _):
mgmt_type = CliCommandType(
operations_tmpl='azure.mgmt.locationbasedservices.operations.accounts_operations#AccountsOperations.{}',
client_factory=cf_accounts)

with self.command_group('locationbasedservices account', mgmt_type) as g:
g.command('show', 'get')
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='location_based_services_account_create_parameters',
custom_func_name='generic_update_account')

with self.command_group('locationbasedservices 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,41 @@
# --------------------------------------------------------------------------------------------
# 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.locationbasedservices.models import (
LocationBasedServicesAccountCreateParameters,
Sku)

ACCOUNT_LOCATION = 'global'

logger = get_logger(__name__)


# pylint: disable=line-too-long
def create_account(client, resource_group_name, account_name, sku_name='S0', tags=None):
sku = Sku(sku_name)
lbs_account_create_params = LocationBasedServicesAccountCreateParameters(ACCOUNT_LOCATION, sku, tags)
return client.create_or_update(resource_group_name, account_name, lbs_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
lbs_account_create_params = LocationBasedServicesAccountCreateParameters(ACCOUNT_LOCATION, instance.sku,
instance.tags)
# Update fields with new parameter values
if sku_name:
lbs_account_create_params.sku.name = sku_name
if tags:
lbs_account_create_params.tags = tags
return lbs_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