Skip to content

Commit

Permalink
Merge pull request Azure#22 from Azure/master
Browse files Browse the repository at this point in the history
Sync with the official repo
  • Loading branch information
ShichaoQiu authored Oct 15, 2020
2 parents db582a5 + e24d524 commit fb5771c
Show file tree
Hide file tree
Showing 710 changed files with 185,111 additions and 22,994 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ exclude =
./src/managementgroups/azext_managementgroups/managementgroups
./src/managementpartner/azext_managementpartner/managementpartner
./src/subscription/azext_subscription/subscription
*/grammar/
21 changes: 14 additions & 7 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/linter_exclusions.yml @MyronFanQiu @haroldrandom @fengzhou-msft

/src/index.json @haroldrandom @fengzhou-msft
/src/index.json @haroldrandom @fengzhou-msft @arrownj @bim @qwordy @houk-ms @MyronFanQiu @jsntcy @Juliehzl @jiasli @zhoxing-ms @evelyn-ys @msyyc

/src/footprint/ @jonunezd @Diego-Perez-Botero

Expand Down Expand Up @@ -64,11 +64,11 @@

/src/hack/ @geektrainer

/src/internet-analyzer/ @MyronFanQiu
/src/internet-analyzer/ @MyronFanQiu @jsntcy

/src/spring-cloud/ @peizhou298

/src/peering/ @MyronFanQiu
/src/peering/ @MyronFanQiu @jsntcy

/src/connectedmachine/ @farehar

Expand Down Expand Up @@ -100,6 +100,8 @@

/src/blueprint/ @fengzhou-msft

/src/storage-blob-preview/ @Juliehzl

/src/storage-or-preview/ @Juliehzl

/src/logic/ @bquantump
Expand All @@ -116,7 +118,7 @@

/src/import-export/ @arrownj

/src/account/ @zikalino
/src/account/ @arrownj @jiasli @fengzhou-msft

/src/datashare/ @fengzhou-msft

Expand All @@ -128,15 +130,13 @@

/src/kusto/ @ilayr @orhasban @astauben

/src/ai-did-you-mean-this/ @christopher-o-toole

/src/custom-providers/ @jsntcy

/src/costmanagement/ @haroldrandom

/src/datafactory/ @qiaozha

/src/blockchain/ @MyronFanQiu
/src/blockchain/ @MyronFanQiu @jsntcy

/src/codespaces/ @derekbekoe

Expand All @@ -147,3 +147,10 @@
/src/guestconfig/ @gehuan

/src/swiftlet/ @qwordy

/src/maintenance/ @sotaneja

/src/scheduled-query/ @MyronFanQiu @jsntcy

/src/stack-hci/ @zhoxing-ms

2 changes: 1 addition & 1 deletion azure-cli-extensions.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -4756,7 +4756,7 @@
<Content Include="src\virtual-wan\azext_vwan\azext_metadata.json" />
<Content Include="src\virtual-wan\readme.md" />
<Content Include="src\vm-repair\azext_vm_repair\scripts\linux-run-driver.sh" />
<Content Include="src\vm-repair\azext_vm_repair\scripts\mount_encrypted_disk.sh" />
<Content Include="src\vm-repair\azext_vm_repair\scripts\mount-encrypted-disk.sh" />
<Content Include="src\vm-repair\azext_vm_repair\scripts\win-run-driver.ps1" />
<Content Include="src\vm-repair\README.md" />
<Content Include="src\vm-repair\setup.cfg" />
Expand Down
7 changes: 7 additions & 0 deletions src/account/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Release History
===============

0.2.0
+++++
* Breaking Change: remove `az account subscription create`.
* Add az account alias commands.
* Add az account tenant commands.
* Support sovereign clouds.

