Skip to content

Commit

Permalink
{Quota}Generate quota with codegen (#4475)
Browse files Browse the repository at this point in the history
* {Quota}Generate quota with codegen

* Update setup.py

* Update test_quota_crud.yaml

* Update test_quota_crud.yaml

* Update

* Update

* Update _help.py

* Update _help.py
  • Loading branch information
ZengTaoxu authored Mar 7, 2022
1 parent f4a846d commit d292d6d
Show file tree
Hide file tree
Showing 48 changed files with 7,159 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,5 @@
/src/datamigration/ @ashutoshsuman99

/src/confidentialledger/ @kairu-ms @lynshi

/src/quota/ @kairu-ms @ZengTaoxu
8 changes: 8 additions & 0 deletions src/quota/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Initial release.
112 changes: 112 additions & 0 deletions src/quota/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Azure CLI quota Extension #
This is the extension for quota

### How to use ###
Install this extension using the below CLI command
```
az extension add --name quota
```

### Included Features ###
#### quota usage ####
##### List-UsagesForCompute #####
```
az quota usage list \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"
```
##### List-UsagesForNetwork #####
```
az quota usage list \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"
```
##### List-UsagesMachineLearningServices #####
```
az quota usage list \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.MachineLearningServices/locations/eastus"
```
##### Show-UsagesRequestForCompute #####
```
az quota usage show --resource-name "standardNDSFamily" \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"
```
##### Show-UsagesRequestForNetwork #####
```
az quota usage show --resource-name "MinPublicIpInterNetworkPrefixLength" \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"
```
#### quota ####
##### Create-ForNetwork #####
```
az quota create --resource-name "MinPublicIpInterNetworkPrefixLength" --scope "subscriptions/00000000-00\
00-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus" \
--limit-object value=10 limit-object-type=LimitValue --resource-type MinPublicIpInterNetworkPrefixLength
```
##### Create-ForNetworkStandardSkuPublicIpAddressesResource #####
```
az quota create --resource-name "StandardSkuPublicIpAddresses" --scope "subscriptions/00000000-0000-0000\
-0000-000000000000/providers/Microsoft.Network/locations/eastus" \
--limit-object value=10 limit-object-type=LimitValue --resource-type PublicIpAddresses
```
##### Create-ForCompute #####
```
az quota create --resource-name "standardFSv2Family" --scope "subscriptions/00000000-0000-0000-0000-0000\
00000000/providers/Microsoft.Compute/locations/eastus" \
--limit-object value=10 limit-object-type=LimitValue --resource-type dedicated
```
##### Create-MachineLearningServicesLowPriorityResource #####
```
az quota create --resource-name "TotalLowPriorityCores" --scope "subscriptions/00000000-0000-0000-0000-\
000000000000/providers/Microsoft.MachineLearning/Services/locations/eastus" \
--limit-object value=10 limit-object-type=LimitValue --resource-type lowPriority
```
##### Show-ForNetwork #####
```
az quota show --resource-name "MinPublicIpInterNetworkPrefixLength" \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"
```
##### Show-ForCompute #####
```
az quota show --resource-name "standardNDSFamily" \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"
```
##### List-QuotaLimitsForCompute #####
```
az quota list --scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"
```
##### List-QuotaLimitsForNetwork #####
```
az quota list --scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"
```
##### List-QuotaLimitsMachineLearningServices #####
```
az quota list \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.MachineLearningServices/locations/eastus"
```
##### Update-ForCompute #####
```
az quota update --resource-name "standardFSv2Family" --scope "subscriptions/00000000-0000-0000-0000-0000\
00000000/providers/Microsoft.Compute/locations/eastus" --limit-object value=10 limit-object-type=LimitValue
--resource-type dedicated
```
##### Update-ForNetwork #####
```
az quota update --resource-name "MinPublicIpInterNetworkPrefixLength" --scope "subscriptions/00000000-00\
00-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus" \
--limit-object value=10 limit-object-type=LimitValue --resource-type MinPublicIpInterNetworkPrefixLength
```
#### quota request status ####
##### List-QuotaRequestHistory #####
```
az quota request status list \
--scope "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"
```
##### Show #####
```
az quota request status show --name "2B5C8515-37D8-4B6A-879B-CD641A2CF605" \
--scope "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"
```
#### quota operation ####
##### List #####
```
az quota operation list
```
53 changes: 53 additions & 0 deletions src/quota/azext_quota/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=unused-import

import azext_quota._help
from azure.cli.core import AzCommandsLoader


class AzureQuotaExtensionAPICommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_quota.generated._client_factory import cf_quota_cl
quota_custom = CliCommandType(
operations_tmpl='azext_quota.custom#{}',
client_factory=cf_quota_cl)
parent = super(AzureQuotaExtensionAPICommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=quota_custom)

def load_command_table(self, args):
from azext_quota.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_quota.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError as e:
if e.name.endswith('manual.commands'):
pass
else:
raise e
return self.command_table

def load_arguments(self, command):
from azext_quota.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_quota.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError as e:
if e.name.endswith('manual._params'):
pass
else:
raise e


COMMAND_LOADER_CLS = AzureQuotaExtensionAPICommandsLoader
20 changes: 20 additions & 0 deletions src/quota/azext_quota/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import
# pylint: disable=unused-import
from .generated._help import helps # pylint: disable=reimported
try:
from .manual._help import helps # pylint: disable=reimported
except ImportError as e:
if e.name.endswith('manual._help'):
pass
else:
raise e
20 changes: 20 additions & 0 deletions src/quota/azext_quota/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError as e:
if e.name.endswith('manual.action'):
pass
else:
raise e
4 changes: 4 additions & 0 deletions src/quota/azext_quota/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.15.0"
}
20 changes: 20 additions & 0 deletions src/quota/azext_quota/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError as e:
if e.name.endswith('manual.custom'):
pass
else:
raise e
12 changes: 12 additions & 0 deletions src/quota/azext_quota/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__)
33 changes: 33 additions & 0 deletions src/quota/azext_quota/generated/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


def cf_quota_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_quota.vendored_sdks.quota import AzureQuotaExtensionAPI
return get_mgmt_service_client(cli_ctx,
AzureQuotaExtensionAPI,
subscription_bound=False)


def cf_usage(cli_ctx, *_):
return cf_quota_cl(cli_ctx).usages


def cf_quota(cli_ctx, *_):
return cf_quota_cl(cli_ctx).quota


def cf_quotarequeststatus(cli_ctx, *_):
return cf_quota_cl(cli_ctx).quotarequeststatus


def cf_quotaoperation(cli_ctx, *_):
return cf_quota_cl(cli_ctx).quotaoperation
Loading

0 comments on commit d292d6d

Please sign in to comment.