Skip to content

Commit

Permalink
[Account] account alias create: Add --reseller-id (Azure#2540)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzhou-msft authored Oct 20, 2020
1 parent 7bfc53d commit 0003f94
Show file tree
Hide file tree
Showing 9 changed files with 1,166 additions and 158 deletions.
4 changes: 4 additions & 0 deletions src/account/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.2.1
+++++
* az account alias create: add --reseller-id

0.2.0
+++++
* Breaking Change: remove `az account subscription create`.
Expand Down
1 change: 1 addition & 0 deletions src/account/azext_account/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def load_arguments(self, _):
'LegacyEA')
c.argument('subscription_id', type=str, help='This parameter can be used to create alias for existing '
'subscription ID')
c.argument('reseller_id', type=str, help='Reseller ID, basically MPN Id')

with self.argument_context('account alias delete') as c:
c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name')
Expand Down
4 changes: 3 additions & 1 deletion src/account/azext_account/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ def account_alias_create(client,
billing_scope=None,
display_name=None,
subscription_id=None,
reseller_id=None,
no_wait=False):
properties = {
'display_name': display_name,
'workload': workload,
'billing_scope': billing_scope,
'subscription_id': subscription_id
'subscription_id': subscription_id,
'reseller_id': reseller_id
}
return sdk_no_wait(no_wait,
client.begin_create,
Expand Down
1,245 changes: 1,114 additions & 131 deletions src/account/azext_account/tests/latest/recordings/test_account.yaml

Large diffs are not rendered by default.

42 changes: 27 additions & 15 deletions src/account/azext_account/tests/latest/test_account_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def test_account(self):
'new_alias_name': self.create_random_name(prefix='cli_alias_new', length=24),
'display_name': "My Subscription",
'new_display_name': "My Big Subscription",
'billing_scope': "/providers/Microsoft.Billing/billingAccounts/9147924/enrollmentAccounts/253727"
'billing_scope': "/providers/Microsoft.Billing/billingAccounts/9147924/enrollmentAccounts/253727",
'reseller_id': "5139005"
})

self.cmd('az account alias create --name {alias_name} --billing-scope "{billing_scope}" --display-name "{display_name}" --workload "Production"',
self.cmd('az account alias create --name {alias_name} --billing-scope "{billing_scope}" --display-name "{display_name}" --workload "Production" --reseller-id {reseller_id}',
checks=[self.check('name', '{alias_name}'),
self.check('properties.provisioningState', 'Succeeded')])

Expand All @@ -36,9 +37,8 @@ def test_account(self):
sub_id = alias_sub['properties']['subscriptionId']
self.kwargs.update({'subscription_id': sub_id})

# response different from swagger, causing deserialization error
# self.cmd('az account alias list',
# checks=[])
self.cmd('az account alias list',
checks=[self.exists('value')])

self.cmd('az account subscription list',
checks=[self.greater_than('length(@)', 0)])
Expand All @@ -54,18 +54,24 @@ def test_account(self):
self.cmd('az account subscription cancel --subscription-id {subscription_id} --yes',
checks=[self.check('subscriptionId', '{subscription_id}')])
time.sleep(300)
self.cmd('az account subscription show --subscription-id {subscription_id}',
checks=[self.check('displayName', '{display_name}'),
self.check('state', 'Warned'),
self.check('subscriptionId', sub_id)])
for i in range(5):
sub = self.cmd('az account subscription show --subscription-id {subscription_id}',
checks=[self.check('displayName', '{display_name}'),
self.check('subscriptionId', sub_id)]).get_output_in_json()
if sub['state'] != 'Warned':
time.sleep(180)
self.assertEquals(sub['state'], 'Warned')

self.cmd('az account subscription enable --subscription-id {subscription_id}',
checks=[self.check('subscriptionId', '{subscription_id}')])
time.sleep(300)
self.cmd('az account subscription show --subscription-id {subscription_id}',
checks=[self.check('displayName', '{display_name}'),
self.check('state', 'Enabled'),
self.check('subscriptionId', sub_id)])
for i in range(10):
sub = self.cmd('az account subscription show --subscription-id {subscription_id}',
checks=[self.check('displayName', '{display_name}'),
self.check('subscriptionId', sub_id)]).get_output_in_json()
if sub['state'] != 'Enabled':
time.sleep(180)
self.assertEquals(sub['state'], 'Enabled')

self.cmd('az account subscription rename --subscription-id {subscription_id} --name "{new_display_name}"',
checks=[self.check('subscriptionId', '{subscription_id}')])
Expand All @@ -88,5 +94,11 @@ def test_account(self):
self.check('properties.provisioningState', 'Succeeded')])

