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