Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
9a40ac5
created subscription extensions
Jan 14, 2020
432242f
added sdk
Jan 15, 2020
236a953
updated with recent version o autorest.cli
Feb 15, 2020
9c60e6b
actions
Feb 19, 2020
a7d3ccb
actions -> action
Feb 19, 2020
3cf6857
generated with new version
Feb 23, 2020
ee2f5c9
regenerated
Feb 23, 2020
8e5a1ac
fix params
Feb 23, 2020
d6d4af3
moved files into the generated folder
Feb 23, 2020
d0024f6
fix path
Feb 23, 2020
61b7d5d
fixed more imports
Feb 23, 2020
7fb75a1
empty line at the end of file
Feb 23, 2020
dcd33d7
fixed a few sanity issues
Feb 23, 2020
bdcdb99
sanity fixes
Feb 23, 2020
1c66a9a
adding entry to CODEOWNERS
Feb 23, 2020
1475655
added license header to actions
Feb 23, 2020
2001c99
examples & test fixes
Feb 24, 2020
01931ff
regenerated with proper tag
Feb 27, 2020
8e2bdbf
removed test for now
Feb 27, 2020
478dafc
empty init
Feb 27, 2020
865e932
import custom properly
Feb 27, 2020
626cf8d
fixed problem
Feb 27, 2020
26612b3
fixed custom
Feb 27, 2020
05d424d
action
Feb 27, 2020
1a5484f
updated commands & vendored sdks
Feb 27, 2020
95fafb5
relative import
Feb 27, 2020
828847b
missing __init__.py in vendored_sdks
Feb 27, 2020
ab44a31
regenerated with flattened sdk
Feb 28, 2020
0e76196
now actions more complete
Feb 28, 2020
78d6755
action is fixed now
Feb 28, 2020
8dc461e
removed unnecessary stuff
Feb 28, 2020
b8aa386
fixes
Feb 29, 2020
170b491
sanity fixes
Feb 29, 2020
bd75618
wildcard imports
Feb 29, 2020
aa40879
fixed vendored_sdks location
Feb 29, 2020
6dfbc99
unused imports again
Feb 29, 2020
9ce42ff
fixed import
Feb 29, 2020
7fd851f
fixed sanity
Feb 29, 2020
2e45ec5
try to disable flake8
Feb 29, 2020
a4933cb
f403
Feb 29, 2020
84c1a60
two spaces
Feb 29, 2020
dc71de7
moved sdk
Feb 29, 2020
6eaebd2
removed old, added .flake8
Feb 29, 2020
707c6da
another try
Feb 29, 2020
673d2f6
try to dump checked files
Feb 29, 2020
6a59e0c
navy's changes
Mar 5, 2020
2b2e72b
two more fixes
Mar 5, 2020
36d210b
fixes
Mar 5, 2020
adf2ec2
sdk is regenerated
Mar 5, 2020
4a6689d
updated commands
Mar 5, 2020
06a49de
fixed client factory
Mar 5, 2020
dcf83aa
hack for config
Mar 5, 2020
ddd76a3
undo config thing
Mar 6, 2020
2e74fed
add credential thingy
Mar 6, 2020
24d3bcf
fix for owner
Mar 10, 2020
63d179e
fixed body_owners
Mar 10, 2020
0e040eb
fix
Mar 13, 2020
d976dd1
fixes
Mar 13, 2020
63d25e9
one more space
Mar 16, 2020
3e28e39
more sanity
Mar 16, 2020
3877164
subscription_id help
Mar 16, 2020
55ce4c7
removed pass
Mar 16, 2020
d78d021
fixed examples
Mar 16, 2020
a886bd5
fixing examples
Mar 16, 2020
374ae3a
example fixes
Mar 16, 2020
806d0d3
one more fix
Mar 16, 2020
cefc20e
fix to manual part of sdk
Mar 17, 2020
0112cb0
fix import
Mar 17, 2020
b908042
try
Mar 17, 2020
b9da2b4
too many blank lines
Mar 17, 2020
873cab4
fixed help
Mar 17, 2020
5ac0ac4
unused import
Mar 17, 2020
23c47b4
updated example descriptions
Apr 14, 2020
754b9aa
confirmation and isexperimental
Apr 14, 2020
e1f803d
subscription create
Apr 14, 2020
fcb8234
one more
Apr 14, 2020
905b88e
removed isPreview
Apr 20, 2020
795fc55
one more blank
Apr 20, 2020
a9ea036
updated
Apr 20, 2020
9f78100
undo one change
Apr 20, 2020
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@
/src/databox/ @jsntcy

/src/hpc-cache/ @qianwens

/src/account/ @zikalino
8 changes: 8 additions & 0 deletions src/account/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:

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

0.1.0
++++++
* Initial release.
5 changes: 5 additions & 0 deletions src/account/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'account' Extension
==========================================

This package is for the 'account' extension.
i.e. 'az account'
3 changes: 3 additions & 0 deletions src/account/azext_account/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
exclude =
vendored_sdks
41 changes: 41 additions & 0 deletions src/account/azext_account/__init__.py
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 azure.cli.core import AzCommandsLoader
from azext_account.generated._help import helps # pylint: disable=unused-import


class SubscriptionClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_account.generated._client_factory import cf_account
account_custom = CliCommandType(
operations_tmpl='azext_account.custom#{}',
client_factory=cf_account)
super(SubscriptionClientCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=account_custom)

def load_command_table(self, args):
from azext_account.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_account.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
return self.command_table

def load_arguments(self, command):
from azext_account.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_account.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass


COMMAND_LOADER_CLS = SubscriptionClientCommandsLoader
13 changes: 13 additions & 0 deletions src/account/azext_account/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from azext_account.generated.action import * # noqa: F403
try:
from azext_account.manual.action import * # noqa: F403
except ImportError:
pass
4 changes: 4 additions & 0 deletions src/account/azext_account/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.3.1"
}
13 changes: 13 additions & 0 deletions src/account/azext_account/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from azext_account.generated.custom import * # noqa: F403
try:
from azext_account.manual.custom import * # noqa: F403
except ImportError:
pass
4 changes: 4 additions & 0 deletions src/account/azext_account/generated/__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.
# --------------------------------------------------------------------------------------------
24 changes: 24 additions & 0 deletions src/account/azext_account/generated/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def cf_account(cli_ctx, *_):
from azure.cli.core.commands.client_factory import _get_mgmt_service_client
from ..vendored_sdks.subscription import SubscriptionClient
return _get_mgmt_service_client(cli_ctx, SubscriptionClient,
subscription_bound=False,
base_url_bound=False)[0]


def cf_subscription(cli_ctx, *_):
return cf_account(cli_ctx).subscription


def cf_subscription_operation(cli_ctx, *_):
return cf_account(cli_ctx).subscription_operation


def cf_operation(cli_ctx, *_):
return cf_account(cli_ctx).operation
80 changes: 80 additions & 0 deletions src/account/azext_account/generated/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long
# pylint: disable=too-many-lines

from knack.help_files import helps


helps['account subscription'] = """
type: group
short-summary: Manage subscriptions
"""

helps['account subscription create'] = """
type: command
short-summary: Create a new WebDirect or EA Azure subscription.
examples:
- name: Create subscription
text: |-
az account subscription create --billing-account-name \\
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_XXXX-XX-XX" \\
--billing-profile-name "27VR-HDWX-BG7-TGB" --cost-center "135366376" --display-name \\
"Contoso MCA subscription" --owner xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\
--sku-id "0001" --invoice-section-name "JGF7-NSBG-PJA-TGB"
"""


helps['account subscription create-in-enrollment-account'] = """
type: command
short-summary: Create subscription in enrolment account
examples:
- name: Create subscription in enrollment account
text: |-
az account subscription create-in-enrollment-account --display-name \\
"Test Ea Azure Sub" --offer-type "MS-AZR-0017P" --owners \\
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \\
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --enrollment-account-name \\
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

helps['account subscription create-csp'] = """
type: command
short-summary: Create a new CSP subscription.
examples:
- name: Create CSP subscription
text: |-
az account subscription create-csp --billing-account-name \\
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_XXXX-XX-XX" \\
--display-name "Contoso MCA subscription" --sku-id "0001" --customer-name \\
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

helps['account subscription rename'] = """
type: command
short-summary: Rename subscription
examples:
- name: Rename subscription
text: |-
az account subscription rename --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

helps['account subscription cancel'] = """
Comment thread
zikalino marked this conversation as resolved.
type: command
short-summary: Cancel subscription
examples:
- name: Cancel subscription
text: |-
az account subscription cancel --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

