diff --git a/build_package.py b/build_package.py new file mode 100644 index 00000000000..8199bf49c3b --- /dev/null +++ b/build_package.py @@ -0,0 +1,30 @@ +#!/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. +#-------------------------------------------------------------------------- + +import argparse +import os +import glob +from subprocess import check_call + +DEFAULT_DEST_FOLDER = "./dist" + +def create_package(name, dest_folder=DEFAULT_DEST_FOLDER): + # a package will exist in either one, or the other folder. this is why we can resolve both at the same time. + absdirs = [os.path.dirname(package) for package in (glob.glob('{}/setup.py'.format(name)) + glob.glob('sdk/*/{}/setup.py'.format(name)))] + absdirpath = os.path.abspath(absdirs[0]) + check_call(['python', 'setup.py', 'bdist_wheel', '-d', dest_folder], cwd=absdirpath) + check_call(['python', 'setup.py', "sdist", "--format", "zip", '-d', dest_folder], cwd=absdirpath) + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Build Azure package.') + parser.add_argument('name', help='The package name') + parser.add_argument('--dest', '-d', default=DEFAULT_DEST_FOLDER, + help='Destination folder. Relative to the package dir. [default: %(default)s]') + args = parser.parse_args() + create_package(args.name, args.dest) + diff --git a/src/customproviders/HISTORY.rst b/src/customproviders/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /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.rst b/src/customproviders/README.rst new file mode 100644 index 00000000000..37b4126417d --- /dev/null +++ b/src/customproviders/README.rst @@ -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..c871e731eb9 --- /dev/null +++ b/src/customproviders/azext_customproviders/__init__.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader + +from azext_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) + super(CustomprovidersCommandsLoader, self).__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) + return self.command_table + + def load_arguments(self, command): + from azext_customproviders.generated._params import load_arguments + load_arguments(self, command) + + +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..bddca252cb7 --- /dev/null +++ b/src/customproviders/azext_customproviders/action.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from azext_customproviders.generated.action import * # noqa: F403 +try: + from azext_customproviders.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..55c81bf3328 --- /dev/null +++ b/src/customproviders/azext_customproviders/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.0.67" +} \ No newline at end of file diff --git a/src/customproviders/azext_customproviders/commands.py b/src/customproviders/azext_customproviders/commands.py new file mode 100644 index 00000000000..b0e01cb7d1c --- /dev/null +++ b/src/customproviders/azext_customproviders/commands.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from azext_customproviders.generated.commands import * # noqa: F403 +try: + from azext_customproviders.manual.commands import * # noqa: F403 +except ImportError: + pass diff --git a/src/customproviders/azext_customproviders/custom.py b/src/customproviders/azext_customproviders/custom.py new file mode 100644 index 00000000000..e99a9c45549 --- /dev/null +++ b/src/customproviders/azext_customproviders/custom.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from azext_customproviders.generated.custom import * # noqa: F403 +try: + from azext_customproviders.manual.custom import * # noqa: F403 +except ImportError: + pass 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..ff6477df3a4 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_client_factory.py @@ -0,0 +1,22 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +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_operation(cli_ctx, *_): + return cf_customproviders(cli_ctx).operation + + +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..fcc6fc409a4 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_help.py @@ -0,0 +1,133 @@ +# coding=utf-8 +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=too-many-lines +# pylint: disable=line-too-long +from knack.help_files import helps # pylint: disable=unused-import + + +helps['customproviders operation'] = """ + type: group + short-summary: customproviders operation +""" + +helps['customproviders operation list'] = """ + type: command + short-summary: The list of operations provided by Microsoft CustomProviders. + examples: + - name: List the custom providers operations + text: |- + az customproviders operation list +""" + +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 "newrp" +""" + +helps['customproviders custom-resource-provider create'] = """ + type: command + short-summary: Creates or updates the custom resource provider. + examples: + - name: Create or update the custom resource provider + text: |- + az customproviders custom-resource-provider create --resource-group "testRG" --location \\ + "eastus" --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 "newrp" +""" + +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 "newrp" +""" + +helps['customproviders association'] = """ + type: group + short-summary: customproviders association +""" + +helps['customproviders association list'] = """ + type: command + short-summary: Gets all association for the given scope. + examples: + - name: Get all associations + text: |- + az customproviders association list --scope "scope" +""" + +helps['customproviders association show'] = """ + type: command + short-summary: Get an association. + examples: + - name: Get an association + text: |- + az customproviders association show --association-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-0 + 000-0000-000000000000/resourceGroups/appRG/providers/Microsoft.Solutions/applications/appl + icationName" --association-name "associationName" --scope "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 create --target-resource-id "/subscriptions/00000000-0000-0 + 000-0000-000000000000/resourceGroups/appRG/providers/Microsoft.Solutions/applications/appl + icationName" --association-name "associationName" --scope "scope" +""" + +helps['customproviders association delete'] = """ + type: command + short-summary: Delete an association. + examples: + - name: Delete an association + text: |- + az customproviders association delete --association-name "associationName" --scope \\ + "scope" +""" diff --git a/src/customproviders/azext_customproviders/generated/_params.py b/src/customproviders/azext_customproviders/generated/_params.py new file mode 100644 index 00000000000..b944922fc35 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_params.py @@ -0,0 +1,70 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=line-too-long +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + tags_type, + resource_group_name_type, + get_location_type +) +from azext_customproviders.action import ( + AddActions, + AddResourceTypes, + AddValidations +) + + +def load_arguments(self, _): + + with self.argument_context('customproviders operation list') as c: + pass + + 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.') + + 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)) + c.argument('tags', tags_type) + c.argument('resource_provider_actions', help='A list of actions that the custom resource provider implements.', action=AddActions, nargs='+') + c.argument('resource_provider_resource_types', help='A list of resource types that the custom resource provider implements.', action=AddResourceTypes, nargs='+') + c.argument('resource_provider_validations', help='A list of validations to run on the custom resource provider\'s requests.', action=AddValidations, nargs='+') + + 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.') + 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.') + + with self.argument_context('customproviders association list') 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/Microsoft.Compute/virtualMachines/{vm-name}\' for a virtual machine resource.') + + with self.argument_context('customproviders association show') 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/Microsoft.Compute/virtualMachines/{vm-name}\' for a virtual machine resource.') + c.argument('association_name', 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/Microsoft.Compute/virtualMachines/{vm-name}\' for a virtual machine resource.') + c.argument('association_name', help='The name of the association.') + c.argument('association_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/Microsoft.Compute/virtualMachines/{vm-name}\' for a virtual machine resource.') + c.argument('association_name', help='The name of the association.') + c.argument('association_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. 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.') + c.argument('association_name', 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..01e8fe71d5a --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/_validators.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/customproviders/azext_customproviders/generated/action.py b/src/customproviders/azext_customproviders/generated/action.py new file mode 100644 index 00000000000..23a61b1db06 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/action.py @@ -0,0 +1,69 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import argparse +from knack.util import CLIError + + +# pylint: disable=protected-access + + +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 = dict(x.split('=', 1) for x in values) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'actions': + d['actions'] = v + 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 = dict(x.split('=', 1) for x in values) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'resource_types': + d['resource_types'] = v + 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 = dict(x.split('=', 1) for x in values) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'validations': + d['validations'] = v + elif kl == 'validations': + d['validations'] = v + 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..924880c35fc --- /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. +# -------------------------------------------------------------------------------------------- + +# pylint: disable=line-too-long +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from ._client_factory import cf_operation + customproviders_operation = CliCommandType( + operations_tmpl='azext_customproviders.vendored_sdks.customproviders.operations._operation_operations#OperationOperations.{}', + client_factory=cf_operation) + with self.command_group('customproviders operation', customproviders_operation, client_factory=cf_operation) as g: + g.custom_command('list', 'customproviders_operation_list') + + from ._client_factory import cf_custom_resource_provider + customproviders_custom_resource_provider = CliCommandType( + operations_tmpl='azext_customproviders.vendored_sdks.customproviders.operations._custom_resource_provider_operations#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) 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') + g.custom_command('update', 'customproviders_custom_resource_provider_update') + g.custom_command('delete', 'customproviders_custom_resource_provider_delete') + + from ._client_factory import cf_association + customproviders_association = CliCommandType( + operations_tmpl='azext_customproviders.vendored_sdks.customproviders.operations._association_operations#AssociationOperations.{}', + client_factory=cf_association) + with self.command_group('customproviders association', customproviders_association, client_factory=cf_association) as g: + g.custom_command('list', 'customproviders_association_list') + g.custom_show_command('show', 'customproviders_association_show') + g.custom_command('create', 'customproviders_association_create') + g.custom_command('update', 'customproviders_association_update') + g.custom_command('delete', 'customproviders_association_delete') diff --git a/src/customproviders/azext_customproviders/generated/custom.py b/src/customproviders/azext_customproviders/generated/custom.py new file mode 100644 index 00000000000..7d80e6d14a1 --- /dev/null +++ b/src/customproviders/azext_customproviders/generated/custom.py @@ -0,0 +1,81 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=line-too-long +# pylint: disable=too-many-statements +# pylint: disable=too-many-lines +# pylint: disable=too-many-locals +# pylint: disable=unused-argument + + +def customproviders_operation_list(cmd, client): + return client.list() + + +def customproviders_custom_resource_provider_list(cmd, client, + resource_group_name=None): + if resource_group_name is not None: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list_by_subscription() + + +def customproviders_custom_resource_provider_show(cmd, 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(cmd, client, + resource_group_name, + resource_provider_name, + location, + tags=None, + resource_provider_actions=None, + resource_provider_resource_types=None, + resource_provider_validations=None): + return client.create_or_update(resource_group_name=resource_group_name, resource_provider_name=resource_provider_name, location=location, tags=tags, actions=resource_provider_actions, resource_types=resource_provider_resource_types, validations=resource_provider_validations) + + +def customproviders_custom_resource_provider_update(cmd, 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(cmd, client, + resource_group_name, + resource_provider_name): + return client.delete(resource_group_name=resource_group_name, resource_provider_name=resource_provider_name) + + +def customproviders_association_list(cmd, client, + scope): + return client.list_all(scope=scope) + + +def customproviders_association_show(cmd, client, + scope, + association_name): + return client.get(scope=scope, association_name=association_name) + + +def customproviders_association_create(cmd, client, + scope, + association_name, + association_target_resource_id=None): + return client.create_or_update(scope=scope, association_name=association_name, target_resource_id=association_target_resource_id) + + +def customproviders_association_update(cmd, client, + scope, + association_name, + association_target_resource_id=None): + return client.create_or_update(scope=scope, association_name=association_name, target_resource_id=association_target_resource_id) + + +def customproviders_association_delete(cmd, client, + scope, + association_name): + return client.delete(scope=scope, association_name=association_name) 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..06963556037 --- /dev/null +++ b/src/customproviders/azext_customproviders/tests/latest/test_customproviders_scenario.py @@ -0,0 +1,70 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import unittest + +from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +class CustomprovidersScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_customproviders') + def test_customproviders(self, resource_group): + + self.cmd('az customproviders association create ' + '--target-resource-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/appRG/providers/Microsoft.Solutions/applications/applicationName" ' + '--association-name "associationName" ' + '--scope "scope"', + checks=[]) + + self.cmd('az customproviders custom-resource-provider create ' + '--resource-group {rg} ' + '--location "eastus" ' + '--resource-provider-name "newrp"', + checks=[]) + + self.cmd('az customproviders custom-resource-provider show ' + '--resource-group {rg} ' + '--resource-provider-name "newrp"', + checks=[]) + + self.cmd('az customproviders custom-resource-provider update ' + '--resource-group {rg} ' + '--resource-provider-name "newrp"', + checks=[]) + + self.cmd('az customproviders custom-resource-provider list ' + '--resource-group {rg}', + checks=[]) + + self.cmd('az customproviders custom-resource-provider list', + checks=[]) + + self.cmd('az customproviders association show ' + '--association-name "associationName" ' + '--scope "scope"', + checks=[]) + + self.cmd('az customproviders association list ' + '--scope "scope"', + checks=[]) + + self.cmd('az customproviders operation list', + checks=[]) + + self.cmd('az customproviders custom-resource-provider delete ' + '--resource-group {rg} ' + '--resource-provider-name "newrp"', + checks=[]) + + self.cmd('az customproviders association delete ' + '--association-name "associationName" ' + '--scope "scope"', + checks=[]) 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..be1a152630c --- /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__) \ No newline at end of file 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..158a0fe1249 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/__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 import Customproviders +__all__ = ['Customproviders'] 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..5018dcaa82e --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_configuration.py @@ -0,0 +1,52 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +VERSION = "unknown" + +class CustomprovidersConfiguration(Configuration): + """Configuration for Customproviders + Note that all parameters used to create this instance are saved as instance + attributes. + + :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, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(CustomprovidersConfiguration, self).__init__(**kwargs) + + self.subscription_id = subscription_id + self.api_version = "2018-09-01-preview" + self._configure(**kwargs) + self.user_agent_policy.add_user_agent('azsdk-python-customproviders/{}'.format(VERSION)) + + 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') 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..94451c2bdbf --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/_customproviders.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 Any, Optional + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +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 subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + 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(subscription_id, **kwargs) + self._client = PipelineClient(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..35918323dff --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_configuration_async.py @@ -0,0 +1,50 @@ +# 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 + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +VERSION = "unknown" + +class CustomprovidersConfiguration(Configuration): + """Configuration for Customproviders + Note that all parameters used to create this instance are saved as instance + attributes. + + :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, + subscription_id: str, + **kwargs: Any + ) -> None: + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(CustomprovidersConfiguration, self).__init__(**kwargs) + + self.subscription_id = subscription_id + self.api_version = "2018-09-01-preview" + self._configure(**kwargs) + self.user_agent_policy.add_user_agent('azsdk-python-customproviders/{}'.format(VERSION)) + + 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') 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..dcbbef8ee79 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/_customproviders_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, Optional + +from azure.core import AsyncPipelineClient +from msrest import Deserializer, Serializer + +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 subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = CustomprovidersConfiguration(subscription_id, **kwargs) + self._client = AsyncPipelineClient(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..1d61ec933a7 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_association_operations_async.py @@ -0,0 +1,359 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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.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 directly this class, but create a Client instance that will create it for you and attach it as 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: ClsType["models.Association"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + + association = models.Association(target_resource_id=target_resource_id) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(association, 'Association') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + 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 + :return: An instance of LROPoller that returns Association + :rtype: ~azure.core.polling.LROPoller[~customproviders.models.Association] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling: Union[bool, AsyncPollingMethod] = kwargs.pop('polling', True) + cls: ClsType["models.Association"] = kwargs.pop('cls', None ) + 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 + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + async def _delete_initial( + self, + scope: str, + association_name: str, + **kwargs + ) -> None: + cls: ClsType[None] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} + + async def delete( + self, + scope: str, + association_name: str, + **kwargs + ) -> None: + """Delete 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 + :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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling: Union[bool, AsyncPollingMethod] = kwargs.pop('polling', True) + cls: ClsType[None] = kwargs.pop('cls', None ) + raw_result = await self._delete_initial( + scope=scope, + association_name=association_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + async def get( + self, + scope: str, + association_name: str, + **kwargs + ) -> "models.Association": + """Get 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 + :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: ~customproviders.models.ErrorResponseException: + """ + cls: ClsType["models.Association"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} + + def list_all( + self, + scope: str, + **kwargs + ) -> "models.AssociationsList": + """Gets all association for the given scope. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AssociationsList or the result of cls(response) + :rtype: ~customproviders.models.AssociationsList + :raises: ~customproviders.models.ErrorResponseException: + """ + cls: ClsType["models.AssociationsList"] = kwargs.pop('cls', None ) + error_map = 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'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations'} 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..a14ff2986ac --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_custom_resource_provider_operations_async.py @@ -0,0 +1,500 @@ +# 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, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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.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 directly this class, but create a Client instance that will create it for you and attach it as 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["CustomRpActionRouteDefinition"]] = None, + resource_types: Optional[List["CustomRpResourceTypeRouteDefinition"]] = None, + validations: Optional[List["CustomRpValidations"]] = None, + **kwargs + ) -> "models.CustomRpManifest": + cls: ClsType["models.CustomRpManifest"] = kwargs.pop('cls', None ) + error_map = 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" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(resource_provider, 'CustomRpManifest') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + 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["CustomRpActionRouteDefinition"]] = None, + resource_types: Optional[List["CustomRpResourceTypeRouteDefinition"]] = None, + validations: Optional[List["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 + :return: An instance of LROPoller that returns CustomRpManifest + :rtype: ~azure.core.polling.LROPoller[~customproviders.models.CustomRpManifest] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling: Union[bool, AsyncPollingMethod] = kwargs.pop('polling', True) + cls: ClsType["models.CustomRpManifest"] = kwargs.pop('cls', None ) + 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 + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('CustomRpManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + async def _delete_initial( + self, + resource_group_name: str, + resource_provider_name: str, + **kwargs + ) -> None: + cls: ClsType[None] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} + + 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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling: Union[bool, AsyncPollingMethod] = kwargs.pop('polling', True) + cls: ClsType[None] = kwargs.pop('cls', None ) + 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 + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + 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: ~customproviders.models.ErrorResponseException: + """ + cls: ClsType["models.CustomRpManifest"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + 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: ~customproviders.models.ErrorResponseException: + """ + cls: ClsType["models.CustomRpManifest"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + + patchable_resource = models.ResourceProvidersUpdate(tags=tags) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(patchable_resource, 'ResourceProvidersUpdate') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> "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: ListByCustomRpManifest or the result of cls(response) + :rtype: ~customproviders.models.ListByCustomRpManifest + :raises: ~customproviders.models.ErrorResponseException: + """ + cls: ClsType["models.ListByCustomRpManifest"] = kwargs.pop('cls', None ) + error_map = 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'] + 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) + else: + url = next_link + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'} + + def list_by_subscription( + self, + **kwargs + ) -> "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: ListByCustomRpManifest or the result of cls(response) + :rtype: ~customproviders.models.ListByCustomRpManifest + :raises: ~customproviders.models.ErrorResponseException: + """ + cls: ClsType["models.ListByCustomRpManifest"] = kwargs.pop('cls', None ) + error_map = 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'] + 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) + else: + url = next_link + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'} 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..0c59a8cfc54 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,98 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +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 directly this class, but create a Client instance that will create it for you and attach it as 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 + ) -> "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: ResourceProviderOperationList or the result of cls(response) + :rtype: ~customproviders.models.ResourceProviderOperationList + :raises: ~customproviders.models.ErrorResponseException: + """ + cls: ClsType["models.ResourceProviderOperationList"] = kwargs.pop('cls', None ) + error_map = 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'] + else: + url = next_link + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.CustomProviders/operations'} 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..591e80b1233 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/__init__.py @@ -0,0 +1,70 @@ +# 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 AssociationProperties + from ._models_py3 import AssociationsList + from ._models_py3 import CustomRpActionRouteDefinition + from ._models_py3 import CustomRpManifest + from ._models_py3 import CustomRpManifestProperties + from ._models_py3 import CustomRpResourceTypeRouteDefinition + from ._models_py3 import CustomRpRouteDefinition + from ._models_py3 import CustomRpValidations + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import 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 AssociationProperties # type: ignore + from ._models import AssociationsList # type: ignore + from ._models import CustomRpActionRouteDefinition # type: ignore + from ._models import CustomRpManifest # type: ignore + from ._models import CustomRpManifestProperties # 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, ErrorResponseException # 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', + 'AssociationProperties', + 'AssociationsList', + 'CustomRpActionRouteDefinition', + 'CustomRpManifest', + 'CustomRpManifestProperties', + 'CustomRpResourceTypeRouteDefinition', + 'CustomRpRouteDefinition', + 'CustomRpValidations', + 'ErrorDefinition', + 'ErrorResponse', 'ErrorResponseException', + '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..b17ff248474 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_customproviders_enums.py @@ -0,0 +1,22 @@ +# 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 ResourceTypeRouting(str, Enum): + + proxy = "Proxy" + proxy_cache = "Proxy,Cache" + +class ProvisioningState(str, Enum): + + accepted = "Accepted" + deleting = "Deleting" + running = "Running" + succeeded = "Succeeded" + failed = "Failed" 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..620897d0b1b --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models.py @@ -0,0 +1,599 @@ +# 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 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}, + '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 AssociationProperties(msrest.serialization.Model): + """The properties of the association. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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 resource provider. Possible values + include: 'Accepted', 'Deleting', 'Running', 'Succeeded', 'Failed'. + :vartype provisioning_state: str or ~customproviders.models.ProvisioningState + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AssociationProperties, self).__init__(**kwargs) + 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': '^https://.+'}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CustomRpRouteDefinition, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.endpoint = kwargs.get('endpoint', None) + + +class CustomRpActionRouteDefinition(CustomRpRouteDefinition): + """The route definition for an action implemented by the custom resource provider. + + 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': '^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.get('location', None) + self.tags = kwargs.get('tags', None) + + +class CustomRpManifest(Resource): + """A manifest file that defines the custom resource provider resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Required. Resource location. + :type location: str + :param tags: 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 CustomRpManifestProperties(msrest.serialization.Model): + """The manifest for the custom resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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 = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'actions': {'key': 'actions', 'type': '[CustomRpActionRouteDefinition]'}, + 'resource_types': {'key': 'resourceTypes', 'type': '[CustomRpResourceTypeRouteDefinition]'}, + 'validations': {'key': 'validations', 'type': '[CustomRpValidations]'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CustomRpManifestProperties, 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': '^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': '^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.get('specification', None) + + +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 ErrorResponseException(HttpResponseError): + """Server responded with exception of type: 'ErrorResponse'. + + :param response: Server response to be deserialized. + :param error_model: A deserialized model of the response body as model. + """ + + def __init__(self, response, error_model): + self.error = error_model + super(ErrorResponseException, self).__init__(response=response, error_model=error_model) + + @classmethod + def from_response(cls, response, deserialize): + """Deserialize this response as this exception, or a subclass of this exception. + + :param response: Server response to be deserialized. + :param deserialize: A deserializer + """ + model_name = 'ErrorResponse' + error = deserialize(model_name, response) + if error is None: + error = deserialize.dependencies[model_name]() + return error._EXCEPTION_TYPE(response, error) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: Error definition. + :type error: ~customproviders.models.ErrorDefinition + """ + _EXCEPTION_TYPE = ErrorResponseException + + _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..7b6dbb0b6e3 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/models/_models_py3.py @@ -0,0 +1,651 @@ +# 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 + + +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 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}, + '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 AssociationProperties(msrest.serialization.Model): + """The properties of the association. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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 resource provider. Possible values + include: 'Accepted', 'Deleting', 'Running', 'Succeeded', 'Failed'. + :vartype provisioning_state: str or ~customproviders.models.ProvisioningState + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + target_resource_id: Optional[str] = None, + **kwargs + ): + super(AssociationProperties, self).__init__(**kwargs) + 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': '^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': '^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 CustomRpManifestProperties(msrest.serialization.Model): + """The manifest for the custom resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :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 = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'actions': {'key': 'actions', 'type': '[CustomRpActionRouteDefinition]'}, + 'resource_types': {'key': 'resourceTypes', 'type': '[CustomRpResourceTypeRouteDefinition]'}, + 'validations': {'key': 'validations', 'type': '[CustomRpValidations]'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + actions: Optional[List["CustomRpActionRouteDefinition"]] = None, + resource_types: Optional[List["CustomRpResourceTypeRouteDefinition"]] = None, + validations: Optional[List["CustomRpValidations"]] = None, + **kwargs + ): + super(CustomRpManifestProperties, self).__init__(**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': '^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': '^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 ErrorResponseException(HttpResponseError): + """Server responded with exception of type: 'ErrorResponse'. + + :param response: Server response to be deserialized. + :param error_model: A deserialized model of the response body as model. + """ + + def __init__(self, response, error_model): + self.error = error_model + super(ErrorResponseException, self).__init__(response=response, error_model=error_model) + + @classmethod + def from_response(cls, response, deserialize): + """Deserialize this response as this exception, or a subclass of this exception. + + :param response: Server response to be deserialized. + :param deserialize: A deserializer + """ + model_name = 'ErrorResponse' + error = deserialize(model_name, response) + if error is None: + error = deserialize.dependencies[model_name]() + return error._EXCEPTION_TYPE(response, error) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: Error definition. + :type error: ~customproviders.models.ErrorDefinition + """ + _EXCEPTION_TYPE = ErrorResponseException + + _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..21094d77b4d --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_association_operations.py @@ -0,0 +1,365 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import 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.polling.arm_polling import ARMPolling + +from .. import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AssociationOperations(object): + """AssociationOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as 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 = kwargs.pop('error_map', {}) + + association = models.Association(target_resource_id=target_resource_id) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(association, 'Association') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + def begin_create_or_update( + self, + scope, # type: str + association_name, # type: str + target_resource_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "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.PollingMethod + :return: An instance of LROPoller that returns Association + :rtype: ~azure.core.polling.LROPoller[~customproviders.models.Association] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None ) # type: ClsType["models.Association"] + 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 + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + 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 = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + + # 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} + + def begin_delete( + self, + scope, # type: str + association_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete 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 + :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 + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None ) # type: ClsType[None] + raw_result = self._delete_initial( + scope=scope, + association_name=association_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + 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. 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 + :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: ~customproviders.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.Association"] + error_map = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + 'associationName': self._serialize.url("association_name", association_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = self._deserialize('Association', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations/{associationName}'} + + def list_all( + self, + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.AssociationsList" + """Gets all association for the given scope. + + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AssociationsList or the result of cls(response) + :rtype: ~customproviders.models.AssociationsList + :raises: ~customproviders.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.AssociationsList"] + error_map = 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'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/{scope}/providers/Microsoft.CustomProviders/associations'} 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..1baea81ccf1 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_custom_resource_provider_operations.py @@ -0,0 +1,508 @@ +# 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, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import 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.polling.arm_polling import ARMPolling + +from .. import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CustomResourceProviderOperations(object): + """CustomResourceProviderOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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["CustomRpActionRouteDefinition"]] + resource_types=None, # type: Optional[List["CustomRpResourceTypeRouteDefinition"]] + validations=None, # type: Optional[List["CustomRpValidations"]] + **kwargs # type: Any + ): + # type: (...) -> "models.CustomRpManifest" + cls = kwargs.pop('cls', None ) # type: ClsType["models.CustomRpManifest"] + error_map = 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" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(resource_provider, 'CustomRpManifest') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + 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["CustomRpActionRouteDefinition"]] + resource_types=None, # type: Optional[List["CustomRpResourceTypeRouteDefinition"]] + validations=None, # type: Optional[List["CustomRpValidations"]] + **kwargs # type: Any + ): + # type: (...) -> "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.PollingMethod + :return: An instance of LROPoller that returns CustomRpManifest + :rtype: ~azure.core.polling.LROPoller[~customproviders.models.CustomRpManifest] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None ) # type: ClsType["models.CustomRpManifest"] + 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 + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('CustomRpManifest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + 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 = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + + # 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders/{resourceProviderName}'} + + def begin_delete( + self, + resource_group_name, # type: str + resource_provider_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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.PollingMethod + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + + :raises ~customproviders.models.ErrorResponseException: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None ) # type: ClsType[None] + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + resource_provider_name=resource_provider_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + 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}'} + + 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: ~customproviders.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.CustomRpManifest"] + error_map = kwargs.pop('error_map', {}) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + 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: ~customproviders.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.CustomRpManifest"] + error_map = kwargs.pop('error_map', {}) + + patchable_resource = models.ResourceProvidersUpdate(tags=tags) + api_version = "2018-09-01-preview" + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderName': self._serialize.url("resource_provider_name", resource_provider_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(patchable_resource, 'ResourceProvidersUpdate') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + 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) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + 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}'} + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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: ListByCustomRpManifest or the result of cls(response) + :rtype: ~customproviders.models.ListByCustomRpManifest + :raises: ~customproviders.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.ListByCustomRpManifest"] + error_map = 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'] + 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) + else: + url = next_link + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CustomProviders/resourceProviders'} + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> "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: ListByCustomRpManifest or the result of cls(response) + :rtype: ~customproviders.models.ListByCustomRpManifest + :raises: ~customproviders.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.ListByCustomRpManifest"] + error_map = 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'] + 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) + else: + url = next_link + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.CustomProviders/resourceProviders'} 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..c487cb38942 --- /dev/null +++ b/src/customproviders/azext_customproviders/vendored_sdks/customproviders/operations/_operation_operations.py @@ -0,0 +1,99 @@ +# 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, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as 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: (...) -> "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: ResourceProviderOperationList or the result of cls(response) + :rtype: ~customproviders.models.ResourceProviderOperationList + :raises: ~customproviders.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.ResourceProviderOperationList"] + error_map = 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'] + else: + url = next_link + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + 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, 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.CustomProviders/operations'} diff --git a/src/customproviders/report.md b/src/customproviders/report.md new file mode 100644 index 00000000000..1ab413d3918 --- /dev/null +++ b/src/customproviders/report.md @@ -0,0 +1,91 @@ +# Azure CLI Module Creation Report + +### customproviders association create + +create a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +|**--association**|object|The parameters required to create or update an association.|/something/my_option|/something/myOption| +|--target-resource-id**|string|The REST resource instance of the target resource for this association.|/something/my_option|/something/myOption| +### customproviders association delete + +delete a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +### customproviders association list + +list a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +### customproviders association show + +show a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +### customproviders association update + +create a customproviders association. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +|**--association**|object|The parameters required to create or update an association.|/something/my_option|/something/myOption| +|--target-resource-id**|string|The REST resource instance of the target resource for this association.|/something/my_option|/something/myOption| +### customproviders custom-resource-provider create + +create a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +|**--resource-provider**|object|The parameters required to create or update a custom resource provider definition.|/something/my_option|/something/myOption| +|**--location**|string|Resource location|/something/my_option|/something/myOption| +|--tags**|dictionary|Resource tags|/something/my_option|/something/myOption| +|--actions**|array|A list of actions that the custom resource provider implements.|/something/my_option|/something/myOption| +|--resource-types**|array|A list of resource types that the custom resource provider implements.|/something/my_option|/something/myOption| +|--validations**|array|A list of validations to run on the custom resource provider's requests.|/something/my_option|/something/myOption| +### customproviders custom-resource-provider delete + +delete a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +### customproviders custom-resource-provider list + +list a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +### customproviders custom-resource-provider show + +show a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +### customproviders custom-resource-provider update + +update a customproviders custom-resource-provider. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| +|**--patchable-resource**|object|The updatable fields of a custom resource provider.|/something/my_option|/something/myOption| +|--tags**|dictionary|Resource tags|/something/my_option|/something/myOption| +### customproviders operation list + +list a customproviders operation. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--api-version**|constant|Api Version|/something/my_option|/something/myOption| \ No newline at end of file diff --git a/src/customproviders/setup.cfg b/src/customproviders/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/src/customproviders/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/customproviders/setup.py b/src/customproviders/setup.py new file mode 100644 index 00000000000..fd29f2c2647 --- /dev/null +++ b/src/customproviders/setup.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.rst', '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', + # TODO: Update author and email, if applicable + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + # TODO: consider pointing directly to your source code instead of the generic repo + url='https://github.com/Azure/azure-cli-extensions', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_customproviders': ['azext_metadata.json']}, +) diff --git a/swagger_to_sdk_config.json b/swagger_to_sdk_config.json new file mode 100644 index 00000000000..b72ffa2273b --- /dev/null +++ b/swagger_to_sdk_config.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://openapistorageprod.blob.core.windows.net/sdkautomation/prod/schemas/swagger_to_sdk_config.schema.json", + "meta": { + "autorest_options": { + "az": "", + "use": "@autorest/az@1.2.0", + "sdkrel:az-src-folder": "./src/.", + "version": "3.0.6198", + "sdkrel:output-folder":".", + "clear-output-folder":"false" + }, + "advanced_options": { + "create_sdk_pull_requests": true, + "sdk_generation_pull_request_base": "integration_branch" + }, + "repotag": "azure-cli-extensions", + "version": "0.1.0" + } +}