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
Next Next commit
[Temporary] Throw an exception on 'account show' command, when nonexist
  • Loading branch information
jp94 committed Feb 28, 2018
commit 4d930f80dc7505595e202bbd25c9710d0cf1afc5
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ def load_command_table(self, _):
client_factory=cf_accounts)

with self.command_group('locationbasedservices account', mgmt_type) as g:
g.command('show', 'get')
g.custom_command('show', 'get_account')
g.custom_command('list', 'list_accounts')
g.custom_command('create', 'create')
g.custom_command('create', 'create_account')
g.command('delete', 'delete')

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
Expand Up @@ -9,11 +9,21 @@

from azure.mgmt.locationbasedservices.models import LocationBasedServicesAccountCreateParameters, Sku

ACCOUNT_LOCATION = 'global'

logger = get_logger(__name__)


# pylint: disable=line-too-long
def create(client, resource_group_name, account_name, sku_name='S0', tags=None, agree=None):
def get_account(client, resource_group_name, account_name):
Copy link
Member

Choose a reason for hiding this comment

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

This can be simply reflected from the SDK.

response = client.get(resource_group_name, account_name)
if response is None:
raise CLIError("The resource 'Microsoft.LocationBasedServices/accounts/" + account_name +
"' under resource group '" + resource_group_name + "' was not found.")
return response


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.
Expand Down Expand Up @@ -44,16 +54,16 @@ def create(client, resource_group_name, account_name, sku_name='S0', tags=None,
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 tests

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.')
Copy link
Member

Choose a reason for hiding this comment

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

This is generally not used anywhere else for create commands. Is there a particular reason LBS would be different?


# Proceed if user has agreed to the Preview Terms.
sku = Sku(sku_name)
lbs_account_create_params = LocationBasedServicesAccountCreateParameters('global', sku, tags)
lbs_account_create_params = LocationBasedServicesAccountCreateParameters(ACCOUNT_LOCATION, sku, tags)
return client.create_or_update(resource_group_name, account_name, lbs_account_create_params)


Expand Down