helps['account subscription enable'] = """
type: command
short-summary: Enable subscription
examples:
- name: Enable subscription
text: |-
az account subscription enable --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""
48 changes: 48 additions & 0 deletions src/account/azext_account/generated/_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long
# pylint: disable=too-many-lines
# pylint: disable=too-many-statements

from azure.cli.core.commands.parameters import (
get_enum_type
)


def load_arguments(self, _):

with self.argument_context('account subscription create') as c:
c.argument('billing_account_name', help='The name of the Microsoft Customer Agreement billing account for which you want to create the subscription.')
c.argument('billing_profile_name', help='The name of the billing profile in the billing account for which you want to create the subscription.')
c.argument('invoice_section_name', help='The name of the invoice section in the billing account for which you want to create the subscription.')
c.argument('display_name', help='The friendly name of the subscription.')
c.argument('sku_id', help='The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.')
c.argument('cost_center', help='If set, the cost center will show up on the Azure usage and charges file.')
c.argument('owner', help='Active Directory Principal who’ll get owner access on the new subscription.')
c.argument('management_group_id', help='The identifier of the management group to which this subscription will be associated.')

with self.argument_context('account subscription create-in-enrollment-account') as c:
c.argument('enrollment_account_name', help='The name of the enrollment account to which the subscription will be billed.')
c.argument('display_name', help='The display name of the subscription.')
c.argument('management_group_id', help='The Management Group Id.')
c.argument('owners', nargs='+', help='The list of principals that should be granted Owner access on the subscription. Principals should be of type User, Service Principal or Security Group.')
c.argument('offer_type', arg_type=get_enum_type(['MS-AZR-0017P', 'MS-AZR-0148P']), help='The offer type of the subscription. For example, MS-AZR-0017P (EnterpriseAgreement) and MS-AZR-0148P (EnterpriseAgreement devTest) are available. Only valid when creating a subscription in a enrollment account scope.')

with self.argument_context('account subscription create-csp') as c:
c.argument('billing_account_name', help='The name of the Microsoft Customer Agreement billing account for which you want to create the subscription.')
c.argument('customer_name', help='The name of the customer.')
c.argument('display_name', help='The friendly name of the subscription.')
c.argument('sku_id', help='The SKU ID of the Azure plan. Azure plan determines the pricing and service-level agreement of the subscription. Use 001 for Microsoft Azure Plan and 002 for Microsoft Azure Plan for DevTest.')
c.argument('reseller_id', help='Reseller ID, basically MPN Id.')

with self.argument_context('account subscription rename') as c:
c.argument('subscription_id', help='Subscription Id.')
c.argument('subscription_name', help='New subscription name')

with self.argument_context('account subscription cancel') as c:
c.argument('subscription_id', help='Subscription Id.')

with self.argument_context('account subscription enable') as c:
c.argument('subscription_id', help='Subscription Id.')
4 changes: 4 additions & 0 deletions src/account/azext_account/generated/_validators.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.
# --------------------------------------------------------------------------------------------
4 changes: 4 additions & 0 deletions src/account/azext_account/generated/action.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.
# --------------------------------------------------------------------------------------------
25 changes: 25 additions & 0 deletions src/account/azext_account/generated/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
# pylint: disable=too-many-lines
# pylint: disable=too-many-statements
# pylint: disable=too-many-locals
from azure.cli.core.commands import CliCommandType


def load_command_table(self, _):

from azext_account.generated._client_factory import cf_subscription
account_subscription = CliCommandType(
operations_tmpl='azext_account.vendored_sdks.subscription.operations._subscription_operations#SubscriptionOperations.{}',
client_factory=cf_subscription)
with self.command_group('account subscription', account_subscription, client_factory=cf_subscription) as g:
g.custom_command('create', 'account_subscription_create_subscription', supports_no_wait=True)
g.custom_command('rename', 'account_subscription_rename')
g.custom_command('cancel', 'account_subscription_cancel', confirmation=True)
g.custom_command('enable', 'account_subscription_enable')
g.custom_command('create-csp', 'account_subscription_create_csp_subscription', supports_no_wait=True)
g.custom_command('create-in-enrollment-account', 'account_subscription_create_subscription_in_enrollment_account', supports_no_wait=True)
76 changes: 76 additions & 0 deletions src/account/azext_account/generated/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long
# pylint: disable=too-many-statements
# pylint: disable=too-many-lines
# pylint: disable=too-many-locals
# pylint: disable=unused-argument

from azure.cli.core.util import sdk_no_wait


def account_subscription_create_subscription(cmd, client,
billing_account_name,
billing_profile_name,
invoice_section_name,
display_name,
sku_id,
cost_center=None,
owner=None,
management_group_id=None,
no_wait=False):

body = {}
body['display_name'] = display_name
body['sku_id'] = sku_id
body['cost_center'] = cost_center
body['owner'] = {'object_id': owner}
body['management_group_id'] = management_group_id
return sdk_no_wait(no_wait, client.create_subscription, billing_account_name=billing_account_name, billing_profile_name=billing_profile_name, invoice_section_name=invoice_section_name, body=body)


def account_subscription_create_subscription_in_enrollment_account(cmd, client,
enrollment_account_name,
display_name=None,
management_group_id=None,
owners=None,
offer_type=None,
no_wait=False):
if owners is not None:
owners = [{'object_id': x} for x in owners]

body = {}
body['display_name'] = display_name
body['management_group_id'] = management_group_id
body['owners'] = owners
body['offer_type'] = offer_type
return sdk_no_wait(no_wait, client.create_subscription_in_enrollment_account, enrollment_account_name=enrollment_account_name, body=body)


def account_subscription_create_csp_subscription(cmd, client,
billing_account_name,
customer_name,
display_name,
sku_id,
reseller_id=None,
no_wait=False):
body = {}
body['display_name'] = display_name
body['sku_id'] = sku_id
body['reseller_id'] = reseller_id
return sdk_no_wait(no_wait, client.create_csp_subscription, billing_account_name=billing_account_name, customer_name=customer_name, body=body)


def account_subscription_rename(cmd, client, subscription_id,
subscription_name=None):
return client.rename(subscription_id=subscription_id, subscription_name=subscription_name)


def account_subscription_cancel(cmd, client, subscription_id):
return client.cancel(subscription_id=subscription_id)


def account_subscription_enable(cmd, client, subscription_id):
return client.enable(subscription_id=subscription_id)
Loading