From 2f81b69b153b342d52a309f14b8c240a311ea880 Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Sun, 15 Mar 2020 17:22:35 +0800 Subject: [PATCH 1/6] [Breadth Coverage] Support custom providers in Azure CLI (draft) --- src/custom-providers/HISTORY.rst | 8 + src/custom-providers/README.md | 5 + .../azext_custom_providers/__init__.py | 32 ++ .../azext_custom_providers/_client_factory.py | 14 + .../azext_custom_providers/_help.py | 67 +++ .../azext_custom_providers/_params.py | 45 ++ .../azext_custom_providers/_validators.py | 18 + .../azext_metadata.json | 4 + .../azext_custom_providers/commands.py | 24 + .../azext_custom_providers/custom.py | 67 +++ .../latest/test_custom-providers_scenario.py | 70 +++ .../vendored_sdks/__init__.py | 1 + .../vendored_sdks/customproviders/__init__.py | 19 + .../customproviders/_configuration.py | 49 ++ .../_custom_providers_client.py | 60 +++ .../customproviders/models/__init__.py | 68 +++ .../models/_custom_providers_client_enums.py | 37 ++ .../customproviders/models/_models.py | 440 ++++++++++++++++ .../customproviders/models/_models_py3.py | 440 ++++++++++++++++ .../customproviders/models/_paged_models.py | 53 ++ .../customproviders/operations/__init__.py | 20 + .../operations/_associations_operations.py | 350 +++++++++++++ .../_custom_resource_provider_operations.py | 484 ++++++++++++++++++ .../customproviders/operations/_operations.py | 100 ++++ .../vendored_sdks/customproviders/version.py | 13 + src/custom-providers/setup.cfg | 2 + src/custom-providers/setup.py | 60 +++ 27 files changed, 2550 insertions(+) create mode 100644 src/custom-providers/HISTORY.rst create mode 100644 src/custom-providers/README.md create mode 100644 src/custom-providers/azext_custom_providers/__init__.py create mode 100644 src/custom-providers/azext_custom_providers/_client_factory.py create mode 100644 src/custom-providers/azext_custom_providers/_help.py create mode 100644 src/custom-providers/azext_custom_providers/_params.py create mode 100644 src/custom-providers/azext_custom_providers/_validators.py create mode 100644 src/custom-providers/azext_custom_providers/azext_metadata.json create mode 100644 src/custom-providers/azext_custom_providers/commands.py create mode 100644 src/custom-providers/azext_custom_providers/custom.py create mode 100644 src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/__init__.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/__init__.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_configuration.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_custom_providers_client.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/__init__.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_custom_providers_client_enums.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models_py3.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_paged_models.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/__init__.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_associations_operations.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_operations.py create mode 100644 src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/version.py create mode 100644 src/custom-providers/setup.cfg create mode 100644 src/custom-providers/setup.py diff --git a/src/custom-providers/HISTORY.rst b/src/custom-providers/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /dev/null +++ b/src/custom-providers/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/custom-providers/README.md b/src/custom-providers/README.md new file mode 100644 index 00000000000..48f776d9b2d --- /dev/null +++ b/src/custom-providers/README.md @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'custom-providers' Extension +========================================== + +This package is for the 'custom-providers' extension. +i.e. 'az custom-providers' diff --git a/src/custom-providers/azext_custom_providers/__init__.py b/src/custom-providers/azext_custom_providers/__init__.py new file mode 100644 index 00000000000..04ccaa71739 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/__init__.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# 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_custom_providers._help import helps # pylint: disable=unused-import + + +class CustomprovidersCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_custom_providers._client_factory import cf_custom_providers + custom_providers_custom = CliCommandType( + operations_tmpl='azext_custom_providers.custom#{}', + client_factory=cf_custom_providers) + super(CustomprovidersCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=custom_providers_custom) + + def load_command_table(self, args): + from azext_custom_providers.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_custom_providers._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = CustomprovidersCommandsLoader diff --git a/src/custom-providers/azext_custom_providers/_client_factory.py b/src/custom-providers/azext_custom_providers/_client_factory.py new file mode 100644 index 00000000000..07af0d4489e --- /dev/null +++ b/src/custom-providers/azext_custom_providers/_client_factory.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def cf_custom_providers(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from .vendored_sdks.customproviders import CustomProvidersClient + return get_mgmt_service_client(cli_ctx, CustomProvidersClient) + + +def cf_custom_resource_provider(cli_ctx, *_): + return cf_custom_providers(cli_ctx).custom_resource_provider diff --git a/src/custom-providers/azext_custom_providers/_help.py b/src/custom-providers/azext_custom_providers/_help.py new file mode 100644 index 00000000000..506e030ae1a --- /dev/null +++ b/src/custom-providers/azext_custom_providers/_help.py @@ -0,0 +1,67 @@ +# 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. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=line-too-long +from knack.help_files import helps # pylint: disable=unused-import + + +helps['custom-providers custom-resource-provider'] = """ + type: group + short-summary: Commands to manage custom resource provider. +""" + +helps['custom-providers custom-resource-provider create'] = """ + type: command + short-summary: Creates or updates the custom resource provider. + examples: + - name: Create or update the custom resource provider + text: |- + az custom-providers custom-resource-provider create --resource-group "testRG" --name \\ + "newrp" --location "eastus" +""" + +helps['custom-providers custom-resource-provider update'] = """ + type: command + short-summary: Creates or updates the custom resource provider. + examples: + - name: Update a custom resource provider + text: |- + az custom-providers custom-resource-provider update --resource-group "testRG" --name \\ + "newrp" +""" + +helps['custom-providers custom-resource-provider delete'] = """ + type: command + short-summary: Deletes the custom resource provider. + examples: + - name: Delete a custom resource provider + text: |- + az custom-providers custom-resource-provider delete --resource-group "testRG" --name \\ + "newrp" +""" + +helps['custom-providers custom-resource-provider show'] = """ + type: command + short-summary: Gets the custom resource provider manifest. + examples: + - name: Get a custom resource provider + text: |- + az custom-providers custom-resource-provider show --resource-group "testRG" --name \\ + "newrp" +""" + +helps['custom-providers custom-resource-provider list'] = """ + type: command + short-summary: Gets all the custom resource providers within a resource group. + examples: + - name: List all custom resource providers on the resourceGroup + text: |- + az custom-providers custom-resource-provider list --resource-group "testRG" + - name: List all custom resource providers on the subscription + text: |- + az custom-providers custom-resource-provider list +""" diff --git a/src/custom-providers/azext_custom_providers/_params.py b/src/custom-providers/azext_custom_providers/_params.py new file mode 100644 index 00000000000..bb4f291ee93 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/_params.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------------------------- +# 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 ( + tags_type, + resource_group_name_type, + get_location_type +) + + +def load_arguments(self, _): + + with self.argument_context('custom-providers custom-resource-provider create') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the resource provider.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('tags', tags_type) + c.argument('actions', id_part=None, help='A list of actions that the custom resource provider implements.', nargs='+') + c.argument('resource_types', id_part=None, help='A list of resource types that the custom resource provider implements.', nargs='+') + c.argument('validations', id_part=None, help='A list of validations to run on the custom resource provider\'s requests.', nargs='+') + + with self.argument_context('custom-providers custom-resource-provider update') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the resource provider.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('tags', tags_type) + c.argument('actions', id_part=None, help='A list of actions that the custom resource provider implements.', nargs='+') + c.argument('resource_types', id_part=None, help='A list of resource types that the custom resource provider implements.', nargs='+') + c.argument('validations', id_part=None, help='A list of validations to run on the custom resource provider\'s requests.', nargs='+') + + with self.argument_context('custom-providers custom-resource-provider delete') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the resource provider.') + + with self.argument_context('custom-providers custom-resource-provider show') as c: + c.argument('resource_group', resource_group_name_type) + c.argument('name', id_part=None, help='The name of the resource provider.') + + with self.argument_context('custom-providers custom-resource-provider list') as c: + c.argument('resource_group', resource_group_name_type) diff --git a/src/custom-providers/azext_custom_providers/_validators.py b/src/custom-providers/azext_custom_providers/_validators.py new file mode 100644 index 00000000000..01e8fe71d5a --- /dev/null +++ b/src/custom-providers/azext_custom_providers/_validators.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/custom-providers/azext_custom_providers/azext_metadata.json b/src/custom-providers/azext_custom_providers/azext_metadata.json new file mode 100644 index 00000000000..55c81bf3328 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.0.67" +} \ No newline at end of file diff --git a/src/custom-providers/azext_custom_providers/commands.py b/src/custom-providers/azext_custom_providers/commands.py new file mode 100644 index 00000000000..369c92bb6c7 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/commands.py @@ -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. +# -------------------------------------------------------------------------------------------- + +# 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 ._client_factory import cf_custom_resource_provider + custom_providers_custom_resource_provider = CliCommandType( + operations_tmpl='azext_custom_providers.vendored_sdks.customproviders.operations._custom_resource_provider_operations#CustomResourceProviderOperations.{}', + client_factory=cf_custom_resource_provider) + with self.command_group('custom-providers custom-resource-provider', custom_providers_custom_resource_provider, client_factory=cf_custom_resource_provider) as g: + g.custom_command('create', 'create_custom_providers_custom_resource_provider') + g.custom_command('update', 'update_custom_providers_custom_resource_provider') + g.custom_command('delete', 'delete_custom_providers_custom_resource_provider') + g.custom_show_command('show', 'get_custom_providers_custom_resource_provider') + g.custom_command('list', 'list_custom_providers_custom_resource_provider') diff --git a/src/custom-providers/azext_custom_providers/custom.py b/src/custom-providers/azext_custom_providers/custom.py new file mode 100644 index 00000000000..719258fbc8d --- /dev/null +++ b/src/custom-providers/azext_custom_providers/custom.py @@ -0,0 +1,67 @@ +# -------------------------------------------------------------------------------------------- +# 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 + + +def create_custom_providers_custom_resource_provider(cmd, client, + resource_group, + name, + location, + tags=None, + actions=None, + resource_types=None, + validations=None): + body = {} + body['location'] = location # str + body['tags'] = tags # dictionary + body['actions'] = actions + body['resource_types'] = resource_types + body['validations'] = validations + return client.create_or_update(resource_group_name=resource_group, resource_provider_name=name, resource_provider=body) + + +def update_custom_providers_custom_resource_provider(cmd, client, + resource_group, + name, + location=None, + tags=None, + actions=None, + resource_types=None, + validations=None): + body = {} + if location is not None: + body['location'] = location # str + if tags is not None: + body['tags'] = tags # dictionary + if actions is not None: + body['actions'] = actions + if resource_types is not None: + body['resource_types'] = resource_types + if validations is not None: + body['validations'] = validations + return client.create_or_update(resource_group_name=resource_group, resource_provider_name=name, resource_provider=body) + + +def delete_custom_providers_custom_resource_provider(cmd, client, + resource_group, + name): + return client.delete(resource_group_name=resource_group, resource_provider_name=name) + + +def get_custom_providers_custom_resource_provider(cmd, client, + resource_group, + name): + return client.get(resource_group_name=resource_group, resource_provider_name=name) + + +def list_custom_providers_custom_resource_provider(cmd, client, + resource_group=None): + if resource_group is not None: + return client.list_by_resource_group(resource_group_name=resource_group) + return client.list_by_subscription() diff --git a/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py b/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py new file mode 100644 index 00000000000..173441b98b7 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py @@ -0,0 +1,70 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import unittest + +from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +class CustomprovidersScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_custom_providers') + def test_custom_providers(self, resource_group): + + self.cmd('az custom-providers association create ' + '--scope "scope" ' + '--name "associationName" ' + '--target-resource-id "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}/providers/Microsoft.Solutions/applications/{{ application_name }}"', + checks=[]) + + self.cmd('az custom-providers custom-resource-provider create ' + '--resource-group {rg} ' + '--name "newrp" ' + '--location "eastus"', + checks=[]) + + self.cmd('az custom-providers custom-resource-provider show ' + '--resource-group {rg} ' + '--name "newrp"', + checks=[]) + + self.cmd('az custom-providers custom-resource-provider list ' + '--resource-group {rg}', + checks=[]) + + self.cmd('az custom-providers custom-resource-provider list', + checks=[]) + + self.cmd('az custom-providers association show ' + '--scope "scope" ' + '--name "associationName"', + checks=[]) + + self.cmd('az custom-providers association list ' + '--scope "scope"', + checks=[]) + + self.cmd('az custom-providers operation list', + checks=[]) + + self.cmd('az custom-providers custom-resource-provider update ' + '--resource-group {rg} ' + '--name "newrp"', + checks=[]) + + self.cmd('az custom-providers custom-resource-provider delete ' + '--resource-group {rg} ' + '--name "newrp"', + checks=[]) + + self.cmd('az custom-providers association delete ' + '--scope "scope" ' + '--name "associationName"', + checks=[]) diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/__init__.py b/src/custom-providers/azext_custom_providers/vendored_sdks/__init__.py new file mode 100644 index 00000000000..0260537a02b --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/__init__.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/__init__.py new file mode 100644 index 00000000000..6fa80a79fc8 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/__init__.py @@ -0,0 +1,19 @@ +# 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. +# -------------------------------------------------------------------------- + +from ._configuration import CustomProvidersClientConfiguration +from ._custom_providers_client import CustomProvidersClient +__all__ = ['CustomProvidersClient', 'CustomProvidersClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_configuration.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_configuration.py new file mode 100644 index 00000000000..b7b2545c2f0 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_configuration.py @@ -0,0 +1,49 @@ +# 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. +# -------------------------------------------------------------------------- +from msrestazure import AzureConfiguration + +from .version import VERSION + + +class CustomProvidersClientConfiguration(AzureConfiguration): + """Configuration for CustomProvidersClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The Azure subscription ID. This is a + GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(CustomProvidersClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-mgmt-customproviders/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_custom_providers_client.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_custom_providers_client.py new file mode 100644 index 00000000000..099a8d5e31b --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/_custom_providers_client.py @@ -0,0 +1,60 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import CustomProvidersClientConfiguration +from .operations import Operations +from .operations import CustomResourceProviderOperations +from .operations import AssociationsOperations +from . import models + + +class CustomProvidersClient(SDKClient): + """Allows extension of ARM control plane with custom resource providers. + + :ivar config: Configuration for client. + :vartype config: CustomProvidersClientConfiguration + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.customproviders.operations.Operations + :ivar custom_resource_provider: CustomResourceProvider operations + :vartype custom_resource_provider: azure.mgmt.customproviders.operations.CustomResourceProviderOperations + :ivar associations: Associations operations + :vartype associations: azure.mgmt.customproviders.operations.AssociationsOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The Azure subscription ID. This is a + GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = CustomProvidersClientConfiguration(credentials, subscription_id, base_url) + super(CustomProvidersClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2018-09-01-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) + self.custom_resource_provider = CustomResourceProviderOperations( + self._client, self.config, self._serialize, self._deserialize) + self.associations = AssociationsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/__init__.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/__init__.py new file mode 100644 index 00000000000..52df0f54944 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/__init__.py @@ -0,0 +1,68 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import Association + from ._models_py3 import CustomRPActionRouteDefinition + from ._models_py3 import CustomRPManifest + from ._models_py3 import CustomRPResourceTypeRouteDefinition + from ._models_py3 import CustomRPRouteDefinition + from ._models_py3 import CustomRPValidations + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import Resource + from ._models_py3 import ResourceProviderOperation + from ._models_py3 import ResourceProviderOperationDisplay + from ._models_py3 import ResourceProvidersUpdate +except (SyntaxError, ImportError): + from ._models import Association + from ._models import CustomRPActionRouteDefinition + from ._models import CustomRPManifest + from ._models import CustomRPResourceTypeRouteDefinition + from ._models import CustomRPRouteDefinition + from ._models import CustomRPValidations + from ._models import ErrorDefinition + from ._models import ErrorResponse, ErrorResponseException + from ._models import Resource + from ._models import ResourceProviderOperation + from ._models import ResourceProviderOperationDisplay + from ._models import ResourceProvidersUpdate +from ._paged_models import AssociationPaged +from ._paged_models import CustomRPManifestPaged +from ._paged_models import ResourceProviderOperationPaged +from ._custom_providers_client_enums import ( + ActionRouting, + ResourceTypeRouting, + ValidationType, + ProvisioningState, +) + +__all__ = [ + 'Association', + 'CustomRPActionRouteDefinition', + 'CustomRPManifest', + 'CustomRPResourceTypeRouteDefinition', + 'CustomRPRouteDefinition', + 'CustomRPValidations', + 'ErrorDefinition', + 'ErrorResponse', 'ErrorResponseException', + 'Resource', + 'ResourceProviderOperation', + 'ResourceProviderOperationDisplay', + 'ResourceProvidersUpdate', + 'ResourceProviderOperationPaged', + 'CustomRPManifestPaged', + 'AssociationPaged', + 'ActionRouting', + 'ResourceTypeRouting', + 'ValidationType', + 'ProvisioningState', +] diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_custom_providers_client_enums.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_custom_providers_client_enums.py new file mode 100644 index 00000000000..66c28c30a9a --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_custom_providers_client_enums.py @@ -0,0 +1,37 @@ +# 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. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class ActionRouting(str, Enum): + + proxy = "Proxy" + + +class ResourceTypeRouting(str, Enum): + + proxy = "Proxy" + proxy_cache = "Proxy,Cache" + + +class ValidationType(str, Enum): + + swagger = "Swagger" + + +class ProvisioningState(str, Enum): + + accepted = "Accepted" + deleting = "Deleting" + running = "Running" + succeeded = "Succeeded" + failed = "Failed" diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models.py new file mode 100644 index 00000000000..4f296d9d2ad --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models.py @@ -0,0 +1,440 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class Association(Model): + """The resource definition of this association. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The association id. + :vartype id: str + :ivar name: The association name. + :vartype name: str + :ivar type: The association type. + :vartype type: str + :param target_resource_id: The REST resource instance of the target + resource for this association. + :type target_resource_id: str + :ivar provisioning_state: The provisioning state of the association. + Possible values include: 'Accepted', 'Deleting', 'Running', 'Succeeded', + 'Failed' + :vartype provisioning_state: str or + ~azure.mgmt.customproviders.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Association, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.target_resource_id = kwargs.get('target_resource_id', None) + self.provisioning_state = None + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class CustomRPRouteDefinition(Model): + """A route definition that defines an action or resource that can be + interacted with through the custom resource provider. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the route definition. This becomes the + name for the ARM extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + :type name: str + :param endpoint: Required. The route definition endpoint URI that the + custom resource provider will proxy requests to. This can be in the form + of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a + path (e.g. 'https://testendpoint/{requestPath}') + :type endpoint: str + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CustomRPRouteDefinition, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.endpoint = kwargs.get('endpoint', None) + + +class CustomRPActionRouteDefinition(CustomRPRouteDefinition): + """The route definition for an action implemented by the custom resource + provider. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the route definition. This becomes the + name for the ARM extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + :type name: str + :param endpoint: Required. The route definition endpoint URI that the + custom resource provider will proxy requests to. This can be in the form + of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a + path (e.g. 'https://testendpoint/{requestPath}') + :type endpoint: str + :param routing_type: The routing types that are supported for action + requests. Possible values include: 'Proxy' + :type routing_type: str or + ~azure.mgmt.customproviders.models.ActionRouting + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'routing_type': {'key': 'routingType', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CustomRPActionRouteDefinition, self).__init__(**kwargs) + self.routing_type = kwargs.get('routing_type', None) + + +class Resource(Model): + """The resource definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = kwargs.get('location', None) + self.tags = kwargs.get('tags', None) + + +class CustomRPManifest(Resource): + """A manifest file that defines the custom resource provider resources. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + :param actions: A list of actions that the custom resource provider + implements. + :type actions: + list[~azure.mgmt.customproviders.models.CustomRPActionRouteDefinition] + :param resource_types: A list of resource types that the custom resource + provider implements. + :type resource_types: + list[~azure.mgmt.customproviders.models.CustomRPResourceTypeRouteDefinition] + :param validations: A list of validations to run on the custom resource + provider's requests. + :type validations: + list[~azure.mgmt.customproviders.models.CustomRPValidations] + :ivar provisioning_state: The provisioning state of the resource provider. + Possible values include: 'Accepted', 'Deleting', 'Running', 'Succeeded', + 'Failed' + :vartype provisioning_state: str or + ~azure.mgmt.customproviders.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'actions': {'key': 'properties.actions', 'type': '[CustomRPActionRouteDefinition]'}, + 'resource_types': {'key': 'properties.resourceTypes', 'type': '[CustomRPResourceTypeRouteDefinition]'}, + 'validations': {'key': 'properties.validations', 'type': '[CustomRPValidations]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CustomRPManifest, self).__init__(**kwargs) + self.actions = kwargs.get('actions', None) + self.resource_types = kwargs.get('resource_types', None) + self.validations = kwargs.get('validations', None) + self.provisioning_state = None + + +class CustomRPResourceTypeRouteDefinition(CustomRPRouteDefinition): + """The route definition for a resource implemented by the custom resource + provider. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the route definition. This becomes the + name for the ARM extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + :type name: str + :param endpoint: Required. The route definition endpoint URI that the + custom resource provider will proxy requests to. This can be in the form + of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a + path (e.g. 'https://testendpoint/{requestPath}') + :type endpoint: str + :param routing_type: The routing types that are supported for resource + requests. Possible values include: 'Proxy', 'Proxy,Cache' + :type routing_type: str or + ~azure.mgmt.customproviders.models.ResourceTypeRouting + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'routing_type': {'key': 'routingType', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CustomRPResourceTypeRouteDefinition, self).__init__(**kwargs) + self.routing_type = kwargs.get('routing_type', None) + + +class CustomRPValidations(Model): + """A validation to apply on custom resource provider requests. + + All required parameters must be populated in order to send to Azure. + + :param validation_type: The type of validation to run against a matching + request. Possible values include: 'Swagger' + :type validation_type: str or + ~azure.mgmt.customproviders.models.ValidationType + :param specification: Required. A link to the validation specification. + The specification must be hosted on raw.githubusercontent.com. + :type specification: str + """ + + _validation = { + 'specification': {'required': True, 'pattern': r'^https://raw.githubusercontent.com/.+'}, + } + + _attribute_map = { + 'validation_type': {'key': 'validationType', 'type': 'str'}, + 'specification': {'key': 'specification', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(CustomRPValidations, self).__init__(**kwargs) + self.validation_type = kwargs.get('validation_type', None) + self.specification = kwargs.get('specification', None) + + +class ErrorDefinition(Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar code: Service specific error code which serves as the substatus for + the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.customproviders.models.ErrorDefinition] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, + } + + def __init__(self, **kwargs): + super(ErrorDefinition, self).__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class ErrorResponse(Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.customproviders.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class ResourceProviderOperation(Model): + """Supported operations of this resource provider. + + :param name: Operation name, in format of + {provider}/{resource}/{operation} + :type name: str + :param display: Display metadata associated with the operation. + :type display: + ~azure.mgmt.customproviders.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__(self, **kwargs): + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + + +class ResourceProviderOperationDisplay(Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft Custom Providers. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class ResourceProvidersUpdate(Model): + """custom resource provider update information. + + :param tags: Resource tags + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(ResourceProvidersUpdate, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models_py3.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models_py3.py new file mode 100644 index 00000000000..08049a74bcc --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_models_py3.py @@ -0,0 +1,440 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class Association(Model): + """The resource definition of this association. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The association id. + :vartype id: str + :ivar name: The association name. + :vartype name: str + :ivar type: The association type. + :vartype type: str + :param target_resource_id: The REST resource instance of the target + resource for this association. + :type target_resource_id: str + :ivar provisioning_state: The provisioning state of the association. + Possible values include: 'Accepted', 'Deleting', 'Running', 'Succeeded', + 'Failed' + :vartype provisioning_state: str or + ~azure.mgmt.customproviders.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'target_resource_id': {'key': 'properties.targetResourceId', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__(self, *, target_resource_id: str=None, **kwargs) -> None: + super(Association, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.target_resource_id = target_resource_id + self.provisioning_state = None + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class CustomRPRouteDefinition(Model): + """A route definition that defines an action or resource that can be + interacted with through the custom resource provider. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the route definition. This becomes the + name for the ARM extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + :type name: str + :param endpoint: Required. The route definition endpoint URI that the + custom resource provider will proxy requests to. This can be in the form + of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a + path (e.g. 'https://testendpoint/{requestPath}') + :type endpoint: str + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + } + + def __init__(self, *, name: str, endpoint: str, **kwargs) -> None: + super(CustomRPRouteDefinition, self).__init__(**kwargs) + self.name = name + self.endpoint = endpoint + + +class CustomRPActionRouteDefinition(CustomRPRouteDefinition): + """The route definition for an action implemented by the custom resource + provider. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the route definition. This becomes the + name for the ARM extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + :type name: str + :param endpoint: Required. The route definition endpoint URI that the + custom resource provider will proxy requests to. This can be in the form + of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a + path (e.g. 'https://testendpoint/{requestPath}') + :type endpoint: str + :param routing_type: The routing types that are supported for action + requests. Possible values include: 'Proxy' + :type routing_type: str or + ~azure.mgmt.customproviders.models.ActionRouting + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'routing_type': {'key': 'routingType', 'type': 'str'}, + } + + def __init__(self, *, name: str, endpoint: str, routing_type=None, **kwargs) -> None: + super(CustomRPActionRouteDefinition, self).__init__(name=name, endpoint=endpoint, **kwargs) + self.routing_type = routing_type + + +class Resource(Model): + """The resource definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, *, location: str, tags=None, **kwargs) -> None: + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class CustomRPManifest(Resource): + """A manifest file that defines the custom resource provider resources. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id + :vartype id: str + :ivar name: Resource name + :vartype name: str + :ivar type: Resource type + :vartype type: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + :param actions: A list of actions that the custom resource provider + implements. + :type actions: + list[~azure.mgmt.customproviders.models.CustomRPActionRouteDefinition] + :param resource_types: A list of resource types that the custom resource + provider implements. + :type resource_types: + list[~azure.mgmt.customproviders.models.CustomRPResourceTypeRouteDefinition] + :param validations: A list of validations to run on the custom resource + provider's requests. + :type validations: + list[~azure.mgmt.customproviders.models.CustomRPValidations] + :ivar provisioning_state: The provisioning state of the resource provider. + Possible values include: 'Accepted', 'Deleting', 'Running', 'Succeeded', + 'Failed' + :vartype provisioning_state: str or + ~azure.mgmt.customproviders.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'actions': {'key': 'properties.actions', 'type': '[CustomRPActionRouteDefinition]'}, + 'resource_types': {'key': 'properties.resourceTypes', 'type': '[CustomRPResourceTypeRouteDefinition]'}, + 'validations': {'key': 'properties.validations', 'type': '[CustomRPValidations]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__(self, *, location: str, tags=None, actions=None, resource_types=None, validations=None, **kwargs) -> None: + super(CustomRPManifest, self).__init__(location=location, tags=tags, **kwargs) + self.actions = actions + self.resource_types = resource_types + self.validations = validations + self.provisioning_state = None + + +class CustomRPResourceTypeRouteDefinition(CustomRPRouteDefinition): + """The route definition for a resource implemented by the custom resource + provider. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. The name of the route definition. This becomes the + name for the ARM extension (e.g. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}/{name}') + :type name: str + :param endpoint: Required. The route definition endpoint URI that the + custom resource provider will proxy requests to. This can be in the form + of a flat URI (e.g. 'https://testendpoint/') or can specify to route via a + path (e.g. 'https://testendpoint/{requestPath}') + :type endpoint: str + :param routing_type: The routing types that are supported for resource + requests. Possible values include: 'Proxy', 'Proxy,Cache' + :type routing_type: str or + ~azure.mgmt.customproviders.models.ResourceTypeRouting + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'routing_type': {'key': 'routingType', 'type': 'str'}, + } + + def __init__(self, *, name: str, endpoint: str, routing_type=None, **kwargs) -> None: + super(CustomRPResourceTypeRouteDefinition, self).__init__(name=name, endpoint=endpoint, **kwargs) + self.routing_type = routing_type + + +class CustomRPValidations(Model): + """A validation to apply on custom resource provider requests. + + All required parameters must be populated in order to send to Azure. + + :param validation_type: The type of validation to run against a matching + request. Possible values include: 'Swagger' + :type validation_type: str or + ~azure.mgmt.customproviders.models.ValidationType + :param specification: Required. A link to the validation specification. + The specification must be hosted on raw.githubusercontent.com. + :type specification: str + """ + + _validation = { + 'specification': {'required': True, 'pattern': r'^https://raw.githubusercontent.com/.+'}, + } + + _attribute_map = { + 'validation_type': {'key': 'validationType', 'type': 'str'}, + 'specification': {'key': 'specification', 'type': 'str'}, + } + + def __init__(self, *, specification: str, validation_type=None, **kwargs) -> None: + super(CustomRPValidations, self).__init__(**kwargs) + self.validation_type = validation_type + self.specification = specification + + +class ErrorDefinition(Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar code: Service specific error code which serves as the substatus for + the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.customproviders.models.ErrorDefinition] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, + } + + def __init__(self, **kwargs) -> None: + super(ErrorDefinition, self).__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class ErrorResponse(Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.customproviders.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__(self, *, error=None, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) + + +class ResourceProviderOperation(Model): + """Supported operations of this resource provider. + + :param name: Operation name, in format of + {provider}/{resource}/{operation} + :type name: str + :param display: Display metadata associated with the operation. + :type display: + ~azure.mgmt.customproviders.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = name + self.display = display + + +class ResourceProviderOperationDisplay(Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft Custom Providers. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProvidersUpdate(Model): + """custom resource provider update information. + + :param tags: Resource tags + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, *, tags=None, **kwargs) -> None: + super(ResourceProvidersUpdate, self).__init__(**kwargs) + self.tags = tags diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_paged_models.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_paged_models.py new file mode 100644 index 00000000000..7928b4d67e2 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/models/_paged_models.py @@ -0,0 +1,53 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class ResourceProviderOperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`ResourceProviderOperation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ResourceProviderOperation]'} + } + + def __init__(self, *args, **kwargs): + + super(ResourceProviderOperationPaged, self).__init__(*args, **kwargs) +class CustomRPManifestPaged(Paged): + """ + A paging container for iterating over a list of :class:`CustomRPManifest ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[CustomRPManifest]'} + } + + def __init__(self, *args, **kwargs): + + super(CustomRPManifestPaged, self).__init__(*args, **kwargs) +class AssociationPaged(Paged): + """ + A paging container for iterating over a list of :class:`Association ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Association]'} + } + + def __init__(self, *args, **kwargs): + + super(AssociationPaged, self).__init__(*args, **kwargs) diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/__init__.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/__init__.py new file mode 100644 index 00000000000..fa463a41f90 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/__init__.py @@ -0,0 +1,20 @@ +# 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. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._custom_resource_provider_operations import CustomResourceProviderOperations +from ._associations_operations import AssociationsOperations + +__all__ = [ + 'Operations', + 'CustomResourceProviderOperations', + 'AssociationsOperations', +] diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_associations_operations.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_associations_operations.py new file mode 100644 index 00000000000..072810c650d --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_associations_operations.py @@ -0,0 +1,350 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class AssociationsOperations(object): + """AssociationsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to be used with the HTTP request. Constant value: "2018-09-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-09-01-preview" + + self.config = config + + + def _create_or_update_initial( + self, scope, association_name, target_resource_id=None, custom_headers=None, raw=False, **operation_config): + association = models.Association(target_resource_id=target_resource_id) + + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(association, 'Association') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Association', response) + if response.status_code == 201: + deserialized = self._deserialize('Association', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, scope, association_name, target_resource_id=None, custom_headers=None, raw=False, polling=True, **operation_config): + """Create or update an association. + + :param scope: The scope of the association. The scope can be any valid + REST resource instance. For example, use + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}' + for a virtual machine resource. + :type scope: str + :param association_name: The name of the association. + :type association_name: str + :param target_resource_id: The REST resource instance of the target + resource for this association. + :type target_resource_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns Association or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.customproviders.models.Association] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.customproviders.models.Association]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._create_or_update_initial( + scope=scope, + association_name=association_name, + target_resource_id=target_resource_id, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('Association', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} + + + def _delete_initial( + self, scope, association_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def delete( + self, scope, association_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Delete an association. + + :param scope: The scope of the association. + :type scope: str + :param association_name: The name of the association. + :type association_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._delete_initial( + scope=scope, + association_name=association_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} + + def get( + self, scope, association_name, custom_headers=None, raw=False, **operation_config): + """Get an association. + + :param scope: The scope of the association. + :type scope: str + :param association_name: The name of the association. + :type association_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Association or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.customproviders.models.Association or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Association', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} + + def list_all( + self, scope, custom_headers=None, raw=False, **operation_config): + """Gets all association for the given scope. + + :param scope: The scope of the association. + :type scope: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Association + :rtype: + ~azure.mgmt.customproviders.models.AssociationPaged[~azure.mgmt.customproviders.models.Association] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_all.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.AssociationPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_all.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations'} diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py new file mode 100644 index 00000000000..5eeee033cc1 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py @@ -0,0 +1,484 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class CustomResourceProviderOperations(object): + """CustomResourceProviderOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to be used with the HTTP request. Constant value: "2018-09-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-09-01-preview" + + self.config = config + + + def _create_or_update_initial( + self, resource_group_name, resource_provider_name, resource_provider, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(resource_provider, 'CustomRPManifest') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('CustomRPManifest', response) + if response.status_code == 201: + deserialized = self._deserialize('CustomRPManifest', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, resource_provider_name, resource_provider, custom_headers=None, raw=False, polling=True, **operation_config): + """Creates or updates the custom resource provider. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_name: The name of the resource provider. + :type resource_provider_name: str + :param resource_provider: The parameters required to create or update + a custom resource provider definition. + :type resource_provider: + ~azure.mgmt.customproviders.models.CustomRPManifest + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns CustomRPManifest or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.customproviders.models.CustomRPManifest] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.customproviders.models.CustomRPManifest]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + resource_provider=resource_provider, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('CustomRPManifest', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} + + + def _delete_initial( + self, resource_group_name, resource_provider_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def delete( + self, resource_group_name, resource_provider_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes the custom resource provider. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_name: The name of the resource provider. + :type resource_provider_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} + + def get( + self, resource_group_name, resource_provider_name, custom_headers=None, raw=False, **operation_config): + """Gets the custom resource provider manifest. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_name: The name of the resource provider. + :type resource_provider_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: CustomRPManifest or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.customproviders.models.CustomRPManifest or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CustomRPManifest', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} + + def update( + self, resource_group_name, resource_provider_name, tags=None, custom_headers=None, raw=False, **operation_config): + """Updates an existing custom resource provider. The only value that can + be updated via PATCH currently is the tags. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_name: The name of the resource provider. + :type resource_provider_name: str + :param tags: Resource tags + :type tags: dict[str, str] + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: CustomRPManifest or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.customproviders.models.CustomRPManifest or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + patchable_resource = models.ResourceProvidersUpdate(tags=tags) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(patchable_resource, 'ResourceProvidersUpdate') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CustomRPManifest', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} + + def list_by_resource_group( + self, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Gets all the custom resource providers within a resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of CustomRPManifest + :rtype: + ~azure.mgmt.customproviders.models.CustomRPManifestPaged[~azure.mgmt.customproviders.models.CustomRPManifest] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.CustomRPManifestPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'} + + def list_by_subscription( + self, custom_headers=None, raw=False, **operation_config): + """Gets all the custom resource providers within a subscription. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of CustomRPManifest + :rtype: + ~azure.mgmt.customproviders.models.CustomRPManifestPaged[~azure.mgmt.customproviders.models.CustomRPManifest] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.CustomRPManifestPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'} diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_operations.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_operations.py new file mode 100644 index 00000000000..3e58a7db597 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/operations/_operations.py @@ -0,0 +1,100 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class Operations(object): + """Operations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to be used with the HTTP request. Constant value: "2018-09-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-09-01-preview" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """The list of operations provided by Microsoft CustomProviders. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ResourceProviderOperation + :rtype: + ~azure.mgmt.customproviders.models.ResourceProviderOperationPaged[~azure.mgmt.customproviders.models.ResourceProviderOperation] + :raises: + :class:`ErrorResponseException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ResourceProviderOperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.CustomProviders/operations'} diff --git a/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/version.py b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/version.py new file mode 100644 index 00000000000..e0ec669828c --- /dev/null +++ b/src/custom-providers/azext_custom_providers/vendored_sdks/customproviders/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" + diff --git a/src/custom-providers/setup.cfg b/src/custom-providers/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/src/custom-providers/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/custom-providers/setup.py b/src/custom-providers/setup.py new file mode 100644 index 00000000000..f06e0f6d515 --- /dev/null +++ b/src/custom-providers/setup.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='custom_providers', + version=VERSION, + description='Microsoft Azure Command-Line Tools Custom Providers Extension', + # TODO: Update author and email, if applicable + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + # TODO: consider pointing directly to your source code instead of the generic repo + url='https://github.com/Azure/azure-cli-extensions', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_custom_providers': ['azext_metadata.json']}, +) From 829503dad8eb88caabb74fbb2dc8b839e9c5b9c6 Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Mon, 27 Apr 2020 14:14:31 +0800 Subject: [PATCH 2/6] [Breadth Coverage] Support customproviders (draft) --- .../azext_custom_providers/_help.py | 24 +++---- .../azext_custom_providers/_params.py | 41 ++++++------ .../azext_custom_providers/commands.py | 6 +- .../azext_custom_providers/custom.py | 64 ++++++++----------- 4 files changed, 61 insertions(+), 74 deletions(-) diff --git a/src/custom-providers/azext_custom_providers/_help.py b/src/custom-providers/azext_custom_providers/_help.py index 506e030ae1a..e5d62383259 100644 --- a/src/custom-providers/azext_custom_providers/_help.py +++ b/src/custom-providers/azext_custom_providers/_help.py @@ -9,59 +9,59 @@ from knack.help_files import helps # pylint: disable=unused-import -helps['custom-providers custom-resource-provider'] = """ +helps['custom-providers resource-provider'] = """ type: group short-summary: Commands to manage custom resource provider. """ -helps['custom-providers custom-resource-provider create'] = """ +helps['custom-providers resource-provider create'] = """ type: command short-summary: Creates or updates the custom resource provider. examples: - name: Create or update the custom resource provider text: |- - az custom-providers custom-resource-provider create --resource-group "testRG" --name \\ + az custom-providers resource-provider create --resource-group "testRG" --name \\ "newrp" --location "eastus" """ -helps['custom-providers custom-resource-provider update'] = """ +helps['custom-providers resource-provider update'] = """ type: command short-summary: Creates or updates the custom resource provider. examples: - name: Update a custom resource provider text: |- - az custom-providers custom-resource-provider update --resource-group "testRG" --name \\ + az custom-providers resource-provider update --resource-group "testRG" --name \\ "newrp" """ -helps['custom-providers custom-resource-provider delete'] = """ +helps['custom-providers resource-provider delete'] = """ type: command short-summary: Deletes the custom resource provider. examples: - name: Delete a custom resource provider text: |- - az custom-providers custom-resource-provider delete --resource-group "testRG" --name \\ + az custom-providers resource-provider delete --resource-group "testRG" --name \\ "newrp" """ -helps['custom-providers custom-resource-provider show'] = """ +helps['custom-providers resource-provider show'] = """ type: command short-summary: Gets the custom resource provider manifest. examples: - name: Get a custom resource provider text: |- - az custom-providers custom-resource-provider show --resource-group "testRG" --name \\ + az custom-providers resource-provider show --resource-group "testRG" --name \\ "newrp" """ -helps['custom-providers custom-resource-provider list'] = """ +helps['custom-providers resource-provider list'] = """ type: command short-summary: Gets all the custom resource providers within a resource group. examples: - name: List all custom resource providers on the resourceGroup text: |- - az custom-providers custom-resource-provider list --resource-group "testRG" + az custom-providers resource-provider list --resource-group "testRG" - name: List all custom resource providers on the subscription text: |- - az custom-providers custom-resource-provider list + az custom-providers resource-provider list """ diff --git a/src/custom-providers/azext_custom_providers/_params.py b/src/custom-providers/azext_custom_providers/_params.py index bb4f291ee93..c2420f3a266 100644 --- a/src/custom-providers/azext_custom_providers/_params.py +++ b/src/custom-providers/azext_custom_providers/_params.py @@ -9,37 +9,36 @@ from azure.cli.core.commands.parameters import ( tags_type, resource_group_name_type, - get_location_type -) + get_location_type, + name_type) +from azure.cli.core.commands.validators import get_default_location_from_resource_group +from knack.arguments import CLIArgumentType def load_arguments(self, _): + resource_provider_name_type = CLIArgumentType(arg_type=name_type, help='The name of the resource provider.') - with self.argument_context('custom-providers custom-resource-provider create') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the resource provider.') - c.argument('location', arg_type=get_location_type(self.cli_ctx)) + with self.argument_context('custom-providers resource-provider create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', resource_provider_name_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group) c.argument('tags', tags_type) c.argument('actions', id_part=None, help='A list of actions that the custom resource provider implements.', nargs='+') c.argument('resource_types', id_part=None, help='A list of resource types that the custom resource provider implements.', nargs='+') c.argument('validations', id_part=None, help='A list of validations to run on the custom resource provider\'s requests.', nargs='+') - with self.argument_context('custom-providers custom-resource-provider update') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the resource provider.') - c.argument('location', arg_type=get_location_type(self.cli_ctx)) + with self.argument_context('custom-providers resource-provider update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', resource_provider_name_type) c.argument('tags', tags_type) - c.argument('actions', id_part=None, help='A list of actions that the custom resource provider implements.', nargs='+') - c.argument('resource_types', id_part=None, help='A list of resource types that the custom resource provider implements.', nargs='+') - c.argument('validations', id_part=None, help='A list of validations to run on the custom resource provider\'s requests.', nargs='+') - with self.argument_context('custom-providers custom-resource-provider delete') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the resource provider.') + with self.argument_context('custom-providers resource-provider delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', resource_provider_name_type) - with self.argument_context('custom-providers custom-resource-provider show') as c: - c.argument('resource_group', resource_group_name_type) - c.argument('name', id_part=None, help='The name of the resource provider.') + with self.argument_context('custom-providers resource-provider show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', resource_provider_name_type) - with self.argument_context('custom-providers custom-resource-provider list') as c: - c.argument('resource_group', resource_group_name_type) + with self.argument_context('custom-providers resource-provider list') as c: + c.argument('resource_group_name', resource_group_name_type) diff --git a/src/custom-providers/azext_custom_providers/commands.py b/src/custom-providers/azext_custom_providers/commands.py index 369c92bb6c7..24fd89b6517 100644 --- a/src/custom-providers/azext_custom_providers/commands.py +++ b/src/custom-providers/azext_custom_providers/commands.py @@ -16,9 +16,9 @@ def load_command_table(self, _): custom_providers_custom_resource_provider = CliCommandType( operations_tmpl='azext_custom_providers.vendored_sdks.customproviders.operations._custom_resource_provider_operations#CustomResourceProviderOperations.{}', client_factory=cf_custom_resource_provider) - with self.command_group('custom-providers custom-resource-provider', custom_providers_custom_resource_provider, client_factory=cf_custom_resource_provider) as g: - g.custom_command('create', 'create_custom_providers_custom_resource_provider') + with self.command_group('custom-providers resource-provider', custom_providers_custom_resource_provider, client_factory=cf_custom_resource_provider) as g: + g.custom_command('create', 'create_custom_providers_custom_resource_provider', supports_no_wait=True) g.custom_command('update', 'update_custom_providers_custom_resource_provider') - g.custom_command('delete', 'delete_custom_providers_custom_resource_provider') + g.custom_command('delete', 'delete_custom_providers_custom_resource_provider', supports_no_wait=True, confirmation=True) g.custom_show_command('show', 'get_custom_providers_custom_resource_provider') g.custom_command('list', 'list_custom_providers_custom_resource_provider') diff --git a/src/custom-providers/azext_custom_providers/custom.py b/src/custom-providers/azext_custom_providers/custom.py index 719258fbc8d..28388a42250 100644 --- a/src/custom-providers/azext_custom_providers/custom.py +++ b/src/custom-providers/azext_custom_providers/custom.py @@ -7,61 +7,49 @@ # pylint: disable=too-many-lines # pylint: disable=too-many-locals # pylint: disable=unused-argument +from azure.cli.core.util import sdk_no_wait -def create_custom_providers_custom_resource_provider(cmd, client, - resource_group, - name, - location, +def create_custom_providers_custom_resource_provider(client, + resource_group_name, + resource_provider_name, + location=None, tags=None, actions=None, resource_types=None, - validations=None): + validations=None, + no_wait=False): body = {} body['location'] = location # str body['tags'] = tags # dictionary body['actions'] = actions body['resource_types'] = resource_types body['validations'] = validations - return client.create_or_update(resource_group_name=resource_group, resource_provider_name=name, resource_provider=body) + return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, resource_provider_name=resource_provider_name, resource_provider=body) -def update_custom_providers_custom_resource_provider(cmd, client, - resource_group, - name, - location=None, - tags=None, - actions=None, - resource_types=None, - validations=None): - body = {} - if location is not None: - body['location'] = location # str - if tags is not None: - body['tags'] = tags # dictionary - if actions is not None: - body['actions'] = actions - if resource_types is not None: - body['resource_types'] = resource_types - if validations is not None: - body['validations'] = validations - return client.create_or_update(resource_group_name=resource_group, resource_provider_name=name, resource_provider=body) +def update_custom_providers_custom_resource_provider(client, + resource_group_name, + resource_provider_name, + tags=None): + return client.update(resource_group_name=resource_group_name, resource_provider_name=resource_provider_name, tags=tags) -def delete_custom_providers_custom_resource_provider(cmd, client, - resource_group, - name): - return client.delete(resource_group_name=resource_group, resource_provider_name=name) +def delete_custom_providers_custom_resource_provider(client, + resource_group_name, + resource_provider_name, + no_wait=False): + return sdk_no_wait(no_wait, client.delete, resource_group_name=resource_group_name, resource_provider_name=resource_provider_name) -def get_custom_providers_custom_resource_provider(cmd, client, - resource_group, - name): - return client.get(resource_group_name=resource_group, resource_provider_name=name) +def get_custom_providers_custom_resource_provider(client, + resource_group_name, + resource_provider_name): + return client.get(resource_group_name=resource_group_name, resource_provider_name=resource_provider_name) -def list_custom_providers_custom_resource_provider(cmd, client, - resource_group=None): - if resource_group is not None: - return client.list_by_resource_group(resource_group_name=resource_group) +def list_custom_providers_custom_resource_provider(client, + resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name=resource_group_name) return client.list_by_subscription() From 4439b97aaf4692b9558693398745c4b72a98da2e Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Thu, 30 Apr 2020 14:51:45 +0800 Subject: [PATCH 3/6] [Breadth Coverage]: Support custom providers --- src/custom-providers/README.md | 59 ++- .../azext_custom_providers/_help.py | 69 ++- .../azext_custom_providers/_params.py | 39 +- .../azext_custom_providers/actions.py | 44 ++ .../azext_metadata.json | 4 +- .../azext_custom_providers/commands.py | 2 +- .../azext_custom_providers/custom.py | 9 +- ...test_custom_providers_common_scenario.yaml | 458 ++++++++++++++++++ .../latest/test_custom-providers_scenario.py | 110 +++-- src/custom-providers/setup.py | 4 +- 10 files changed, 683 insertions(+), 115 deletions(-) create mode 100644 src/custom-providers/azext_custom_providers/actions.py create mode 100644 src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml diff --git a/src/custom-providers/README.md b/src/custom-providers/README.md index 48f776d9b2d..f1683e07800 100644 --- a/src/custom-providers/README.md +++ b/src/custom-providers/README.md @@ -1,5 +1,56 @@ -Microsoft Azure CLI 'custom-providers' Extension -========================================== +# Azure CLI Custom Providers Extension # +This is a extension for Custom Providers features. -This package is for the 'custom-providers' extension. -i.e. 'az custom-providers' +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name custom-providers +``` + +### Included Features +#### Manage custom resource provider: + + +##### Create or update a custom resource provider. + +``` +az custom-providers resource-provider create \ + -n MyRP \ + -g MyRG \ + --action name=ping endpoint=https://test.azurewebsites.net/api routing_type=Proxy \ + --resource-type name=users endpoint=https://test.azurewebsites.net/api routing_type="Proxy, Cache" \ + --validation validation_type=swagger specification=https://raw.githubusercontent.com/test.json +``` + +##### Update the tags for a custom resource provider.. +``` +az custom-providers resource-provider update \ + -g MyRG \ + -n MyRP \ + --tags a=b +``` + +##### Get a custom resource provider. +``` +az custom-providers resource-provider show \ + -g MyRG \ + -n MyRP +``` + +##### Get all the custom resource providers within a resource group or in the current subscription. +``` +az custom-providers resource-provider list +``` +``` +az custom-providers resource-provider list \ + -g MyRG +``` + +##### Delete a custom resource provider.. +``` +az custom-providers resource-provider delete \ + -g MyRG \ + -n MyRP +``` + +If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues. \ No newline at end of file diff --git a/src/custom-providers/azext_custom_providers/_help.py b/src/custom-providers/azext_custom_providers/_help.py index e5d62383259..dff889b48d3 100644 --- a/src/custom-providers/azext_custom_providers/_help.py +++ b/src/custom-providers/azext_custom_providers/_help.py @@ -16,52 +16,81 @@ helps['custom-providers resource-provider create'] = """ type: command - short-summary: Creates or updates the custom resource provider. + short-summary: Create or update the custom resource provider. + parameters: + - name: --action -a + short-summary: Add an action to the custom resource provider. + long-summary: | + Usage: --action name=ping endpoint="https://test.azurewebsites.net/api/{requestPath}" routing_type=Proxy + + name: Required. The name of the action. + endpoint: Required. The endpoint URI that the custom resource provider will proxy requests to. + routing_type: The routing types that are supported for action requests. Possible values include: 'Proxy'. + + Multiple actions can be specified by using more than one `--action` argument. + - name: --resource-type -r + short-summary: Add a custom resource type to the custom resource provider. + long-summary: | + Usage: --resource-type name=user endpoint="https://test.azurewebsites.net/api/{requestPath}" routing_type="Proxy, Cache" + + name: Required. The name of the resource type. + endpoint: Required. The endpoint URI that the custom resource provider will proxy requests to. + routing_type: The routing types that are supported for resource requests. Possible values include: 'Proxy', 'Proxy,Cache'. + + Multiple resource types can be specified by using more than one `--resource-type` argument. + - name: --validation -v + short-summary: Add a validation to the custom resource provider. + long-summary: | + Usage: --validation specification="https://raw.githubusercontent.com/" validation_type="Swagger" + + specification: A link to the validation specification.vThe specification must be hosted on raw.githubusercontent.com. + validation_type: The type of validation to run against a matching request. Possible values include: 'Swagger'. + + Multiple validations can be specified by using more than one `--validation` argument. examples: - - name: Create or update the custom resource provider + - name: Create or update a custom resource provider. text: |- - az custom-providers resource-provider create --resource-group "testRG" --name \\ - "newrp" --location "eastus" + az custom-providers resource-provider create -n MyRP -g MyRG \\ + --action name=ping endpoint=https://test.azurewebsites.net/api routing_type=Proxy \\ + --resource-type name=users endpoint=https://test.azurewebsites.net/api routing_type="Proxy, Cache" \\ + --validation validation_type=swagger specification=https://raw.githubusercontent.com/test.json """ helps['custom-providers resource-provider update'] = """ type: command - short-summary: Creates or updates the custom resource provider. + short-summary: Update the custom resource provider. Only tags can be updated. examples: - - name: Update a custom resource provider + - name: Update the tags for a custom resource provider. text: |- - az custom-providers resource-provider update --resource-group "testRG" --name \\ - "newrp" + az custom-providers resource-provider update -g MyRG -n MyRP --tags a=b """ helps['custom-providers resource-provider delete'] = """ type: command - short-summary: Deletes the custom resource provider. + short-summary: Delete the custom resource provider. examples: - - name: Delete a custom resource provider + - name: Delete a custom resource provider. text: |- - az custom-providers resource-provider delete --resource-group "testRG" --name \\ - "newrp" + az custom-providers resource-provider delete -g MyRG -n MyRP """ helps['custom-providers resource-provider show'] = """ type: command - short-summary: Gets the custom resource provider manifest. + short-summary: Get the properties for the custom resource provider. examples: - - name: Get a custom resource provider + - name: Get a custom resource provider. text: |- - az custom-providers resource-provider show --resource-group "testRG" --name \\ - "newrp" + az custom-providers resource-provider show -g MyRG -n MyRP """ helps['custom-providers resource-provider list'] = """ type: command - short-summary: Gets all the custom resource providers within a resource group. + short-summary: Get all the custom resource providers within a resource group or in the current subscription. examples: - - name: List all custom resource providers on the resourceGroup + - name: List all custom resource providers in the resource group. text: |- - az custom-providers resource-provider list --resource-group "testRG" - - name: List all custom resource providers on the subscription + az custom-providers resource-provider list -g MyRG + - name: List all custom resource providers in the current subscription. text: |- az custom-providers resource-provider list """ diff --git a/src/custom-providers/azext_custom_providers/_params.py b/src/custom-providers/azext_custom_providers/_params.py index c2420f3a266..a4dc6f04469 100644 --- a/src/custom-providers/azext_custom_providers/_params.py +++ b/src/custom-providers/azext_custom_providers/_params.py @@ -2,43 +2,22 @@ # 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 ( tags_type, - resource_group_name_type, get_location_type, name_type) from azure.cli.core.commands.validators import get_default_location_from_resource_group -from knack.arguments import CLIArgumentType +from .actions import (ActionAddAction, ResourceTypeAddAction, ValidationAddAction) def load_arguments(self, _): - resource_provider_name_type = CLIArgumentType(arg_type=name_type, help='The name of the resource provider.') - - with self.argument_context('custom-providers resource-provider create') as c: - c.argument('resource_group_name', resource_group_name_type) - c.argument('resource_provider_name', resource_provider_name_type) - c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group) - c.argument('tags', tags_type) - c.argument('actions', id_part=None, help='A list of actions that the custom resource provider implements.', nargs='+') - c.argument('resource_types', id_part=None, help='A list of resource types that the custom resource provider implements.', nargs='+') - c.argument('validations', id_part=None, help='A list of validations to run on the custom resource provider\'s requests.', nargs='+') - - with self.argument_context('custom-providers resource-provider update') as c: - c.argument('resource_group_name', resource_group_name_type) - c.argument('resource_provider_name', resource_provider_name_type) + with self.argument_context('custom-providers resource-provider') as c: + c.argument('resource_provider_name', arg_type=name_type, help='The name of the resource provider.') + c.argument('location', + arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) c.argument('tags', tags_type) - - with self.argument_context('custom-providers resource-provider delete') as c: - c.argument('resource_group_name', resource_group_name_type) - c.argument('resource_provider_name', resource_provider_name_type) - - with self.argument_context('custom-providers resource-provider show') as c: - c.argument('resource_group_name', resource_group_name_type) - c.argument('resource_provider_name', resource_provider_name_type) - - with self.argument_context('custom-providers resource-provider list') as c: - c.argument('resource_group_name', resource_group_name_type) + c.argument('actions', options_list=['--action', '-a'], action=ActionAddAction, nargs='+') + c.argument('resource_types', options_list=['--resource-type', '-r'], action=ResourceTypeAddAction, nargs='+') + c.argument('validations', options_list=['--validation', '-v'], action=ValidationAddAction, nargs='+') diff --git a/src/custom-providers/azext_custom_providers/actions.py b/src/custom-providers/azext_custom_providers/actions.py new file mode 100644 index 00000000000..e38a48a6924 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/actions.py @@ -0,0 +1,44 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=protected-access +# pylint: disable=line-too-long +# pylint: disable=too-few-public-methods +import argparse +from knack.util import CLIError + + +class ActionAddAction(argparse._AppendAction): + + def __call__(self, parser, namespace, values, option_string=None): + from azext_custom_providers.vendored_sdks.customproviders.models import CustomRPActionRouteDefinition as model + action = get_object(values, option_string, model) + super(ActionAddAction, self).__call__(parser, namespace, action, option_string) + + +class ResourceTypeAddAction(argparse._AppendAction): + + def __call__(self, parser, namespace, values, option_string=None): + from azext_custom_providers.vendored_sdks.customproviders.models import CustomRPResourceTypeRouteDefinition as model + resource_type = get_object(values, option_string, model) + super(ResourceTypeAddAction, self).__call__(parser, namespace, resource_type, option_string) + + +class ValidationAddAction(argparse._AppendAction): + + def __call__(self, parser, namespace, values, option_string=None): + from azext_custom_providers.vendored_sdks.customproviders.models import CustomRPValidations as model + validation = get_object(values, option_string, model) + super(ValidationAddAction, self).__call__(parser, namespace, validation, option_string) + + +def get_object(values, option_string, model): + kwargs = {} + for item in values: + try: + key, value = item.split('=', 1) + kwargs[key] = value + except ValueError: + raise CLIError('usage error: {} KEY=VALUE [KEY=VALUE ...]'.format(option_string)) + return model(**kwargs) diff --git a/src/custom-providers/azext_custom_providers/azext_metadata.json b/src/custom-providers/azext_custom_providers/azext_metadata.json index 55c81bf3328..13025150393 100644 --- a/src/custom-providers/azext_custom_providers/azext_metadata.json +++ b/src/custom-providers/azext_custom_providers/azext_metadata.json @@ -1,4 +1,4 @@ { - "azext.isPreview": true, - "azext.minCliCoreVersion": "2.0.67" + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.3.1" } \ No newline at end of file diff --git a/src/custom-providers/azext_custom_providers/commands.py b/src/custom-providers/azext_custom_providers/commands.py index 24fd89b6517..f4675335515 100644 --- a/src/custom-providers/azext_custom_providers/commands.py +++ b/src/custom-providers/azext_custom_providers/commands.py @@ -16,7 +16,7 @@ def load_command_table(self, _): custom_providers_custom_resource_provider = CliCommandType( operations_tmpl='azext_custom_providers.vendored_sdks.customproviders.operations._custom_resource_provider_operations#CustomResourceProviderOperations.{}', client_factory=cf_custom_resource_provider) - with self.command_group('custom-providers resource-provider', custom_providers_custom_resource_provider, client_factory=cf_custom_resource_provider) as g: + with self.command_group('custom-providers resource-provider', custom_providers_custom_resource_provider, client_factory=cf_custom_resource_provider, is_experimental=True) as g: g.custom_command('create', 'create_custom_providers_custom_resource_provider', supports_no_wait=True) g.custom_command('update', 'update_custom_providers_custom_resource_provider') g.custom_command('delete', 'delete_custom_providers_custom_resource_provider', supports_no_wait=True, confirmation=True) diff --git a/src/custom-providers/azext_custom_providers/custom.py b/src/custom-providers/azext_custom_providers/custom.py index 28388a42250..240586f9211 100644 --- a/src/custom-providers/azext_custom_providers/custom.py +++ b/src/custom-providers/azext_custom_providers/custom.py @@ -19,12 +19,9 @@ def create_custom_providers_custom_resource_provider(client, resource_types=None, validations=None, no_wait=False): - body = {} - body['location'] = location # str - body['tags'] = tags # dictionary - body['actions'] = actions - body['resource_types'] = resource_types - body['validations'] = validations + body = {'location': location, 'tags': tags, + 'actions': actions, 'resource_types': resource_types, + 'validations': validations} return sdk_no_wait(no_wait, client.create_or_update, resource_group_name=resource_group_name, resource_provider_name=resource_provider_name, resource_provider=body) diff --git a/src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml b/src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml new file mode 100644 index 00000000000..b686a3a97b6 --- /dev/null +++ b/src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml @@ -0,0 +1,458 @@ +interactions: +- request: + body: '{"location": "westus2", "properties": {"actions": [{"name": "ping", "endpoint": + "https://ayniadjso4lay.azurewebsites.net/api", "routingType": "Proxy"}], "resourceTypes": + [{"name": "users", "endpoint": "https://ayniadjso4lay.azurewebsites.net/api", + "routingType": "Proxy, Cache"}], "validations": [{"validationType": "swagger", + "specification": "https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider create + Connection: + - keep-alive + Content-Length: + - '421' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --location --action --resource-type --validation + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview + response: + body: + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Accepted"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + cache-control: + - no-cache + content-length: + - '749' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:34:30 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider create + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name --location --action --resource-type --validation + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + response: + body: + string: '{"status":"Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:34:47 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider create + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name --location --action --resource-type --validation + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview + response: + body: + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}' + headers: + cache-control: + - no-cache + content-length: + - '750' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:34:47 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider show + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview + response: + body: + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}' + headers: + cache-control: + - no-cache + content-length: + - '750' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:34:51 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider list + Connection: + - keep-alive + ParameterSetName: + - --resource-group + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders?api-version=2018-09-01-preview + response: + body: + string: '{"value":[{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}]}' + headers: + cache-control: + - no-cache + content-length: + - '762' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:34:53 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"tags": {"a": "b"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider update + Connection: + - keep-alive + Content-Length: + - '20' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - --resource-group --name --tags + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + accept-language: + - en-US + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview + response: + body: + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{"a":"b"}}' + headers: + cache-control: + - no-cache + content-length: + - '757' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:34:56 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1197' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --resource-group --name -y + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + accept-language: + - en-US + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview + response: + body: + string: 'null' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:34:58 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationresults/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14998' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider delete + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name -y + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + response: + body: + string: '{"status":"Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 30 Apr 2020 03:35:15 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - custom-providers resource-provider show + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name + User-Agent: + - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 + azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Thu, 30 Apr 2020 03:35:19 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 404 + message: Not Found +version: 1 diff --git a/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py b/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py index 173441b98b7..aee2ed84e18 100644 --- a/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py +++ b/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py @@ -3,68 +3,80 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -import os -import unittest - -from azure_devtools.scenario_tests import AllowLargeResponse from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) -TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) - - -class CustomprovidersScenarioTest(ScenarioTest): +class CustomProvidersScenarioTest(ScenarioTest): @ResourceGroupPreparer(name_prefix='cli_test_custom_providers') - def test_custom_providers(self, resource_group): + def test_custom_providers_common_scenario(self): - self.cmd('az custom-providers association create ' - '--scope "scope" ' - '--name "associationName" ' - '--target-resource-id "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group }}/providers/Microsoft.Solutions/applications/{{ application_name }}"', - checks=[]) + rp_name = self.create_random_name('clitest-crp', 20) + self.kwargs.update({ + 'rp_name': rp_name + }) - self.cmd('az custom-providers custom-resource-provider create ' + self.cmd('az custom-providers resource-provider create ' '--resource-group {rg} ' - '--name "newrp" ' - '--location "eastus"', - checks=[]) - - self.cmd('az custom-providers custom-resource-provider show ' + '--name {rp_name} ' + '--location westus2 ' + '--action ' + 'name=ping ' + 'endpoint=https://ayniadjso4lay.azurewebsites.net/api ' + 'routing_type=Proxy ' + '--resource-type ' + 'name=users ' + 'endpoint=https://ayniadjso4lay.azurewebsites.net/api ' + 'routing_type="Proxy, Cache" ' + '--validation ' + 'validation_type=swagger ' + 'specification=https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json', + checks=[ + self.check('provisioningState', 'Succeeded'), + self.check('name', rp_name), + self.check('actions[0].name', 'ping'), + self.check('resourceTypes[0].name', 'users'), + self.check('validations[0].validationType', 'Swagger') + ]) + + self.cmd('az custom-providers resource-provider show ' '--resource-group {rg} ' - '--name "newrp"', - checks=[]) - - self.cmd('az custom-providers custom-resource-provider list ' + '--name {rp_name}', + checks=[ + self.check('provisioningState', 'Succeeded'), + self.check('name', rp_name), + self.check('actions[0].name', 'ping'), + self.check('actions[0].endpoint', 'https://ayniadjso4lay.azurewebsites.net/api'), + self.check('actions[0].routingType', 'Proxy'), + self.check('resourceTypes[0].name', 'users'), + self.check('resourceTypes[0].endpoint', 'https://ayniadjso4lay.azurewebsites.net/api'), + self.check('resourceTypes[0].routingType', 'Proxy, Cache'), + self.check('validations[0].validationType', 'Swagger'), + self.check('validations[0].specification', + 'https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json') + ]) + + self.cmd('az custom-providers resource-provider list ' '--resource-group {rg}', - checks=[]) - - self.cmd('az custom-providers custom-resource-provider list', - checks=[]) - - self.cmd('az custom-providers association show ' - '--scope "scope" ' - '--name "associationName"', - checks=[]) - - self.cmd('az custom-providers association list ' - '--scope "scope"', - checks=[]) + checks=[ + self.check('length(@)', 1) + ]) - self.cmd('az custom-providers operation list', - checks=[]) - - self.cmd('az custom-providers custom-resource-provider update ' + self.cmd('az custom-providers resource-provider update ' '--resource-group {rg} ' - '--name "newrp"', - checks=[]) + '--name {rp_name} ' + '--tags a=b', + checks=[ + self.check('tags.a', 'b'), + ]) - self.cmd('az custom-providers custom-resource-provider delete ' + self.cmd('az custom-providers resource-provider delete ' '--resource-group {rg} ' - '--name "newrp"', + '--name {rp_name} ' + '-y', checks=[]) - self.cmd('az custom-providers association delete ' - '--scope "scope" ' - '--name "associationName"', - checks=[]) + self.cmd('az custom-providers resource-provider show ' + '--resource-group {rg} ' + '--name {rp_name}', + expect_failure=True) diff --git a/src/custom-providers/setup.py b/src/custom-providers/setup.py index f06e0f6d515..149ceed2817 100644 --- a/src/custom-providers/setup.py +++ b/src/custom-providers/setup.py @@ -25,8 +25,6 @@ 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', @@ -43,7 +41,7 @@ HISTORY = f.read() setup( - name='custom_providers', + name='custom-providers', version=VERSION, description='Microsoft Azure Command-Line Tools Custom Providers Extension', # TODO: Update author and email, if applicable From 635e56443a3b897384aa5784f151d9371a76b5be Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Thu, 30 Apr 2020 15:05:42 +0800 Subject: [PATCH 4/6] add code owner for custom-providers extension --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 09173350abc..de95fdd2b38 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -119,3 +119,5 @@ /src/log-analytics-solution/ @zhoxing-ms /src/kusto/ @ilayr @orhasban @astauben + +/src/custom-providers/ @jsntcy From ed025bfb55950f850eece2dddac7b96fc85c9cf1 Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Fri, 8 May 2020 18:05:41 +0800 Subject: [PATCH 5/6] refine the format for help and readme --- src/custom-providers/README.md | 37 ++---- .../azext_custom_providers/_help.py | 124 +++++++++--------- 2 files changed, 74 insertions(+), 87 deletions(-) diff --git a/src/custom-providers/README.md b/src/custom-providers/README.md index f1683e07800..e675d470514 100644 --- a/src/custom-providers/README.md +++ b/src/custom-providers/README.md @@ -1,7 +1,7 @@ -# Azure CLI Custom Providers Extension # +# Azure CLI Custom Providers Extension This is a extension for Custom Providers features. -### How to use ### +### How to use Install this extension using the below CLI command ``` az extension add --name custom-providers @@ -11,46 +11,33 @@ az extension add --name custom-providers #### Manage custom resource provider: -##### Create or update a custom resource provider. +##### Create or update a custom resource provider ``` -az custom-providers resource-provider create \ - -n MyRP \ - -g MyRG \ - --action name=ping endpoint=https://test.azurewebsites.net/api routing_type=Proxy \ - --resource-type name=users endpoint=https://test.azurewebsites.net/api routing_type="Proxy, Cache" \ - --validation validation_type=swagger specification=https://raw.githubusercontent.com/test.json +az custom-providers resource-provider create -n MyRP -g MyRG --action name=ping endpoint=https://test.azurewebsites.net/api routing_type=Proxy --resource-type name=users endpoint=https://test.azurewebsites.net/api routing_type="Proxy, Cache" --validation validation_type=swagger specification=https://raw.githubusercontent.com/test.json ``` -##### Update the tags for a custom resource provider.. +##### Update the tags for a custom resource provider ``` -az custom-providers resource-provider update \ - -g MyRG \ - -n MyRP \ - --tags a=b +az custom-providers resource-provider update -g MyRG -n MyRP --tags a=b ``` -##### Get a custom resource provider. +##### Get a custom resource provider ``` -az custom-providers resource-provider show \ - -g MyRG \ - -n MyRP +az custom-providers resource-provider show -g MyRG -n MyRP ``` -##### Get all the custom resource providers within a resource group or in the current subscription. +##### Get all the custom resource providers within a resource group or in the current subscription ``` az custom-providers resource-provider list ``` ``` -az custom-providers resource-provider list \ - -g MyRG +az custom-providers resource-provider list -g MyRG ``` -##### Delete a custom resource provider.. +##### Delete a custom resource provider ``` -az custom-providers resource-provider delete \ - -g MyRG \ - -n MyRP +az custom-providers resource-provider delete -g MyRG -n MyRP ``` If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues. \ No newline at end of file diff --git a/src/custom-providers/azext_custom_providers/_help.py b/src/custom-providers/azext_custom_providers/_help.py index dff889b48d3..5709cbf6eb2 100644 --- a/src/custom-providers/azext_custom_providers/_help.py +++ b/src/custom-providers/azext_custom_providers/_help.py @@ -10,87 +10,87 @@ helps['custom-providers resource-provider'] = """ - type: group - short-summary: Commands to manage custom resource provider. +type: group +short-summary: Commands to manage custom resource provider. """ helps['custom-providers resource-provider create'] = """ - type: command - short-summary: Create or update the custom resource provider. - parameters: - - name: --action -a - short-summary: Add an action to the custom resource provider. - long-summary: | - Usage: --action name=ping endpoint="https://test.azurewebsites.net/api/{requestPath}" routing_type=Proxy +type: command +short-summary: Create or update the custom resource provider. +parameters: + - name: --action -a + short-summary: Add an action to the custom resource provider. + long-summary: | + Usage: --action name=ping endpoint="https://test.azurewebsites.net/api/{requestPath}" routing_type=Proxy - name: Required. The name of the action. - endpoint: Required. The endpoint URI that the custom resource provider will proxy requests to. - routing_type: The routing types that are supported for action requests. Possible values include: 'Proxy'. + name: Required. The name of the action. + endpoint: Required. The endpoint URI that the custom resource provider will proxy requests to. + routing_type: The routing types that are supported for action requests. Possible values include: 'Proxy'. - Multiple actions can be specified by using more than one `--action` argument. - - name: --resource-type -r - short-summary: Add a custom resource type to the custom resource provider. - long-summary: | - Usage: --resource-type name=user endpoint="https://test.azurewebsites.net/api/{requestPath}" routing_type="Proxy, Cache" + Multiple actions can be specified by using more than one `--action` argument. + - name: --resource-type -r + short-summary: Add a custom resource type to the custom resource provider. + long-summary: | + Usage: --resource-type name=user endpoint="https://test.azurewebsites.net/api/{requestPath}" routing_type="Proxy, Cache" - name: Required. The name of the resource type. - endpoint: Required. The endpoint URI that the custom resource provider will proxy requests to. - routing_type: The routing types that are supported for resource requests. Possible values include: 'Proxy', 'Proxy,Cache'. + name: Required. The name of the resource type. + endpoint: Required. The endpoint URI that the custom resource provider will proxy requests to. + routing_type: The routing types that are supported for resource requests. Possible values include: 'Proxy', 'Proxy,Cache'. - Multiple resource types can be specified by using more than one `--resource-type` argument. - - name: --validation -v - short-summary: Add a validation to the custom resource provider. - long-summary: | - Usage: --validation specification="https://raw.githubusercontent.com/" validation_type="Swagger" + Multiple resource types can be specified by using more than one `--resource-type` argument. + - name: --validation -v + short-summary: Add a validation to the custom resource provider. + long-summary: | + Usage: --validation specification="https://raw.githubusercontent.com/" validation_type="Swagger" - specification: A link to the validation specification.vThe specification must be hosted on raw.githubusercontent.com. - validation_type: The type of validation to run against a matching request. Possible values include: 'Swagger'. + specification: A link to the validation specification.vThe specification must be hosted on raw.githubusercontent.com. + validation_type: The type of validation to run against a matching request. Possible values include: 'Swagger'. - Multiple validations can be specified by using more than one `--validation` argument. - examples: - - name: Create or update a custom resource provider. - text: |- - az custom-providers resource-provider create -n MyRP -g MyRG \\ - --action name=ping endpoint=https://test.azurewebsites.net/api routing_type=Proxy \\ - --resource-type name=users endpoint=https://test.azurewebsites.net/api routing_type="Proxy, Cache" \\ - --validation validation_type=swagger specification=https://raw.githubusercontent.com/test.json + Multiple validations can be specified by using more than one `--validation` argument. +examples: + - name: Create or update a custom resource provider. + text: |- + az custom-providers resource-provider create -n MyRP -g MyRG \\ + --action name=ping endpoint=https://test.azurewebsites.net/api routing_type=Proxy \\ + --resource-type name=users endpoint=https://test.azurewebsites.net/api routing_type="Proxy, Cache" \\ + --validation validation_type=swagger specification=https://raw.githubusercontent.com/test.json """ helps['custom-providers resource-provider update'] = """ - type: command - short-summary: Update the custom resource provider. Only tags can be updated. - examples: - - name: Update the tags for a custom resource provider. - text: |- - az custom-providers resource-provider update -g MyRG -n MyRP --tags a=b +type: command +short-summary: Update the custom resource provider. Only tags can be updated. +examples: + - name: Update the tags for a custom resource provider. + text: |- + az custom-providers resource-provider update -g MyRG -n MyRP --tags a=b """ helps['custom-providers resource-provider delete'] = """ - type: command - short-summary: Delete the custom resource provider. - examples: - - name: Delete a custom resource provider. - text: |- - az custom-providers resource-provider delete -g MyRG -n MyRP +type: command +short-summary: Delete the custom resource provider. +examples: + - name: Delete a custom resource provider. + text: |- + az custom-providers resource-provider delete -g MyRG -n MyRP """ helps['custom-providers resource-provider show'] = """ - type: command - short-summary: Get the properties for the custom resource provider. - examples: - - name: Get a custom resource provider. - text: |- - az custom-providers resource-provider show -g MyRG -n MyRP +type: command +short-summary: Get the properties for the custom resource provider. +examples: + - name: Get a custom resource provider. + text: |- + az custom-providers resource-provider show -g MyRG -n MyRP """ helps['custom-providers resource-provider list'] = """ - type: command - short-summary: Get all the custom resource providers within a resource group or in the current subscription. - examples: - - name: List all custom resource providers in the resource group. - text: |- - az custom-providers resource-provider list -g MyRG - - name: List all custom resource providers in the current subscription. - text: |- - az custom-providers resource-provider list +type: command +short-summary: Get all the custom resource providers within a resource group or in the current subscription. +examples: + - name: List all custom resource providers in the resource group. + text: |- + az custom-providers resource-provider list -g MyRG + - name: List all custom resource providers in the current subscription. + text: |- + az custom-providers resource-provider list """ From 1f6586957c650a8e1b00c2c61e3d17da651d92a9 Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Sat, 9 May 2020 16:26:31 +0800 Subject: [PATCH 6/6] add multiple actions in test for create command --- .../azext_custom_providers/_validators.py | 18 ----- ...test_custom_providers_common_scenario.yaml | 71 ++++++++++--------- .../latest/test_custom-providers_scenario.py | 4 ++ 3 files changed, 40 insertions(+), 53 deletions(-) delete mode 100644 src/custom-providers/azext_custom_providers/_validators.py diff --git a/src/custom-providers/azext_custom_providers/_validators.py b/src/custom-providers/azext_custom_providers/_validators.py deleted file mode 100644 index 01e8fe71d5a..00000000000 --- a/src/custom-providers/azext_custom_providers/_validators.py +++ /dev/null @@ -1,18 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - - -def example_name_or_id_validator(cmd, namespace): - from azure.cli.core.commands.client_factory import get_subscription_id - from msrestazure.tools import is_valid_resource_id, resource_id - if namespace.storage_account: - if not is_valid_resource_id(namespace.RESOURCE): - namespace.storage_account = resource_id( - subscription=get_subscription_id(cmd.cli_ctx), - resource_group=namespace.resource_group_name, - namespace='Microsoft.Storage', - type='storageAccounts', - name=namespace.storage_account - ) diff --git a/src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml b/src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml index b686a3a97b6..36df7918bf8 100644 --- a/src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml +++ b/src/custom-providers/azext_custom_providers/tests/latest/recordings/test_custom_providers_common_scenario.yaml @@ -1,8 +1,9 @@ interactions: - request: body: '{"location": "westus2", "properties": {"actions": [{"name": "ping", "endpoint": - "https://ayniadjso4lay.azurewebsites.net/api", "routingType": "Proxy"}], "resourceTypes": - [{"name": "users", "endpoint": "https://ayniadjso4lay.azurewebsites.net/api", + "https://ayniadjso4lay.azurewebsites.net/api", "routingType": "Proxy"}, {"name": + "ping1", "endpoint": "https://ayniadjso4lay.azurewebsites.net/api1", "routingType": + "Proxy"}], "resourceTypes": [{"name": "users", "endpoint": "https://ayniadjso4lay.azurewebsites.net/api", "routingType": "Proxy, Cache"}], "validations": [{"validationType": "swagger", "specification": "https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}]}}' headers: @@ -15,11 +16,11 @@ interactions: Connection: - keep-alive Content-Length: - - '421' + - '524' Content-Type: - application/json; charset=utf-8 ParameterSetName: - - --resource-group --name --location --action --resource-type --validation + - --resource-group --name --location --action --action --resource-type --validation User-Agent: - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 @@ -29,19 +30,19 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview response: body: - string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"},{"name":"ping1","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api1"}],"resourceTypes":[{"name":"users","routingType":"Proxy, Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Accepted"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}' headers: azure-asyncoperation: - - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTU0JJQ0VCUkZGWFlWV0s2T1ZKVDdUUzVJN1FEM0RZM1lFQ0FYWE8zNUsyRFlQT1hFVk86MkRDTElURVNUOjJEQ1JQNEpOVDNGSEZJIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview cache-control: - no-cache content-length: - - '749' + - '846' content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:34:30 GMT + - Sat, 09 May 2020 08:16:10 GMT expires: - '-1' pragma: @@ -53,7 +54,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1198' + - '1199' status: code: 201 message: Created @@ -69,12 +70,12 @@ interactions: Connection: - keep-alive ParameterSetName: - - --resource-group --name --location --action --resource-type --validation + - --resource-group --name --location --action --action --resource-type --validation User-Agent: - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTU0JJQ0VCUkZGWFlWV0s2T1ZKVDdUUzVJN1FEM0RZM1lFQ0FYWE8zNUsyRFlQT1hFVk86MkRDTElURVNUOjJEQ1JQNEpOVDNGSEZJIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview response: body: string: '{"status":"Succeeded"}' @@ -86,11 +87,11 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:34:47 GMT + - Sat, 09 May 2020 08:16:26 GMT expires: - '-1' location: - - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTU0JJQ0VCUkZGWFlWV0s2T1ZKVDdUUzVJN1FEM0RZM1lFQ0FYWE8zNUsyRFlQT1hFVk86MkRDTElURVNUOjJEQ1JQNEpOVDNGSEZJIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview pragma: - no-cache server: @@ -118,7 +119,7 @@ interactions: Connection: - keep-alive ParameterSetName: - - --resource-group --name --location --action --resource-type --validation + - --resource-group --name --location --action --action --resource-type --validation User-Agent: - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 @@ -126,17 +127,17 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview response: body: - string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"},{"name":"ping1","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api1"}],"resourceTypes":[{"name":"users","routingType":"Proxy, Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}' headers: cache-control: - no-cache content-length: - - '750' + - '847' content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:34:47 GMT + - Sat, 09 May 2020 08:16:27 GMT expires: - '-1' pragma: @@ -176,17 +177,17 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview response: body: - string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"},{"name":"ping1","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api1"}],"resourceTypes":[{"name":"users","routingType":"Proxy, Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}' headers: cache-control: - no-cache content-length: - - '750' + - '847' content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:34:51 GMT + - Sat, 09 May 2020 08:16:30 GMT expires: - '-1' pragma: @@ -226,17 +227,17 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders?api-version=2018-09-01-preview response: body: - string: '{"value":[{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + string: '{"value":[{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"},{"name":"ping1","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api1"}],"resourceTypes":[{"name":"users","routingType":"Proxy, Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{}}]}' headers: cache-control: - no-cache content-length: - - '762' + - '859' content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:34:53 GMT + - Sat, 09 May 2020 08:16:33 GMT expires: - '-1' pragma: @@ -280,17 +281,17 @@ interactions: uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceProviders/clitest-crp000002?api-version=2018-09-01-preview response: body: - string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"resourceTypes":[{"name":"users","routingType":"Proxy, + string: '{"properties":{"actions":[{"name":"ping","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"},{"name":"ping1","routingType":"Proxy","endpoint":"https://ayniadjso4lay.azurewebsites.net/api1"}],"resourceTypes":[{"name":"users","routingType":"Proxy, Cache","endpoint":"https://ayniadjso4lay.azurewebsites.net/api"}],"validations":[{"validationType":"Swagger","specification":"https://raw.githubusercontent.com/jsntcy/TestFixDelete/master/test.json"}],"provisioningState":"Succeeded"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/resourceproviders/clitest-crp000002","name":"clitest-crp000002","type":"Microsoft.CustomProviders/resourceproviders","location":"westus2","tags":{"a":"b"}}' headers: cache-control: - no-cache content-length: - - '757' + - '854' content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:34:56 GMT + - Sat, 09 May 2020 08:16:40 GMT expires: - '-1' pragma: @@ -306,7 +307,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-writes: - - '1197' + - '1199' status: code: 200 message: OK @@ -337,7 +338,7 @@ interactions: string: 'null' headers: azure-asyncoperation: - - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTU0JJQ0VCUkZGWFlWV0s2T1ZKVDdUUzVJN1FEM0RZM1lFQ0FYWE8zNUsyRFlQT1hFVk86MkRDTElURVNUOjJEQ1JQNEpOVDNGSEZJIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview cache-control: - no-cache content-length: @@ -345,11 +346,11 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:34:58 GMT + - Sat, 09 May 2020 08:16:44 GMT expires: - '-1' location: - - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationresults/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationresults/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTU0JJQ0VCUkZGWFlWV0s2T1ZKVDdUUzVJN1FEM0RZM1lFQ0FYWE8zNUsyRFlQT1hFVk86MkRDTElURVNUOjJEQ1JQNEpOVDNGSEZJIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview pragma: - no-cache server: @@ -359,7 +360,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-deletes: - - '14998' + - '14999' status: code: 202 message: Accepted @@ -380,7 +381,7 @@ interactions: - python/3.7.6 (Windows-10-10.0.18362-SP0) msrest/0.6.11 yulocal msrest_azure/0.6.3 azure-mgmt-customproviders/0.1.0 Azure-SDK-For-Python AZURECLI/2.4.0 method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTU0JJQ0VCUkZGWFlWV0s2T1ZKVDdUUzVJN1FEM0RZM1lFQ0FYWE8zNUsyRFlQT1hFVk86MkRDTElURVNUOjJEQ1JQNEpOVDNGSEZJIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview response: body: string: '{"status":"Succeeded"}' @@ -392,11 +393,11 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Thu, 30 Apr 2020 03:35:15 GMT + - Sat, 09 May 2020 08:17:00 GMT expires: - '-1' location: - - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTNkdNSTJONkZXVVNSSEpIWk5XMlpCVk1VUElOSkFZWjZHWUxIQ0tZRldOUTJHWjVISkw6MkRDTElURVNUOjJEQ1JQN1lVTktOSTRPIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_custom_providers000001/providers/Microsoft.CustomProviders/locations/westus2/operationstatuses/eyJqb2JJZCI6Ik1SUENSVUQ6MkRDTEk6NUZURVNUOjVGQ1VTVE9NOjVGUFJPVklERVJTU0JJQ0VCUkZGWFlWV0s2T1ZKVDdUUzVJN1FEM0RZM1lFQ0FYWE8zNUsyRFlQT1hFVk86MkRDTElURVNUOjJEQ1JQNEpOVDNGSEZJIiwiam9iTG9jYXRpb24iOiJXRVNUVVMyIn0?api-version=2018-09-01-preview pragma: - no-cache server: @@ -441,7 +442,7 @@ interactions: content-length: - '0' date: - - Thu, 30 Apr 2020 03:35:19 GMT + - Sat, 09 May 2020 08:17:03 GMT expires: - '-1' pragma: diff --git a/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py b/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py index aee2ed84e18..c7e31291a46 100644 --- a/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py +++ b/src/custom-providers/azext_custom_providers/tests/latest/test_custom-providers_scenario.py @@ -24,6 +24,10 @@ def test_custom_providers_common_scenario(self): 'name=ping ' 'endpoint=https://ayniadjso4lay.azurewebsites.net/api ' 'routing_type=Proxy ' + '--action ' + 'name=ping1 ' + 'endpoint=https://ayniadjso4lay.azurewebsites.net/api1 ' + 'routing_type=Proxy ' '--resource-type ' 'name=users ' 'endpoint=https://ayniadjso4lay.azurewebsites.net/api '