From 9170195646e182bca926ec99150cc26ae4966d0c Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Mon, 17 Aug 2020 12:52:37 +0000 Subject: [PATCH] Update from master --- src/customproviders/HISTORY.rst | 8 + src/customproviders/README.md | 5 + .../azext_customproviders/__init__.py | 46 ++ .../azext_customproviders/action.py | 17 + .../azext_customproviders/azext_metadata.json | 4 + .../azext_customproviders/custom.py | 17 + .../generated/__init__.py | 12 + .../generated/_client_factory.py | 23 + .../azext_customproviders/generated/_help.py | 189 ++++++ .../generated/_params.py | 90 +++ .../generated/_validators.py | 9 + .../azext_customproviders/generated/action.py | 88 +++ .../generated/commands.py | 42 ++ .../azext_customproviders/generated/custom.py | 111 ++++ .../azext_customproviders/manual/__init__.py | 12 + .../azext_customproviders/tests/__init__.py | 71 +++ .../tests/latest/__init__.py | 12 + .../tests/latest/preparers.py | 159 +++++ .../latest/test_customproviders_scenario.py | 157 +++++ .../vendored_sdks/__init__.py | 12 + .../vendored_sdks/customproviders/__init__.py | 16 + .../customproviders/_configuration.py | 69 +++ .../customproviders/_customproviders.py | 79 +++ .../customproviders/aio/__init__.py | 10 + .../aio/_configuration_async.py | 65 +++ .../aio/_customproviders_async.py | 73 +++ .../aio/operations_async/__init__.py | 17 + .../_association_operations_async.py | 371 ++++++++++++ ...stom_resource_provider_operations_async.py | 524 +++++++++++++++++ .../_operation_operations_async.py | 102 ++++ .../customproviders/models/__init__.py | 65 +++ .../models/_customproviders_enums.py | 26 + .../customproviders/models/_models.py | 504 ++++++++++++++++ .../customproviders/models/_models_py3.py | 552 ++++++++++++++++++ .../customproviders/operations/__init__.py | 17 + .../operations/_association_operations.py | 381 ++++++++++++ .../_custom_resource_provider_operations.py | 536 +++++++++++++++++ .../operations/_operation_operations.py | 107 ++++ .../vendored_sdks/customproviders/py.typed | 1 + src/customproviders/report.md | 88 +++ src/customproviders/setup.cfg | 1 + src/customproviders/setup.py | 57 ++ 42 files changed, 4745 insertions(+) create mode 100644 src/customproviders/HISTORY.rst create mode 100644 src/customproviders/README.md create mode 100644 src/customproviders/azext_customproviders/__init__.py create mode 100644 src/customproviders/azext_customproviders/action.py create mode 100644 src/customproviders/azext_customproviders/azext_metadata.json create mode 100644 src/customproviders/azext_customproviders/custom.py create mode 100644 src/customproviders/azext_customproviders/generated/__init__.py create mode 100644 src/customproviders/azext_customproviders/generated/_client_factory.py create mode 100644 src/customproviders/azext_customproviders/generated/_help.py create mode 100644 src/customproviders/azext_customproviders/generated/_params.py create mode 100644 src/customproviders/azext_customproviders/generated/_validators.py create mode 100644 src/customproviders/azext_customproviders/generated/action.py create mode 100644 src/customproviders/azext_customproviders/generated/commands.py create mode 100644 src/customproviders/azext_customproviders/generated/custom.py create mode 100644 src/customproviders/azext_customproviders/manual/__init__.py create mode 100644 src/customproviders/azext_customproviders/tests/__init__.py create mode 100644 src/customproviders/azext_customproviders/tests/latest/__init__.py create mode 100644 src/customproviders/azext_customproviders/tests/latest/preparers.py create mode 100644 src/customproviders/azext_customproviders/tests/latest/test_customproviders_scenario.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/__init__.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/__init__.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/_configuration.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/_customproviders.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/__init__.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_configuration_async.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_customproviders_async.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/__init__.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_association_operations_async.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_custom_resource_provider_operations_async.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_operation_operations_async.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/__init__.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_customproviders_enums.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models_py3.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/__init__.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_association_operations.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_operation_operations.py create mode 100644 src/customproviders/azext_customproviders/vendored_sdks/customproviders/py.typed create mode 100644 src/customproviders/report.md create mode 100644 src/customproviders/setup.cfg create mode 100644 src/customproviders/setup.py diff --git a/src/customproviders/HISTORY.rst b/src/customproviders/HISTORY.rst new file mode 100644 index 00000000000..27f152061e8 --- /dev/null +++ b/src/customproviders/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/customproviders/README.md b/src/customproviders/README.md new file mode 100644 index 00000000000..c993828b1e5 --- /dev/null +++ b/src/customproviders/README.md @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'customproviders' Extension +========================================== + +This package is for the 'customproviders' extension. +i.e. 'az customproviders' diff --git a/src/customproviders/azext_customproviders/__init__.py b/src/customproviders/azext_customproviders/__init__.py new file mode 100644 index 00000000000..c7078817abd --- /dev/null +++ b/src/customproviders/azext_customproviders/__init__.py @@ -0,0 +1,46 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core import AzCommandsLoader +from azext_customproviders.generated._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_customproviders.generated._client_factory import cf_customproviders + customproviders_custom = CliCommandType( + operations_tmpl='azext_customproviders.custom#{}', + client_factory=cf_customproviders) + parent = super(CustomprovidersCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=customproviders_custom) + + def load_command_table(self, args): + from azext_customproviders.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_customproviders.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_customproviders.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_customproviders.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = CustomprovidersCommandsLoader diff --git a/src/customproviders/azext_customproviders/action.py b/src/customproviders/azext_customproviders/action.py new file mode 100644 index 00000000000..a846b2766c4 --- /dev/null +++ b/src/customproviders/azext_customproviders/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/customproviders/azext_customproviders/azext_metadata.json b/src/customproviders/azext_customproviders/azext_metadata.json new file mode 100644 index 00000000000..7b56fb1e11a --- /dev/null +++ b/src/customproviders/azext_customproviders/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.3.1" +} \ No newline at end of file diff --git a/src/customproviders/azext_customproviders/custom.py b/src/customproviders/azext_customproviders/custom.py new file mode 100644 index 00000000000..7f31674ce96 --- /dev/null +++ b/src/customproviders/azext_customproviders/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/customproviders/azext_customproviders/generated/__init__.py b/src/customproviders/azext_customproviders/generated/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/customproviders/azext_customproviders/generated/_client_factory.py b/src/customproviders/azext_customproviders/generated/_client_factory.py new file mode 100644 index 00000000000..2ea80e4cc5a --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_client_factory.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + + +def cf_customproviders(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.customproviders import Customproviders + return get_mgmt_service_client(cli_ctx, Customproviders) + + +def cf_custom_resource_provider(cli_ctx, *_): + return cf_customproviders(cli_ctx).custom_resource_provider + + +def cf_association(cli_ctx, *_): + return cf_customproviders(cli_ctx).association diff --git a/src/customproviders/azext_customproviders/generated/_help.py b/src/customproviders/azext_customproviders/generated/_help.py new file mode 100644 index 00000000000..a350a2840c5 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_help.py @@ -0,0 +1,189 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['customproviders custom-resource-provider'] = """ + type: group + short-summary: customproviders custom-resource-provider +""" + +helps['customproviders custom-resource-provider list'] = """ + type: command + short-summary: Gets all the custom resource providers within a subscription. + examples: + - name: List all custom resource providers on the resourceGroup + text: |- + az customproviders custom-resource-provider list --resource-group "testRG" +""" + +helps['customproviders custom-resource-provider show'] = """ + type: command + short-summary: Gets the custom resource provider manifest. + examples: + - name: Get a custom resource provider + text: |- + az customproviders custom-resource-provider show --resource-group "testRG" --resource-provider-name "new\ +rp" +""" + +helps['customproviders custom-resource-provider create'] = """ + type: command + short-summary: Creates or updates the custom resource provider. + parameters: + - name: --actions + short-summary: A list of actions that the custom resource provider implements. + long-summary: | + Usage: --actions name=XX endpoint=XX + + name: Required. The name of the route definition. This becomes the name for the ARM extension (e.g. '/subsc\ +riptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{res\ +ourceProviderName}/{name}') + 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. 'htt\ +ps://testendpoint/{requestPath}') + + Multiple actions can be specified by using more than one --actions argument. + - name: --resource-types + short-summary: A list of resource types that the custom resource provider implements. + long-summary: | + Usage: --resource-types routing-type=XX name=XX endpoint=XX + + routing-type: The routing types that are supported for resource requests. + name: Required. The name of the route definition. This becomes the name for the ARM extension (e.g. '/subsc\ +riptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{res\ +ourceProviderName}/{name}') + 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. 'htt\ +ps://testendpoint/{requestPath}') + + Multiple actions can be specified by using more than one --resource-types argument. + - name: --validations + short-summary: A list of validations to run on the custom resource provider's requests. + long-summary: | + Usage: --validations specification=XX + + specification: Required. A link to the validation specification. The specification must be hosted on raw.gi\ +thubusercontent.com. + + Multiple actions can be specified by using more than one --validations argument. + examples: + - name: Create or update the custom resource provider + text: |- + az customproviders custom-resource-provider create --resource-group "testRG" --location "eastus" --actio\ +ns name="TestAction" endpoint="https://mytestendpoint/" routing-type="Proxy" --resource-types name="TestResource" endpo\ +int="https://mytestendpoint2/" routing-type="Proxy,Cache" --resource-provider-name "newrp" +""" + +helps['customproviders custom-resource-provider update'] = """ + type: command + short-summary: Updates an existing custom resource provider. The only value that can be updated via PATCH currently\ + is the tags. + examples: + - name: Update a custom resource provider + text: |- + az customproviders custom-resource-provider update --resource-group "testRG" --resource-provider-name "n\ +ewrp" +""" + +helps['customproviders custom-resource-provider delete'] = """ + type: command + short-summary: Deletes the custom resource provider. + examples: + - name: Delete a custom resource provider + text: |- + az customproviders custom-resource-provider delete --resource-group "testRG" --resource-provider-name "n\ +ewrp" +""" + +helps['customproviders custom-resource-provider wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the customproviders custom-resource-provider i\ +s met. + examples: + - name: Pause executing next line of CLI script until the customproviders custom-resource-provider is successfull\ +y created. + text: |- + az customproviders custom-resource-provider wait --resource-group "testRG" --resource-provider-name "new\ +rp" --created + - name: Pause executing next line of CLI script until the customproviders custom-resource-provider is successfull\ +y deleted. + text: |- + az customproviders custom-resource-provider wait --resource-group "testRG" --resource-provider-name "new\ +rp" --deleted +""" + +helps['customproviders association'] = """ + type: group + short-summary: customproviders association +""" + +helps['customproviders association show'] = """ + type: command + short-summary: Get an association. + examples: + - name: Get an association + text: |- + az customproviders association show --name "associationName" --scope "scope" +""" + +helps['customproviders association create'] = """ + type: command + short-summary: Create or update an association. + examples: + - name: Create or update an association + text: |- + az customproviders association create --target-resource-id "/subscriptions/00000000-0000-0000-0000-00000\ +0000000/resourceGroups/appRG/providers/Microsoft.Solutions/applications/applicationName" --name "associationName" --sco\ +pe "scope" +""" + +helps['customproviders association update'] = """ + type: command + short-summary: Create or update an association. + examples: + - name: Create or update an association + text: |- + az customproviders association update --target-resource-id "/subscriptions/00000000-0000-0000-0000-00000\ +0000000/resourceGroups/appRG/providers/Microsoft.Solutions/applications/applicationName" --name "associationName" --sco\ +pe "scope" +""" + +helps['customproviders association delete'] = """ + type: command + short-summary: Delete an association. + examples: + - name: Delete an association + text: |- + az customproviders association delete --name "associationName" --scope "scope" +""" + +helps['customproviders association list-all'] = """ + type: command + short-summary: Gets all association for the given scope. + examples: + - name: Get all associations + text: |- + az customproviders association list-all --scope "scope" +""" + +helps['customproviders association wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the customproviders association is met. + examples: + - name: Pause executing next line of CLI script until the customproviders association is successfully created. + text: |- + az customproviders association wait --name "associationName" --scope "scope" --created + - name: Pause executing next line of CLI script until the customproviders association is successfully deleted. + text: |- + az customproviders association wait --name "associationName" --scope "scope" --deleted +""" diff --git a/src/customproviders/azext_customproviders/generated/_params.py b/src/customproviders/azext_customproviders/generated/_params.py new file mode 100644 index 00000000000..03baa84ce41 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_params.py @@ -0,0 +1,90 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + tags_type, + resource_group_name_type, + get_location_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group +from azext_customproviders.action import ( + AddActions, + AddResourceTypes, + AddValidations +) + + +def load_arguments(self, _): + + with self.argument_context('customproviders custom-resource-provider list') as c: + c.argument('resource_group_name', resource_group_name_type) + + with self.argument_context('customproviders custom-resource-provider show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', help='The name of the resource provider.', id_part='name') + + with self.argument_context('customproviders custom-resource-provider create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', 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) + c.argument('actions', action=AddActions, nargs='+', help='A list of actions that the custom resource provider i' + 'mplements.') + c.argument('resource_types', action=AddResourceTypes, nargs='+', help='A list of resource types that the custom' + ' resource provider implements.') + c.argument('validations', action=AddValidations, nargs='+', help='A list of validations to run on the custom re' + 'source provider\'s requests.') + + with self.argument_context('customproviders custom-resource-provider update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', help='The name of the resource provider.', id_part='name') + c.argument('tags', tags_type) + + with self.argument_context('customproviders custom-resource-provider delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', help='The name of the resource provider.', id_part='name') + + with self.argument_context('customproviders custom-resource-provider wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('resource_provider_name', help='The name of the resource provider.', id_part='name') + + with self.argument_context('customproviders association show') as c: + c.argument('scope', help='The scope of the association.') + c.argument('association_name', options_list=['--name', '-n'], help='The name of the association.') + + with self.argument_context('customproviders association create') as c: + c.argument('scope', help='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/Micr' + 'osoft.Compute/virtualMachines/{vm-name}\' for a virtual machine resource.') + c.argument('association_name', options_list=['--name', '-n'], help='The name of the association.') + c.argument('target_resource_id', + help='The REST resource instance of the target resource for this association.') + + with self.argument_context('customproviders association update') as c: + c.argument('scope', help='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/Micr' + 'osoft.Compute/virtualMachines/{vm-name}\' for a virtual machine resource.') + c.argument('association_name', options_list=['--name', '-n'], help='The name of the association.') + c.argument('target_resource_id', + help='The REST resource instance of the target resource for this association.') + + with self.argument_context('customproviders association delete') as c: + c.argument('scope', help='The scope of the association.') + c.argument('association_name', options_list=['--name', '-n'], help='The name of the association.') + + with self.argument_context('customproviders association list-all') as c: + c.argument('scope', help='The scope of the association.') + + with self.argument_context('customproviders association wait') as c: + c.argument('scope', help='The scope of the association.') + c.argument('association_name', options_list=['--name', '-n'], help='The name of the association.') diff --git a/src/customproviders/azext_customproviders/generated/_validators.py b/src/customproviders/azext_customproviders/generated/_validators.py new file mode 100644 index 00000000000..e5ac7838677 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/src/customproviders/azext_customproviders/generated/action.py b/src/customproviders/azext_customproviders/generated/action.py new file mode 100644 index 00000000000..b01e641a4a4 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/action.py @@ -0,0 +1,88 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from knack.util import CLIError +from collections import defaultdict + + +class AddActions(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddActions, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + d['routing_type'] = "Proxy" + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'name': + d['name'] = v[0] + elif kl == 'endpoint': + d['endpoint'] = v[0] + return d + + +class AddResourceTypes(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddResourceTypes, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'routing-type': + d['routing_type'] = v[0] + elif kl == 'name': + d['name'] = v[0] + elif kl == 'endpoint': + d['endpoint'] = v[0] + return d + + +class AddValidations(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddValidations, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + d['validation_type'] = "Swagger" + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'specification': + d['specification'] = v[0] + return d diff --git a/src/customproviders/azext_customproviders/generated/commands.py b/src/customproviders/azext_customproviders/generated/commands.py new file mode 100644 index 00000000000..9ac6022731f --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/commands.py @@ -0,0 +1,42 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_customproviders.generated._client_factory import cf_custom_resource_provider + customproviders_custom_resource_provider = CliCommandType( + operations_tmpl='azext_customproviders.vendored_sdks.customproviders.operations._custom_resource_provider_opera' + 'tions#CustomResourceProviderOperations.{}', + client_factory=cf_custom_resource_provider) + with self.command_group('customproviders custom-resource-provider', customproviders_custom_resource_provider, + client_factory=cf_custom_resource_provider, is_experimental=True) as g: + g.custom_command('list', 'customproviders_custom_resource_provider_list') + g.custom_show_command('show', 'customproviders_custom_resource_provider_show') + g.custom_command('create', 'customproviders_custom_resource_provider_create', supports_no_wait=True) + g.custom_command('update', 'customproviders_custom_resource_provider_update') + g.custom_command('delete', 'customproviders_custom_resource_provider_delete', supports_no_wait=True) + g.custom_wait_command('wait', 'customproviders_custom_resource_provider_show') + + from azext_customproviders.generated._client_factory import cf_association + customproviders_association = CliCommandType( + operations_tmpl='azext_customproviders.vendored_sdks.customproviders.operations._association_operations#Associa' + 'tionOperations.{}', + client_factory=cf_association) + with self.command_group('customproviders association', customproviders_association, client_factory=cf_association, + is_experimental=True) as g: + g.custom_show_command('show', 'customproviders_association_show') + g.custom_command('create', 'customproviders_association_create', supports_no_wait=True) + g.custom_command('update', 'customproviders_association_update', supports_no_wait=True) + g.custom_command('delete', 'customproviders_association_delete', supports_no_wait=True) + g.custom_command('list-all', 'customproviders_association_list_all') + g.custom_wait_command('wait', 'customproviders_association_show') diff --git a/src/customproviders/azext_customproviders/generated/custom.py b/src/customproviders/azext_customproviders/generated/custom.py new file mode 100644 index 00000000000..04968d68127 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/custom.py @@ -0,0 +1,111 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from azure.cli.core.util import sdk_no_wait + + +def customproviders_custom_resource_provider_list(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() + + +def customproviders_custom_resource_provider_show(client, + resource_group_name, + resource_provider_name): + return client.get(resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name) + + +def customproviders_custom_resource_provider_create(client, + resource_group_name, + resource_provider_name, + location, + tags=None, + actions=None, + resource_types=None, + validations=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + location=location, + tags=tags, + actions=actions, + resource_types=resource_types, + validations=validations) + + +def customproviders_custom_resource_provider_update(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 customproviders_custom_resource_provider_delete(client, + resource_group_name, + resource_provider_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_delete, + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name) + + +def customproviders_association_show(client, + scope, + association_name): + return client.get(scope=scope, + association_name=association_name) + + +def customproviders_association_create(client, + scope, + association_name, + target_resource_id=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + scope=scope, + association_name=association_name, + target_resource_id=target_resource_id) + + +def customproviders_association_update(client, + scope, + association_name, + target_resource_id=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + scope=scope, + association_name=association_name, + target_resource_id=target_resource_id) + + +def customproviders_association_delete(client, + scope, + association_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_delete, + scope=scope, + association_name=association_name) + + +def customproviders_association_list_all(client, + scope): + return client.list_all(scope=scope) diff --git a/src/customproviders/azext_customproviders/manual/__init__.py b/src/customproviders/azext_customproviders/manual/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/customproviders/azext_customproviders/manual/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/customproviders/azext_customproviders/tests/__init__.py b/src/customproviders/azext_customproviders/tests/__init__.py new file mode 100644 index 00000000000..5f8f1fd97ad --- /dev/null +++ b/src/customproviders/azext_customproviders/tests/__init__.py @@ -0,0 +1,71 @@ +# 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 inspect +import os +import sys +import traceback +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + print("Found manual override for {}(...)".format(func.__name__)) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + print("running {}()...".format(func.__name__)) + try: + return func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, JMESPathCheckAssertionError) as e: + print("--------------------------------------") + print("step exception: ", e) + print("--------------------------------------", file=sys.stderr) + print("step exception in {}: {}".format(func.__name__, e), file=sys.stderr) + traceback.print_exc() + exceptions.append((func.__name__, sys.exc_info())) + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/customproviders/azext_customproviders/tests/latest/__init__.py b/src/customproviders/azext_customproviders/tests/latest/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/customproviders/azext_customproviders/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/customproviders/azext_customproviders/tests/latest/preparers.py b/src/customproviders/azext_customproviders/tests/latest/preparers.py new file mode 100644 index 00000000000..4702355b2bd --- /dev/null +++ b/src/customproviders/azext_customproviders/tests/latest/preparers.py @@ -0,0 +1,159 @@ +# -------------------------------------------------------------------------- +# 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 os +from datetime import datetime +from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer +from azure.cli.testsdk.exceptions import CliTestError +from azure.cli.testsdk.reverse_dependency import get_dummy_cli + + +KEY_RESOURCE_GROUP = 'rg' +KEY_VIRTUAL_NETWORK = 'vnet' +KEY_VNET_SUBNET = 'subnet' +KEY_VNET_NIC = 'nic' + + +class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='virtual_network', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + dev_setting_name='AZURE_CLI_TEST_DEV_VIRTUAL_NETWORK_NAME', + random_name_length=24, key=KEY_VIRTUAL_NETWORK): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VirtualNetworkPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + + tags = {'product': 'azurecli', 'cause': 'automation', + 'date': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')} + if 'ENV_JOB_NAME' in os.environ: + tags['job'] = os.environ['ENV_JOB_NAME'] + tags = ' '.join(['{}={}'.format(key, value) + for key, value in tags.items()]) + template = 'az network vnet create --resource-group {} --name {} --subnet-name default --tag ' + tags + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group_name, name)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + # delete vnet if test is being recorded and if the vnet is not a dev rg + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, + 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + + +class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='subnet', + resource_group_key=KEY_RESOURCE_GROUP, + vnet_key=KEY_VIRTUAL_NETWORK, + address_prefixes="11.0.0.0/24", + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', + key=KEY_VNET_SUBNET): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetSubnetPreparer, self).__init__(name_prefix, 15) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] + self.address_prefixes = address_prefixes + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: + raise CliTestError("Error: No resource group configured!") + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: + raise CliTestError("Error: No vnet configured!") + + self.test_class_instance.kwargs[self.key] = 'default' + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + pass + + +class VnetNicPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.nic', + parameter_name='subnet', + resource_group_key=KEY_RESOURCE_GROUP, + vnet_key=KEY_VIRTUAL_NETWORK, + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_NIC_NAME', + key=KEY_VNET_NIC): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetNicPreparer, self).__init__(name_prefix, 15) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group = [resource_group_key, None] + self.vnet = [vnet_key, None] + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **_): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group[1]: + self.resource_group[1] = self.test_class_instance.kwargs.get( + self.resource_group[0]) + if not self.resource_group[1]: + raise CliTestError("Error: No resource group configured!") + if not self.vnet[1]: + self.vnet[1] = self.test_class_instance.kwargs.get(self.vnet[0]) + if not self.vnet[1]: + raise CliTestError("Error: No vnet configured!") + + template = 'az network nic create --resource-group {} --name {} --vnet-name {} --subnet default ' + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group[1], name, self.vnet[1])) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **_): + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, + 'az network nic delete --name {} --resource-group {}'.format(name, self.resource_group[1])) diff --git a/src/customproviders/azext_customproviders/tests/latest/test_customproviders_scenario.py b/src/customproviders/azext_customproviders/tests/latest/test_customproviders_scenario.py new file mode 100644 index 00000000000..729a7343166 --- /dev/null +++ b/src/customproviders/azext_customproviders/tests/latest/test_customproviders_scenario.py @@ -0,0 +1,157 @@ +# -------------------------------------------------------------------------- +# 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 os +from azure.cli.testsdk import ScenarioTest +from .. import try_manual, raise_if +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +@try_manual +def setup(test, rg, rg_2): + pass + + +# EXAMPLE: /Associations/put/Create or update an association +@try_manual +def step__associations_put_create_or_update_an_association(test, rg, rg_2): + test.cmd('az customproviders association create ' + '--target-resource-id "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Solutions/' + 'applications/applicationName" ' + '--name "{associationName}" ' + '--scope "scope"', + checks=[]) + test.cmd('az customproviders association wait --created ' + '--name "{associationName}"', + checks=[]) + + +# EXAMPLE: /Associations/get/Get all associations +@try_manual +def step__associations_get_get_all_associations(test, rg, rg_2): + test.cmd('az customproviders association list-all ' + '--scope "scope"', + checks=[]) + + +# EXAMPLE: /Associations/get/Get an association +@try_manual +def step__associations_get_get_an_association(test, rg, rg_2): + test.cmd('az customproviders association show ' + '--name "{associationName}" ' + '--scope "scope"', + checks=[]) + + +# EXAMPLE: /CustomResourceProvider/put/Create or update the custom resource provider +@try_manual +def step__customresourceprovider_put_create_or_update_the_custom_resource_provider(test, rg, rg_2): + test.cmd('az customproviders custom-resource-provider create ' + '--resource-group "{rg_2}" ' + '--location "eastus" ' + '--actions name="TestAction" endpoint="https://mytestendpoint/" routing-type="Proxy" ' + '--resource-types name="TestResource" endpoint="https://mytestendpoint2/" routing-type="Proxy,Cache" ' + '--resource-provider-name "newrp"', + checks=[]) + + +# EXAMPLE: /CustomResourceProvider/get/Get a custom resource provider +@try_manual +def step__customresourceprovider_get_get_a_custom_resource_provider(test, rg, rg_2): + test.cmd('az customproviders custom-resource-provider show ' + '--resource-group "{rg_2}" ' + '--resource-provider-name "newrp"', + checks=[]) + + +# EXAMPLE: /CustomResourceProvider/get/List all custom resource providers on the resourceGroup +@try_manual +def step__customresourceprovider_get_list_all_custom_resource_providers_on_the_resourcegroup(test, rg, rg_2): + test.cmd('az customproviders custom-resource-provider list ' + '--resource-group "{rg_2}"', + checks=[]) + + +# EXAMPLE: /CustomResourceProvider/get/List all custom resource providers on the subscription +@try_manual +def step__customresourceprovider_get_list_all_custom_resource_providers_on_the_subscription(test, rg, rg_2): + test.cmd('az customproviders custom-resource-provider list ' + '-g ""', + checks=[]) + + +# EXAMPLE: /CustomResourceProvider/patch/Update a custom resource provider +@try_manual +def step__customresourceprovider_patch_update_a_custom_resource_provider(test, rg, rg_2): + test.cmd('az customproviders custom-resource-provider update ' + '--resource-group "{rg_2}" ' + '--resource-provider-name "newrp"', + checks=[]) + + +# EXAMPLE: /Associations/delete/Delete an association +@try_manual +def step__associations_delete_delete_an_association(test, rg, rg_2): + test.cmd('az customproviders association delete ' + '--name "{associationName}" ' + '--scope "scope"', + checks=[]) + + +# EXAMPLE: /CustomResourceProvider/delete/Delete a custom resource provider +@try_manual +def step__customresourceprovider_delete_delete_a_custom_resource_provider(test, rg, rg_2): + test.cmd('az customproviders custom-resource-provider delete ' + '--resource-group "{rg_2}" ' + '--resource-provider-name "newrp"', + checks=[]) + + +@try_manual +def cleanup(test, rg, rg_2): + pass + + +@try_manual +def call_scenario(test, rg, rg_2): + setup(test, rg, rg_2) + step__associations_put_create_or_update_an_association(test, rg, rg_2) + step__associations_get_get_all_associations(test, rg, rg_2) + step__associations_get_get_an_association(test, rg, rg_2) + step__customresourceprovider_put_create_or_update_the_custom_resource_provider(test, rg, rg_2) + step__customresourceprovider_get_get_a_custom_resource_provider(test, rg, rg_2) + step__customresourceprovider_get_list_all_custom_resource_providers_on_the_resourcegroup(test, rg, rg_2) + step__customresourceprovider_get_list_all_custom_resource_providers_on_the_subscription(test, rg, rg_2) + step__customresourceprovider_patch_update_a_custom_resource_provider(test, rg, rg_2) + step__associations_delete_delete_an_association(test, rg, rg_2) + step__customresourceprovider_delete_delete_a_custom_resource_provider(test, rg, rg_2) + cleanup(test, rg, rg_2) + + +@try_manual +class CustomprovidersScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='clitestcustomproviders_appRG'[:7], key='rg', parameter_name='rg') + @ResourceGroupPreparer(name_prefix='clitestcustomproviders_testRG'[:7], key='rg_2', parameter_name='rg_2') + def test_customproviders(self, rg, rg_2): + + self.kwargs.update({ + 'subscription_id': self.get_subscription_id() + }) + + self.kwargs.update({ + 'associationName': 'associationName', + }) + + call_scenario(self, rg, rg_2) + raise_if() diff --git a/src/customproviders/azext_customproviders/vendored_sdks/__init__.py b/src/customproviders/azext_customproviders/vendored_sdks/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/__init__.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/__init__.py new file mode 100644 index 00000000000..40c12be7d65 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/__init__.py @@ -0,0 +1,16 @@ +# 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 ._customproviders import Customproviders +__all__ = ['Customproviders'] + +try: + from ._patch import patch_sdk + patch_sdk() +except ImportError: + pass diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_configuration.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_configuration.py new file mode 100644 index 00000000000..231900deab4 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_configuration.py @@ -0,0 +1,69 @@ +# 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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class CustomprovidersConfiguration(Configuration): + """Configuration for Customproviders. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(CustomprovidersConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-09-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'customproviders/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_customproviders.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_customproviders.py new file mode 100644 index 00000000000..1415610ecb9 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_customproviders.py @@ -0,0 +1,79 @@ +# 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 typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import CustomprovidersConfiguration +from .operations import OperationOperations +from .operations import CustomResourceProviderOperations +from .operations import AssociationOperations +from . import models + + +class Customproviders(object): + """Allows extension of ARM control plane with custom resource providers. + + :ivar operation: OperationOperations operations + :vartype operation: customproviders.operations.OperationOperations + :ivar custom_resource_provider: CustomResourceProviderOperations operations + :vartype custom_resource_provider: customproviders.operations.CustomResourceProviderOperations + :ivar association: AssociationOperations operations + :vartype association: customproviders.operations.AssociationOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = CustomprovidersConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.custom_resource_provider = CustomResourceProviderOperations( + self._client, self._config, self._serialize, self._deserialize) + self.association = AssociationOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> Customproviders + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/__init__.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/__init__.py new file mode 100644 index 00000000000..be0b6ba433d --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._customproviders_async import Customproviders +__all__ = ['Customproviders'] diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_configuration_async.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_configuration_async.py new file mode 100644 index 00000000000..bf793b0321d --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class CustomprovidersConfiguration(Configuration): + """Configuration for Customproviders. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(CustomprovidersConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-09-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'customproviders/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_customproviders_async.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_customproviders_async.py new file mode 100644 index 00000000000..336a458bb53 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_customproviders_async.py @@ -0,0 +1,73 @@ +# 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 typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration_async import CustomprovidersConfiguration +from .operations_async import OperationOperations +from .operations_async import CustomResourceProviderOperations +from .operations_async import AssociationOperations +from .. import models + + +class Customproviders(object): + """Allows extension of ARM control plane with custom resource providers. + + :ivar operation: OperationOperations operations + :vartype operation: customproviders.aio.operations_async.OperationOperations + :ivar custom_resource_provider: CustomResourceProviderOperations operations + :vartype custom_resource_provider: customproviders.aio.operations_async.CustomResourceProviderOperations + :ivar association: AssociationOperations operations + :vartype association: customproviders.aio.operations_async.AssociationOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = CustomprovidersConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.custom_resource_provider = CustomResourceProviderOperations( + self._client, self._config, self._serialize, self._deserialize) + self.association = AssociationOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "Customproviders": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/__init__.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/__init__.py new file mode 100644 index 00000000000..e0b026e0c51 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# 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 ._operation_operations_async import OperationOperations +from ._custom_resource_provider_operations_async import CustomResourceProviderOperations +from ._association_operations_async import AssociationOperations + +__all__ = [ + 'OperationOperations', + 'CustomResourceProviderOperations', + 'AssociationOperations', +] diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_association_operations_async.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_association_operations_async.py new file mode 100644 index 00000000000..ba35a4c2f70 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_association_operations_async.py @@ -0,0 +1,371 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AssociationOperations: + """AssociationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~customproviders.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + scope: str, + association_name: str, + target_resource_id: Optional[str] = None, + **kwargs + ) -> "models.Association": + cls = kwargs.pop('cls', None) # type: ClsType["models.Association"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _association = models.Association(target_resource_id=target_resource_id) + api_version = "2018-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_association, 'Association') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Association', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + async def create_or_update( + self, + scope: str, + association_name: str, + target_resource_id: Optional[str] = None, + **kwargs + ) -> "models.Association": + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: Association, or the result of cls(response) + :rtype: ~customproviders.models.Association + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Association"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + scope=scope, + association_name=association_name, + target_resource_id=target_resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + async def _delete_initial( + self, + scope: str, + association_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + async def delete( + self, + scope: str, + association_name: str, + **kwargs + ) -> None: + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: None, or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + scope=scope, + association_name=association_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + async def get( + self, + scope: str, + association_name: str, + **kwargs + ) -> "models.Association": + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Association, or the result of cls(response) + :rtype: ~customproviders.models.Association + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Association"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + def list_all( + self, + scope: str, + **kwargs + ) -> AsyncIterable["models.AssociationsList"]: + """Gets all association for the given scope. + + :param scope: The scope of the association. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AssociationsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~customproviders.models.AssociationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AssociationsList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_all.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AssociationsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations'} # type: ignore diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_custom_resource_provider_operations_async.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_custom_resource_provider_operations_async.py new file mode 100644 index 00000000000..38308bbe018 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_custom_resource_provider_operations_async.py @@ -0,0 +1,524 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CustomResourceProviderOperations: + """CustomResourceProviderOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~customproviders.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + resource_provider_name: str, + location: str, + tags: Optional[Dict[str, str]] = None, + actions: Optional[List["models.CustomRPActionRouteDefinition"]] = None, + resource_types: Optional[List["models.CustomRPResourceTypeRouteDefinition"]] = None, + validations: Optional[List["models.CustomRPValidations"]] = None, + **kwargs + ) -> "models.CustomRPManifest": + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _resource_provider = models.CustomRPManifest(location=location, tags=tags, actions=actions, resource_types=resource_types, validations=validations) + api_version = "2018-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_resource_provider, 'CustomRPManifest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + resource_provider_name: str, + location: str, + tags: Optional[Dict[str, str]] = None, + actions: Optional[List["models.CustomRPActionRouteDefinition"]] = None, + resource_types: Optional[List["models.CustomRPResourceTypeRouteDefinition"]] = None, + validations: Optional[List["models.CustomRPValidations"]] = None, + **kwargs + ) -> "models.CustomRPManifest": + """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 location: 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[~customproviders.models.CustomRPActionRouteDefinition] + :param resource_types: A list of resource types that the custom resource provider implements. + :type resource_types: list[~customproviders.models.CustomRPResourceTypeRouteDefinition] + :param validations: A list of validations to run on the custom resource provider's requests. + :type validations: list[~customproviders.models.CustomRPValidations] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: CustomRPManifest, or the result of cls(response) + :rtype: ~customproviders.models.CustomRPManifest + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + location=location, + tags=tags, + actions=actions, + resource_types=resource_types, + validations=validations, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + resource_provider_name: str, + **kwargs + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_name: str, + **kwargs + ) -> None: + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: None, or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_name: str, + **kwargs + ) -> "models.CustomRPManifest": + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomRPManifest, or the result of cls(response) + :rtype: ~customproviders.models.CustomRPManifest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + resource_provider_name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ) -> "models.CustomRPManifest": + """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] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomRPManifest, or the result of cls(response) + :rtype: ~customproviders.models.CustomRPManifest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _patchable_resource = models.ResourceProvidersUpdate(tags=tags) + api_version = "2018-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_patchable_resource, 'ResourceProvidersUpdate') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.ListByCustomRPManifest"]: + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~customproviders.models.ListByCustomRPManifest] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ListByCustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ListByCustomRPManifest', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["models.ListByCustomRPManifest"]: + """Gets all the custom resource providers within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~customproviders.models.ListByCustomRPManifest] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ListByCustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ListByCustomRPManifest', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'} # type: ignore diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_operation_operations_async.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_operation_operations_async.py new file mode 100644 index 00000000000..9d3c28abd72 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,102 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~customproviders.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.ResourceProviderOperationList"]: + """The list of operations provided by Microsoft CustomProviders. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~customproviders.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceProviderOperationList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.CustomProviders/operations'} # type: ignore diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/__init__.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/__init__.py new file mode 100644 index 00000000000..f03f0111132 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/__init__.py @@ -0,0 +1,65 @@ +# 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 AssociationsList + 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 + from ._models_py3 import ListByCustomRPManifest + from ._models_py3 import Resource + from ._models_py3 import ResourceProviderOperation + from ._models_py3 import ResourceProviderOperationDisplay + from ._models_py3 import ResourceProviderOperationList + from ._models_py3 import ResourceProvidersUpdate +except (SyntaxError, ImportError): + from ._models import Association # type: ignore + from ._models import AssociationsList # type: ignore + from ._models import CustomRPActionRouteDefinition # type: ignore + from ._models import CustomRPManifest # type: ignore + from ._models import CustomRPResourceTypeRouteDefinition # type: ignore + from ._models import CustomRPRouteDefinition # type: ignore + from ._models import CustomRPValidations # type: ignore + from ._models import ErrorDefinition # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ListByCustomRPManifest # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceProviderOperation # type: ignore + from ._models import ResourceProviderOperationDisplay # type: ignore + from ._models import ResourceProviderOperationList # type: ignore + from ._models import ResourceProvidersUpdate # type: ignore + +from ._customproviders_enums import ( + ProvisioningState, + ResourceTypeRouting, +) + +__all__ = [ + 'Association', + 'AssociationsList', + 'CustomRPActionRouteDefinition', + 'CustomRPManifest', + 'CustomRPResourceTypeRouteDefinition', + 'CustomRPRouteDefinition', + 'CustomRPValidations', + 'ErrorDefinition', + 'ErrorResponse', + 'ListByCustomRPManifest', + 'Resource', + 'ResourceProviderOperation', + 'ResourceProviderOperationDisplay', + 'ResourceProviderOperationList', + 'ResourceProvidersUpdate', + 'ProvisioningState', + 'ResourceTypeRouting', +] diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_customproviders_enums.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_customproviders_enums.py new file mode 100644 index 00000000000..2e8014ba2fe --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_customproviders_enums.py @@ -0,0 +1,26 @@ +# 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 ProvisioningState(str, Enum): + """The provisioning state of the resource provider. + """ + + accepted = "Accepted" + deleting = "Deleting" + running = "Running" + succeeded = "Succeeded" + failed = "Failed" + +class ResourceTypeRouting(str, Enum): + """The routing types that are supported for resource requests. + """ + + proxy = "Proxy" + proxy_cache = "Proxy,Cache" diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models.py new file mode 100644 index 00000000000..c91425c1968 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models.py @@ -0,0 +1,504 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Association(msrest.serialization.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 ~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 AssociationsList(msrest.serialization.Model): + """List of associations. + + :param value: The array of associations. + :type value: list[~customproviders.models.Association] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Association]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AssociationsList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class CustomRPRouteDefinition(msrest.serialization.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['name'] + self.endpoint = kwargs['endpoint'] + + +class CustomRPActionRouteDefinition(CustomRPRouteDefinition): + """The route definition for an action implemented by the custom resource provider. + + 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. + + :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 + :ivar routing_type: The routing types that are supported for action requests. Default value: + "Proxy". + :vartype routing_type: str + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + 'routing_type': {'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'routing_type': {'key': 'routingType', 'type': 'str'}, + } + + routing_type = "Proxy" + + def __init__( + self, + **kwargs + ): + super(CustomRPActionRouteDefinition, self).__init__(**kwargs) + + +class Resource(msrest.serialization.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: A set of 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['location'] + 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: A set of tags. Resource tags. + :type tags: dict[str, str] + :param actions: A list of actions that the custom resource provider implements. + :type actions: list[~customproviders.models.CustomRPActionRouteDefinition] + :param resource_types: A list of resource types that the custom resource provider implements. + :type resource_types: list[~customproviders.models.CustomRPResourceTypeRouteDefinition] + :param validations: A list of validations to run on the custom resource provider's requests. + :type validations: list[~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 ~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 ~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(msrest.serialization.Model): + """A validation to apply on custom resource provider requests. + + 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 validation_type: The type of validation to run against a matching request. Default value: + "Swagger". + :vartype validation_type: str + :param specification: Required. A link to the validation specification. The specification must + be hosted on raw.githubusercontent.com. + :type specification: str + """ + + _validation = { + 'validation_type': {'constant': True}, + 'specification': {'required': True, 'pattern': r'^https://raw.githubusercontent.com/.+'}, + } + + _attribute_map = { + 'validation_type': {'key': 'validationType', 'type': 'str'}, + 'specification': {'key': 'specification', 'type': 'str'}, + } + + validation_type = "Swagger" + + def __init__( + self, + **kwargs + ): + super(CustomRPValidations, self).__init__(**kwargs) + self.specification = kwargs['specification'] + + +class ErrorDefinition(msrest.serialization.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[~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(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~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 ListByCustomRPManifest(msrest.serialization.Model): + """List of custom resource providers. + + :param value: The array of custom resource provider manifests. + :type value: list[~customproviders.models.CustomRPManifest] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CustomRPManifest]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ListByCustomRPManifest, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ResourceProviderOperation(msrest.serialization.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: ~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(msrest.serialization.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 ResourceProviderOperationList(msrest.serialization.Model): + """Results of the request to list operations. + + :param value: List of operations supported by this resource provider. + :type value: list[~customproviders.models.ResourceProviderOperation] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ResourceProvidersUpdate(msrest.serialization.Model): + """custom resource provider update information. + + :param tags: A set of 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/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models_py3.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models_py3.py new file mode 100644 index 00000000000..78714c9639f --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models_py3.py @@ -0,0 +1,552 @@ +# 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 typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._customproviders_enums import * + + +class Association(msrest.serialization.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 ~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: Optional[str] = None, + **kwargs + ): + 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 AssociationsList(msrest.serialization.Model): + """List of associations. + + :param value: The array of associations. + :type value: list[~customproviders.models.Association] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Association]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Association"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(AssociationsList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CustomRPRouteDefinition(msrest.serialization.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 + ): + 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. + + 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. + + :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 + :ivar routing_type: The routing types that are supported for action requests. Default value: + "Proxy". + :vartype routing_type: str + """ + + _validation = { + 'name': {'required': True}, + 'endpoint': {'required': True, 'pattern': r'^https://.+'}, + 'routing_type': {'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'routing_type': {'key': 'routingType', 'type': 'str'}, + } + + routing_type = "Proxy" + + def __init__( + self, + *, + name: str, + endpoint: str, + **kwargs + ): + super(CustomRPActionRouteDefinition, self).__init__(name=name, endpoint=endpoint, **kwargs) + + +class Resource(msrest.serialization.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: A set of 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: Optional[Dict[str, str]] = None, + **kwargs + ): + 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: A set of tags. Resource tags. + :type tags: dict[str, str] + :param actions: A list of actions that the custom resource provider implements. + :type actions: list[~customproviders.models.CustomRPActionRouteDefinition] + :param resource_types: A list of resource types that the custom resource provider implements. + :type resource_types: list[~customproviders.models.CustomRPResourceTypeRouteDefinition] + :param validations: A list of validations to run on the custom resource provider's requests. + :type validations: list[~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 ~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: Optional[Dict[str, str]] = None, + actions: Optional[List["CustomRPActionRouteDefinition"]] = None, + resource_types: Optional[List["CustomRPResourceTypeRouteDefinition"]] = None, + validations: Optional[List["CustomRPValidations"]] = None, + **kwargs + ): + 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 ~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: Optional[Union[str, "ResourceTypeRouting"]] = None, + **kwargs + ): + super(CustomRPResourceTypeRouteDefinition, self).__init__(name=name, endpoint=endpoint, **kwargs) + self.routing_type = routing_type + + +class CustomRPValidations(msrest.serialization.Model): + """A validation to apply on custom resource provider requests. + + 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 validation_type: The type of validation to run against a matching request. Default value: + "Swagger". + :vartype validation_type: str + :param specification: Required. A link to the validation specification. The specification must + be hosted on raw.githubusercontent.com. + :type specification: str + """ + + _validation = { + 'validation_type': {'constant': True}, + 'specification': {'required': True, 'pattern': r'^https://raw.githubusercontent.com/.+'}, + } + + _attribute_map = { + 'validation_type': {'key': 'validationType', 'type': 'str'}, + 'specification': {'key': 'specification', 'type': 'str'}, + } + + validation_type = "Swagger" + + def __init__( + self, + *, + specification: str, + **kwargs + ): + super(CustomRPValidations, self).__init__(**kwargs) + self.specification = specification + + +class ErrorDefinition(msrest.serialization.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[~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(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~customproviders.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinition"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ListByCustomRPManifest(msrest.serialization.Model): + """List of custom resource providers. + + :param value: The array of custom resource provider manifests. + :type value: list[~customproviders.models.CustomRPManifest] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CustomRPManifest]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CustomRPManifest"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ListByCustomRPManifest, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceProviderOperation(msrest.serialization.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: ~customproviders.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["ResourceProviderOperationDisplay"] = None, + **kwargs + ): + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = name + self.display = display + + +class ResourceProviderOperationDisplay(msrest.serialization.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: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(msrest.serialization.Model): + """Results of the request to list operations. + + :param value: List of operations supported by this resource provider. + :type value: list[~customproviders.models.ResourceProviderOperation] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceProviderOperation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceProvidersUpdate(msrest.serialization.Model): + """custom resource provider update information. + + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(ResourceProvidersUpdate, self).__init__(**kwargs) + self.tags = tags diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/__init__.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/__init__.py new file mode 100644 index 00000000000..865272625df --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/__init__.py @@ -0,0 +1,17 @@ +# 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 ._operation_operations import OperationOperations +from ._custom_resource_provider_operations import CustomResourceProviderOperations +from ._association_operations import AssociationOperations + +__all__ = [ + 'OperationOperations', + 'CustomResourceProviderOperations', + 'AssociationOperations', +] diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_association_operations.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_association_operations.py new file mode 100644 index 00000000000..98177d3f4a8 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_association_operations.py @@ -0,0 +1,381 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AssociationOperations(object): + """AssociationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~customproviders.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + scope, # type: str + association_name, # type: str + target_resource_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.Association" + cls = kwargs.pop('cls', None) # type: ClsType["models.Association"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _association = models.Association(target_resource_id=target_resource_id) + api_version = "2018-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_association, 'Association') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Association', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + def begin_create_or_update( + self, + scope, # type: str + association_name, # type: str + target_resource_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Association or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~customproviders.models.Association] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Association"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._create_or_update_initial( + scope=scope, + association_name=association_name, + target_resource_id=target_resource_id, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + def _delete_initial( + self, + scope, # type: str + association_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + def begin_delete( + self, + scope, # type: str + association_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._delete_initial( + scope=scope, + association_name=association_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + def get( + self, + scope, # type: str + association_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Association" + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Association, or the result of cls(response) + :rtype: ~customproviders.models.Association + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Association"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} # type: ignore + + def list_all( + self, + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.AssociationsList"] + """Gets all association for the given scope. + + :param scope: The scope of the association. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AssociationsList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~customproviders.models.AssociationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AssociationsList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_all.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AssociationsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations'} # type: ignore diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py new file mode 100644 index 00000000000..7b4f6461138 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py @@ -0,0 +1,536 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CustomResourceProviderOperations(object): + """CustomResourceProviderOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~customproviders.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name, # type: str + resource_provider_name, # type: str + location, # type: str + tags=None, # type: Optional[Dict[str, str]] + actions=None, # type: Optional[List["models.CustomRPActionRouteDefinition"]] + resource_types=None, # type: Optional[List["models.CustomRPResourceTypeRouteDefinition"]] + validations=None, # type: Optional[List["models.CustomRPValidations"]] + **kwargs # type: Any + ): + # type: (...) -> "models.CustomRPManifest" + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _resource_provider = models.CustomRPManifest(location=location, tags=tags, actions=actions, resource_types=resource_types, validations=validations) + api_version = "2018-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_resource_provider, 'CustomRPManifest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + resource_provider_name, # type: str + location, # type: str + tags=None, # type: Optional[Dict[str, str]] + actions=None, # type: Optional[List["models.CustomRPActionRouteDefinition"]] + resource_types=None, # type: Optional[List["models.CustomRPResourceTypeRouteDefinition"]] + validations=None, # type: Optional[List["models.CustomRPValidations"]] + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """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 location: 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[~customproviders.models.CustomRPActionRouteDefinition] + :param resource_types: A list of resource types that the custom resource provider implements. + :type resource_types: list[~customproviders.models.CustomRPResourceTypeRouteDefinition] + :param validations: A list of validations to run on the custom resource provider's requests. + :type validations: list[~customproviders.models.CustomRPValidations] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either CustomRPManifest or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~customproviders.models.CustomRPManifest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + location=location, + tags=tags, + actions=actions, + resource_types=resource_types, + validations=validations, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name, # type: str + resource_provider_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + resource_provider_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + resource_provider_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CustomRPManifest" + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomRPManifest, or the result of cls(response) + :rtype: ~customproviders.models.CustomRPManifest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + def update( + self, + resource_group_name, # type: str + resource_provider_name, # type: str + tags=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> "models.CustomRPManifest" + """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] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CustomRPManifest, or the result of cls(response) + :rtype: ~customproviders.models.CustomRPManifest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _patchable_resource = models.ResourceProvidersUpdate(tags=tags) + api_version = "2018-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_patchable_resource, 'ResourceProvidersUpdate') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CustomRPManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ListByCustomRPManifest"] + """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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~customproviders.models.ListByCustomRPManifest] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ListByCustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ListByCustomRPManifest', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'} # type: ignore + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ListByCustomRPManifest"] + """Gets all the custom resource providers within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListByCustomRPManifest or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~customproviders.models.ListByCustomRPManifest] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ListByCustomRPManifest"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + 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 = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ListByCustomRPManifest', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'} # type: ignore diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_operation_operations.py b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_operation_operations.py new file mode 100644 index 00000000000..49d1c4da783 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_operation_operations.py @@ -0,0 +1,107 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~customproviders.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceProviderOperationList"] + """The list of operations provided by Microsoft CustomProviders. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~customproviders.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceProviderOperationList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-09-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.CustomProviders/operations'} # type: ignore diff --git a/src/customproviders/azext_customproviders/vendored_sdks/customproviders/py.typed b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/customproviders/report.md b/src/customproviders/report.md new file mode 100644 index 00000000000..2723283b5a6 --- /dev/null +++ b/src/customproviders/report.md @@ -0,0 +1,88 @@ +# Azure CLI Module Creation Report + +### customproviders association create + +create a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--scope**|string|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.|scope| +|**--association-name**|string|The name of the association.|association_name| +|**--target-resource-id**|string|The REST resource instance of the target resource for this association.|target_resource_id| +### customproviders association delete + +delete a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--scope**|string|The scope of the association.|scope| +|**--association-name**|string|The name of the association.|association_name| +### customproviders association list-all + +list-all a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--scope**|string|The scope of the association.|scope| +### customproviders association show + +show a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--scope**|string|The scope of the association.|scope| +|**--association-name**|string|The name of the association.|association_name| +### customproviders association update + +create a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--scope**|string|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.|scope| +|**--association-name**|string|The name of the association.|association_name| +|**--target-resource-id**|string|The REST resource instance of the target resource for this association.|target_resource_id| +### customproviders custom-resource-provider create + +create a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name| +|**--resource-provider-name**|string|The name of the resource provider.|resource_provider_name| +|**--location**|string|Resource location|location| +|**--tags**|dictionary|Resource tags|tags| +|**--actions**|array|A list of actions that the custom resource provider implements.|actions| +|**--resource-types**|array|A list of resource types that the custom resource provider implements.|resource_types| +|**--validations**|array|A list of validations to run on the custom resource provider's requests.|validations| +### customproviders custom-resource-provider delete + +delete a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name| +|**--resource-provider-name**|string|The name of the resource provider.|resource_provider_name| +### customproviders custom-resource-provider list + +list a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name| +### customproviders custom-resource-provider show + +show a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name| +|**--resource-provider-name**|string|The name of the resource provider.|resource_provider_name| +### customproviders custom-resource-provider update + +update a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name| +|**--resource-provider-name**|string|The name of the resource provider.|resource_provider_name| +|**--tags**|dictionary|Resource tags|tags| \ No newline at end of file diff --git a/src/customproviders/setup.cfg b/src/customproviders/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/customproviders/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/customproviders/setup.py b/src/customproviders/setup.py new file mode 100644 index 00000000000..32c3976a8b2 --- /dev/null +++ b/src/customproviders/setup.py @@ -0,0 +1,57 @@ +#!/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 + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from .manual.version import VERSION +except ImportError: + pass + +# 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 :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] +try: + from .manual.dependency import DEPENDENCIES +except ImportError: + pass + +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='customproviders', + version=VERSION, + description='Microsoft Azure Command-Line Tools Customproviders Extension', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/customproviders', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_customproviders': ['azext_metadata.json']}, +)