0.1.0
++++++
* Initial release.
2 changes: 1 addition & 1 deletion src/account/azext_account/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from azext_account.generated.action import * # noqa: F403
# from azext_account.generated.action import * # noqa: F403
try:
from azext_account.manual.action import * # noqa: F403
except ImportError:
Expand Down
10 changes: 5 additions & 5 deletions src/account/azext_account/generated/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ def cf_account(cli_ctx, *_):
from ..vendored_sdks.subscription import SubscriptionClient
return _get_mgmt_service_client(cli_ctx, SubscriptionClient,
subscription_bound=False,
base_url_bound=False)[0]
base_url_bound=True)[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_tenant(cli_ctx, *_):
return cf_account(cli_ctx).tenant


def cf_operation(cli_ctx, *_):
return cf_account(cli_ctx).operation
def cf_alias(cli_ctx, *_):
return cf_account(cli_ctx).alias
125 changes: 90 additions & 35 deletions src/account/azext_account/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,123 @@
short-summary: Manage subscriptions
"""

helps['account subscription create'] = """
helps['account subscription rename'] = """
type: command
short-summary: Create a new WebDirect or EA Azure subscription.
short-summary: Rename subscription
examples:
- name: Create subscription
- name: Rename 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"
az account subscription rename --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

helps['account subscription cancel'] = """
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 create-in-enrollment-account'] = """
helps['account subscription enable'] = """
type: command
short-summary: Create subscription in enrolment account
short-summary: Enable subscription
examples:
- name: Create subscription in enrollment account
- name: Enable subscription
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"
az account subscription enable --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

helps['account subscription create-csp'] = """
helps['account subscription list'] = """
type: command
short-summary: Create a new CSP subscription.
short-summary: Get all subscriptions for a tenant.
examples:
- name: Create CSP subscription
- name: listSubscriptions
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"
az account subscription list
"""

helps['account subscription rename'] = """
helps['account subscription show'] = """
type: command
short-summary: Rename subscription
short-summary: Get details about a specified subscription.
examples:
- name: Rename subscription
- name: getSubscription
text: |-
az account subscription rename --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
az account subscription show --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

helps['account subscription cancel'] = """
helps['account subscription list-location'] = """
type: command
short-summary: Cancel subscription
short-summary: This operation provides all the locations that are available for resource providers; however, each r\
esource provider may support a subset of this list.
examples:
- name: Cancel subscription
- name: listLocations
text: |-
az account subscription cancel --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
az account subscription list-location --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
"""

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

helps['account tenant list'] = """
type: command
short-summary: Enable subscription
short-summary: Get the tenants for your account.
examples:
- name: Enable subscription
- name: listTenants
text: |-
az account subscription enable --subscription-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
az account tenant list
"""

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

helps['account alias list'] = """
type: command
short-summary: List Alias Subscriptions.
examples:
- name: List Alias Subscriptions
text: |-
az account alias list
"""

helps['account alias show'] = """
type: command
short-summary: Get Alias Subscription.
examples:
- name: GetAlias
text: |-
az account alias show --name "aliasForNewSub"
"""

helps['account alias create'] = """
type: command
short-summary: "Create Alias Subscription."
examples:
- name: CreateAlias
text: |-
az account alias create --name "aliasForNewSub" --billing-scope "/providers/Microsoft.Billing/billingAcc\
ounts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:024cabf4-7321-4cf9-be59-df0c77ca51de_2019-05-31/billingProfiles/PE2Q-NOIT-BG\
7-TGB/invoiceSections/MTT4-OBS7-PJA-TGB" --display-name "Contoso MCA subscription" --workload "Production"
"""

helps['account alias delete'] = """
type: command
short-summary: Delete Alias.
examples:
- name: DeleteAlias
text: |-
az account alias delete --name "aliasForNewSub"
"""

helps['account alias wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the account alias is met.
examples:
- name: Pause executing next line of CLI script until the account alias is successfully created.
text: |-
az account alias wait --name "aliasForNewSub" --created
"""
71 changes: 40 additions & 31 deletions src/account/azext_account/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,52 @@
# pylint: disable=too-many-lines
# pylint: disable=too-many-statements

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


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')
c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='Subscription Id.')
c.argument('subscription_name', options_list=['--name', '-n', '--subscription-name'], help='New subscription name')

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

with self.argument_context('account subscription enable') as c:
c.argument('subscription_id', help='Subscription Id.')
c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='Subscription Id.')

with self.argument_context('account subscription list') as c:
pass

with self.argument_context('account subscription show') as c:
c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='The ID of the target subscription.', id_part='subscription')

with self.argument_context('account subscription list-location') as c:
c.argument('subscription_id', options_list=['--id', '--subscription-id'], help='The ID of the target subscription.')

with self.argument_context('account tenant list') as c:
pass

with self.argument_context('account alias list') as c:
pass

with self.argument_context('account alias show') as c:
c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name')

with self.argument_context('account alias create', validator=alias_validator) as c:
c.argument('alias_name', options_list=['--name', '-n'], type=str, help='Alias Name')
c.argument('display_name', type=str, help='The friendly name of the subscription.')
c.argument('workload', arg_type=get_enum_type(['Production', 'DevTest']), help='The workload type of the '
'subscription. It can be either Production or DevTest.')
c.argument('billing_scope', type=str, help='Billing scope. It determines whether the subscription is Field-Led, Partner-Led or '
'LegacyEA')
c.argument('subscription_id', type=str, help='This parameter can be used to create alias for existing '
'subscription ID')

with self.argument_context('account alias delete') as c:
c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name')

with self.argument_context('account alias wait') as c:
c.argument('alias_name', options_list=['--name', '-n'], help='Alias Name')
12 changes: 12 additions & 0 deletions src/account/azext_account/generated/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.util import CLIError


def alias_validator(namespace):
if namespace.subscription_id:
if namespace.billing_scope or namespace.display_name:
raise CLIError('--billing-scope or --display-name is not allowed when --subscription-id is provided.')
else:
if not namespace.billing_scope or not namespace.display_name or not namespace.workload:
raise CLIError('--billing-scope, --display-name and --workload are required when creating '
'an alias with a new susbcription.')
Loading

0 comments on commit fb5771c

Please sign in to comment.