time.sleep(600)
self.cmd('az account alias delete -n {new_alias_name}',
checks=[])
for i in range(10):
try:
self.cmd('az account alias delete -n {new_alias_name}', checks=[])
break
except Exception as ex:
if i == 9:
raise ex
time.sleep(180)
Original file line number Diff line number Diff line change
Expand Up @@ -316,24 +316,28 @@ class PutAliasRequestProperties(msrest.serialization.Model):
:param subscription_id: This parameter can be used to create alias for existing subscription
Id.
:type subscription_id: str
:param reseller_id: Reseller ID, basically MPN Id.
:type reseller_id: str
"""

_attribute_map = {
'display_name': {'key': 'displayName', 'type': 'str'},
'workload': {'key': 'workload', 'type': 'str'},
'billing_scope': {'key': 'billingScope', 'type': 'str'},
'subscription_id': {'key': 'subscriptionId', 'type': 'str'},
'reseller_id': {'key': 'resellerId', 'type': 'str'},
}

def __init__(
self,
**kwargs
):
super(PutAliasRequestProperties, self).__init__(**kwargs)
self.display_name = kwargs['display_name']
self.workload = kwargs['workload']
self.billing_scope = kwargs['billing_scope']
self.display_name = kwargs.get('display_name', None)
self.workload = kwargs.get('workload', None)
self.billing_scope = kwargs.get('billing_scope', None)
self.subscription_id = kwargs.get('subscription_id', None)
self.reseller_id = kwargs.get('reseller_id', None)


class PutAliasResponse(msrest.serialization.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,29 +339,34 @@ class PutAliasRequestProperties(msrest.serialization.Model):
:param subscription_id: This parameter can be used to create alias for existing subscription
Id.
:type subscription_id: str
:param reseller_id: Reseller ID, basically MPN Id.
:type reseller_id: str
"""

_attribute_map = {
'display_name': {'key': 'displayName', 'type': 'str'},
'workload': {'key': 'workload', 'type': 'str'},
'billing_scope': {'key': 'billingScope', 'type': 'str'},
'subscription_id': {'key': 'subscriptionId', 'type': 'str'},
'reseller_id': {'key': 'resellerId', 'type': 'str'},
}

def __init__(
self,
*,
display_name: str,
workload: Union[str, "Workload"],
billing_scope: str,
display_name: Optional[str] = None,
workload: Optional[Union[str, "Workload"]] = None,
billing_scope: Optional[str] = None,
subscription_id: Optional[str] = None,
reseller_id: Optional[str] = None,
**kwargs
):
super(PutAliasRequestProperties, self).__init__(**kwargs)
self.display_name = display_name
self.workload = workload
self.billing_scope = billing_scope
self.subscription_id = subscription_id
self.reseller_id = reseller_id


class PutAliasResponse(msrest.serialization.Model):
Expand Down
2 changes: 0 additions & 2 deletions src/account/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
[bdist_wheel]
universal=1
5 changes: 2 additions & 3 deletions src/account/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.
VERSION = '0.2.0'
VERSION = '0.2.1'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down Expand Up @@ -47,8 +47,7 @@
# TODO: Update author and email, if applicable
author='Microsoft Corporation',
author_email='[email protected]',
# TODO: consider pointing directly to your source code instead of the generic repo
url='https://github.com/Azure/azure-cli-extensions',
url='https://github.com/Azure/azure-cli-extensions/tree/master/src/account',
long_description=README + '\n\n' + HISTORY,
license='MIT',
classifiers=CLASSIFIERS,
Expand Down

0 comments on commit 0003f94

Please sign in to comment.