Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
[Refactor] Remove Preview Terms & docs in custom.py
  • Loading branch information
jp94 committed Mar 21, 2018
commit 35976e7f515491980b8a37dc06b6ccb6fdde0c5a
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ def load_arguments(self, _):
c.argument('tags',
arg_type=tags_type)

with self.argument_context('locationbasedservices account create') as c:
c.argument('agree',
options_list=['--agree-to-the-preview-terms'],
help='You agree to the Preview Terms. Ignore prompt for confirmation.',
action='store_true')

with self.argument_context('locationbasedservices account update') as c:
c.ignore('agree')

# Prevent --ids argument in keys with id_part=None
with self.argument_context('locationbasedservices account keys') as c:
c.argument('account_name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ def load_command_table(self, _):
mgmt_type = CliCommandType(
operations_tmpl='azure.mgmt.locationbasedservices.operations.accounts_operations#AccountsOperations.{}',
client_factory=cf_accounts)
custom_type = CliCommandType(
operations_tmpl='azure.cli.command_modules.locationbasedservices.custom#{}')

with self.command_group('locationbasedservices account', mgmt_type) as g:
g.command('show', 'get')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# --------------------------------------------------------------------------------------------

from knack.log import get_logger
from knack.prompting import prompt_y_n
from knack.util import CLIError

from azure.mgmt.locationbasedservices.models import (
LocationBasedServicesAccountCreateParameters,
Expand All @@ -17,65 +15,13 @@


# pylint: disable=line-too-long
def create_account(client, resource_group_name, account_name, sku_name='S0', tags=None, agree=None):
"""Create a Location Based Services Account. A Location Based
Services Account holds the keys which allow access to the Location
Based Services REST APIs.

:param resource_group_name: The name of the Azure Resource Group.
:type resource_group_name: str
:param account_name: The name of the Location Based Services Account.
:type account_name: str
:param sku_name: The name of the SKU, in standard format (such as S0).
:type sku_name: str
:param tags: Gets or sets a list of key value pairs that describe the
resource. These tags can be used in viewing and grouping this resource
(across resource groups). A maximum of 15 tags can be provided for a
resource. Each tag must have a key no greater than 128 characters and
value no greater than 256 characters.
:type tags: dict[str, str]
:param agree: If true, user agrees to the Preview Terms. Ignore prompt
for confirmation. False otherwise.
:type agree: bool
:return: LocationBasedServicesAccount
:rtype:
~azure.mgmt.locationbasedservices.models.LocationBasedServicesAccount
:raises:
:class:`ErrorException<azure.mgmt.locationbasedservices.models.ErrorException>`
"""
# Prompt for the Preview Terms agreement.
warning_msg = 'By creating a Location Based Services account, you agree to the Microsoft Azure Preview Terms.' + \
'\nThe Preview Terms can be found at: ' + \
'\nhttps://azure.microsoft.com/en-us/support/legal/preview-supplemental-terms/'
logger.warning(warning_msg)

if not agree: # ... in order to pass ScenarioTest
response = prompt_y_n('I confirm that I have read and agree to the Microsoft Azure Preview Terms.')
if not response:
raise CLIError('You must agree to the Microsoft Azure Preview Terms to create an account.')

# Proceed if user has agreed to the Preview Terms.
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):
"""Get all Location Based Services Accounts in a Resource Group OR in a Subscription.

:param resource_group_name: The name of the Azure Resource Group.
:type resource_group_name: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: An iterator like instance of LocationBasedServicesAccount
:rtype:
~azure.mgmt.locationbasedservices.models.LocationBasedServicesAccountPaged[~azure.mgmt.locationbasedservices.models.LocationBasedServicesAccount]
:raises:
:class:`ErrorException<azure.mgmt.locationbasedservices.models.ErrorException>`
"""
# Retrieve accounts via subscription
if resource_group_name is None:
return client.list_by_subscription()
Expand All @@ -84,22 +30,6 @@ def list_accounts(client, resource_group_name=None):


def generic_update_account(instance, sku_name=None, tags=None):
"""Create a LocationBasedServicesCreateParameters from old account instance
with new sku_name and tags. This function is called from the
generic_update_command(...) in commands.py .

:param sku_name: The name of the SKU, in standard format (such as S0).
:type sku_name: str
:param tags: Gets or sets a list of key value pairs that describe the
resource. These tags can be used in viewing and grouping this resource
(across resource groups). A maximum of 15 tags can be provided for a
resource. Each tag must have a key no greater than 128 characters and
value no greater than 256 characters.
:type tags: dict[str, str]
:return: LocationBasedServicesAccountCreateParameters
:rtype:
~azure.mgmt.locationbasedservices.models.LocationBasedServicesAccountCreateParameters
"""
# Pre-populate with old instance
lbs_account_create_params = LocationBasedServicesAccountCreateParameters(ACCOUNT_LOCATION, instance.sku,
instance.tags)
Expand Down
Loading