From 0fa9b1661ee7d17e3837e6dc67df79015c9c5a76 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Tue, 24 Mar 2020 23:51:28 +0000 Subject: [PATCH] Generated from af8f1d62191b9d7b43bda26417d04cfadcdd9f53 Updating Dashboards properties type to integer Updating Dashboards properties type to integer --- src/portal/HISTORY.rst | 8 + src/portal/README.rst | 5 + src/portal/azext_portal/__init__.py | 31 ++ src/portal/azext_portal/action.py | 12 + src/portal/azext_portal/azext_metadata.json | 4 + src/portal/azext_portal/commands.py | 12 + src/portal/azext_portal/custom.py | 12 + .../azext_portal/generated/_client_factory.py | 14 + src/portal/azext_portal/generated/_help.py | 65 +++ src/portal/azext_portal/generated/_params.py | 44 ++ .../azext_portal/generated/_validators.py | 18 + src/portal/azext_portal/generated/action.py | 26 + src/portal/azext_portal/generated/commands.py | 20 + src/portal/azext_portal/generated/custom.py | 48 ++ .../azext_portal/tests/latest/__init__.py | 4 + .../azext_portal/tests/latest/preparers.py | 111 +++++ .../tests/latest/test_portal_scenario.py | 56 +++ .../azext_portal/vendored_sdks/__init__.py | 12 + .../vendored_sdks/portal/__init__.py | 10 + .../vendored_sdks/portal/_configuration.py | 60 +++ .../vendored_sdks/portal/_portal.py | 67 +++ .../vendored_sdks/portal/aio/__init__.py | 10 + .../portal/aio/_configuration_async.py | 58 +++ .../vendored_sdks/portal/aio/_portal_async.py | 63 +++ .../portal/aio/operations_async/__init__.py | 15 + .../_dashboard_operations_async.py | 422 ++++++++++++++++ .../_operation_operations_async.py | 98 ++++ .../vendored_sdks/portal/models/__init__.py | 49 ++ .../vendored_sdks/portal/models/_models.py | 405 ++++++++++++++++ .../portal/models/_models_py3.py | 449 ++++++++++++++++++ .../portal/operations/__init__.py | 15 + .../operations/_dashboard_operations.py | 428 +++++++++++++++++ .../operations/_operation_operations.py | 99 ++++ src/portal/report.md | 48 ++ src/portal/setup.cfg | 2 + src/portal/setup.py | 60 +++ 36 files changed, 2860 insertions(+) create mode 100644 src/portal/HISTORY.rst create mode 100644 src/portal/README.rst create mode 100644 src/portal/azext_portal/__init__.py create mode 100644 src/portal/azext_portal/action.py create mode 100644 src/portal/azext_portal/azext_metadata.json create mode 100644 src/portal/azext_portal/commands.py create mode 100644 src/portal/azext_portal/custom.py create mode 100644 src/portal/azext_portal/generated/_client_factory.py create mode 100644 src/portal/azext_portal/generated/_help.py create mode 100644 src/portal/azext_portal/generated/_params.py create mode 100644 src/portal/azext_portal/generated/_validators.py create mode 100644 src/portal/azext_portal/generated/action.py create mode 100644 src/portal/azext_portal/generated/commands.py create mode 100644 src/portal/azext_portal/generated/custom.py create mode 100644 src/portal/azext_portal/tests/latest/__init__.py create mode 100644 src/portal/azext_portal/tests/latest/preparers.py create mode 100644 src/portal/azext_portal/tests/latest/test_portal_scenario.py create mode 100644 src/portal/azext_portal/vendored_sdks/__init__.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/__init__.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/_configuration.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/_portal.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/__init__.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_dashboard_operations_async.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_operation_operations_async.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/models/__init__.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/models/_models.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py create mode 100644 src/portal/report.md create mode 100644 src/portal/setup.cfg create mode 100644 src/portal/setup.py diff --git a/src/portal/HISTORY.rst b/src/portal/HISTORY.rst new file mode 100644 index 00000000000..27f152061e8 --- /dev/null +++ b/src/portal/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/portal/README.rst b/src/portal/README.rst new file mode 100644 index 00000000000..8b94239e86f --- /dev/null +++ b/src/portal/README.rst @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'portal' Extension +========================================== + +This package is for the 'portal' extension. +i.e. 'az portal' diff --git a/src/portal/azext_portal/__init__.py b/src/portal/azext_portal/__init__.py new file mode 100644 index 00000000000..9d7e1d918ae --- /dev/null +++ b/src/portal/azext_portal/__init__.py @@ -0,0 +1,31 @@ +# -------------------------------------------------------------------------------------------- +# 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 .generated._help import helps + + +class PortalCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from .generated._client_factory import cf_portal + portal_custom = CliCommandType( + operations_tmpl='azext_portal.custom#{}', + client_factory=cf_portal) + super(PortalCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=portal_custom) + + def load_command_table(self, args): + from .generated.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from .generated._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = PortalCommandsLoader diff --git a/src/portal/azext_portal/action.py b/src/portal/azext_portal/action.py new file mode 100644 index 00000000000..2cb3583de76 --- /dev/null +++ b/src/portal/azext_portal/action.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/portal/azext_portal/azext_metadata.json b/src/portal/azext_portal/azext_metadata.json new file mode 100644 index 00000000000..fc707c41f3b --- /dev/null +++ b/src/portal/azext_portal/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.0.67" +} \ No newline at end of file diff --git a/src/portal/azext_portal/commands.py b/src/portal/azext_portal/commands.py new file mode 100644 index 00000000000..73c5cb52b0f --- /dev/null +++ b/src/portal/azext_portal/commands.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.commands import * # noqa: F403 +try: + from .manual.commands import * # noqa: F403 +except ImportError: + pass diff --git a/src/portal/azext_portal/custom.py b/src/portal/azext_portal/custom.py new file mode 100644 index 00000000000..41ab47d5063 --- /dev/null +++ b/src/portal/azext_portal/custom.py @@ -0,0 +1,12 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/portal/azext_portal/generated/_client_factory.py b/src/portal/azext_portal/generated/_client_factory.py new file mode 100644 index 00000000000..c45a81045cf --- /dev/null +++ b/src/portal/azext_portal/generated/_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_portal(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.portal import Portal + return get_mgmt_service_client(cli_ctx, Portal) + + +def cf_dashboard(cli_ctx, *_): + return cf_portal(cli_ctx).dashboard diff --git a/src/portal/azext_portal/generated/_help.py b/src/portal/azext_portal/generated/_help.py new file mode 100644 index 00000000000..c8959ceb9bc --- /dev/null +++ b/src/portal/azext_portal/generated/_help.py @@ -0,0 +1,65 @@ +# -------------------------------------------------------------------------------------------- +# 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 + +from knack.help_files import helps + + +helps['portal dashboard'] = """ + type: group + short-summary: portal dashboard +""" + +helps['portal dashboard list'] = """ + type: command + short-summary: Gets all the dashboards within a subscription. + examples: + - name: List all custom resource providers on the resourceGroup + text: |- + az portal dashboard list --resource-group "testRG" +""" + +helps['portal dashboard show'] = """ + type: command + short-summary: Gets the Dashboard. + examples: + - name: Get a Dashboard + text: |- + az portal dashboard show --dashboard-name "testDashboard" --resource-group "testRG" +""" + +helps['portal dashboard create'] = """ + type: command + short-summary: Creates or updates a Dashboard. + examples: + - name: Create or update a Dashboard + text: |- + az portal dashboard create --location "eastus" --properties-lenses "{\\"aLens\\":{\\"order\\": + 1,\\"parts\\":{\\"aPart\\":{\\"position\\":{\\"colSpan\\":3,\\"rowSpan\\":4,\\"x\\":1,\\"y\\":2}},\\"bPar + t\\":{\\"position\\":{\\"colSpan\\":6,\\"rowSpan\\":6,\\"x\\":5,\\"y\\":5}}}},\\"bLens\\":{\\"order\\":2, + \\"parts\\":{}}}" --properties-metadata metadata=[object Object] --tags + aKey=aValue anotherKey=anotherValue --dashboard-name "testDashboard" --resource-group + "testRG" +""" + +helps['portal dashboard update'] = """ + type: command + short-summary: Updates an existing Dashboard. + examples: + - name: Update a Dashboard + text: |- + az portal dashboard update --tags aKey=bValue anotherKey=anotherValue2 --dashboard-name + "testDashboard" --resource-group "testRG" +""" + +helps['portal dashboard delete'] = """ + type: command + short-summary: Deletes the Dashboard. + examples: + - name: Delete a Dashboard + text: |- + az portal dashboard delete --dashboard-name "testDashboard" --resource-group "testRG" +""" diff --git a/src/portal/azext_portal/generated/_params.py b/src/portal/azext_portal/generated/_params.py new file mode 100644 index 00000000000..6c71fbfab3f --- /dev/null +++ b/src/portal/azext_portal/generated/_params.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=line-too-long +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.arguments import CLIArgumentType +from azure.cli.core.commands.parameters import ( + tags_type, + resource_group_name_type, + get_location_type +) +from azext_portal.action import AddMetadata + + +def load_arguments(self, _): + + with self.argument_context('portal dashboard list') as c: + c.argument('resource_group_name', resource_group_name_type, help='The name of the resource group.') + + with self.argument_context('portal dashboard show') as c: + c.argument('resource_group_name', resource_group_name_type, help='The name of the resource group.') + c.argument('dashboard_name', help='The name of the dashboard.') + + with self.argument_context('portal dashboard create') as c: + c.argument('resource_group_name', resource_group_name_type, help='The name of the resource group.') + c.argument('dashboard_name', help='The name of the dashboard.') + c.argument('location', arg_type=get_location_type(self.cli_ctx), help='Resource location') + c.argument('tags', tags_type, help='Resource tags') + c.argument('properties_lenses', arg_type=CLIArgumentType(options_list=['--properties-lenses'], help='The dashboard lenses.')) + c.argument('properties_metadata', action=AddMetadata, nargs='+', help='The dashboard metadata.') + + with self.argument_context('portal dashboard update') as c: + c.argument('resource_group_name', resource_group_name_type, help='The name of the resource group.') + c.argument('dashboard_name', help='The name of the dashboard.') + c.argument('tags', tags_type, help='Resource tags') + c.argument('properties_lenses', arg_type=CLIArgumentType(options_list=['--properties-lenses'], help='The dashboard lenses.')) + c.argument('properties_metadata', action=AddMetadata, nargs='+', help='The dashboard metadata.') + + with self.argument_context('portal dashboard delete') as c: + c.argument('resource_group_name', resource_group_name_type, help='The name of the resource group.') + c.argument('dashboard_name', help='The name of the dashboard.') diff --git a/src/portal/azext_portal/generated/_validators.py b/src/portal/azext_portal/generated/_validators.py new file mode 100644 index 00000000000..25e260a7bb4 --- /dev/null +++ b/src/portal/azext_portal/generated/_validators.py @@ -0,0 +1,18 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/portal/azext_portal/generated/action.py b/src/portal/azext_portal/generated/action.py new file mode 100644 index 00000000000..207ef2aac6e --- /dev/null +++ b/src/portal/azext_portal/generated/action.py @@ -0,0 +1,26 @@ +# -------------------------------------------------------------------------------------------- +# 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 + +import argparse +from knack.util import CLIError + + +class AddMetadata(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.properties_metadata = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = dict(x.split('=', 1) for x in values) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + d[k] = v + return d diff --git a/src/portal/azext_portal/generated/commands.py b/src/portal/azext_portal/generated/commands.py new file mode 100644 index 00000000000..48ca13e38cc --- /dev/null +++ b/src/portal/azext_portal/generated/commands.py @@ -0,0 +1,20 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_portal.generated._client_factory import cf_dashboard + portal_dashboard = CliCommandType( + operations_tmpl='azext_portal.vendored_sdks.portal.operations._dashboard_operations#DashboardOperations.{}', + client_factory=cf_dashboard) + with self.command_group('portal dashboard', portal_dashboard, client_factory=cf_dashboard) as g: + g.custom_command('list', 'portal_dashboard_list') + g.custom_show_command('show', 'portal_dashboard_show') + g.custom_command('create', 'portal_dashboard_create') + g.custom_command('update', 'portal_dashboard_update') + g.custom_command('delete', 'portal_dashboard_delete') diff --git a/src/portal/azext_portal/generated/custom.py b/src/portal/azext_portal/generated/custom.py new file mode 100644 index 00000000000..c1a69d5d4f6 --- /dev/null +++ b/src/portal/azext_portal/generated/custom.py @@ -0,0 +1,48 @@ +# -------------------------------------------------------------------------------------------- +# 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 + +import json + + +def portal_dashboard_list(cmd, client, + resource_group_name=None): + if resource_group_name is not None: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list_by_subscription() + + +def portal_dashboard_show(cmd, client, + resource_group_name, + dashboard_name): + return client.get(resource_group_name=resource_group_name, dashboard_name=dashboard_name) + + +def portal_dashboard_create(cmd, client, + resource_group_name, + dashboard_name, + location, + tags=None, + properties_lenses=None, + properties_metadata=None): + properties_lenses = json.loads(properties_lenses) if isinstance(properties_lenses, str) else properties_lenses + return client.create_or_update(resource_group_name=resource_group_name, dashboard_name=dashboard_name, location=location, tags=tags, lenses=properties_lenses, metadata=properties_metadata) + + +def portal_dashboard_update(cmd, client, + resource_group_name, + dashboard_name, + tags=None, + properties_lenses=None, + properties_metadata=None): + properties_lenses = json.loads(properties_lenses) if isinstance(properties_lenses, str) else properties_lenses + return client.update(resource_group_name=resource_group_name, dashboard_name=dashboard_name, tags=tags, lenses=properties_lenses, metadata=properties_metadata) + + +def portal_dashboard_delete(cmd, client, + resource_group_name, + dashboard_name): + return client.delete(resource_group_name=resource_group_name, dashboard_name=dashboard_name) diff --git a/src/portal/azext_portal/tests/latest/__init__.py b/src/portal/azext_portal/tests/latest/__init__.py new file mode 100644 index 00000000000..944e5654667 --- /dev/null +++ b/src/portal/azext_portal/tests/latest/__init__.py @@ -0,0 +1,4 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- diff --git a/src/portal/azext_portal/tests/latest/preparers.py b/src/portal/azext_portal/tests/latest/preparers.py new file mode 100644 index 00000000000..48c7b77dcaf --- /dev/null +++ b/src/portal/azext_portal/tests/latest/preparers.py @@ -0,0 +1,111 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +from datetime import datetime +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer +from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.exceptions import CliTestError +from azure.cli.testsdk.reverse_dependency import get_dummy_cli + + +KEY_RESOURCE_GROUP = 'rg' +KEY_VIRTUAL_NETWORK = 'vnet' +KEY_VNET_SUBNET = 'subnet' + + +class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='virtual_network', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + dev_setting_name='AZURE_CLI_TEST_DEV_VIRTUAL_NETWORK_NAME', + random_name_length=24, key=KEY_VIRTUAL_NETWORK): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VirtualNetworkPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + + tags = {'product': 'azurecli', 'cause': 'automation', + 'date': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')} + if 'ENV_JOB_NAME' in os.environ: + tags['job'] = os.environ['ENV_JOB_NAME'] + tags = ' '.join(['{}={}'.format(key, value) + for key, value in tags.items()]) + template = 'az network vnet create --resource-group {} --name {} --tag ' + tags + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group_name, name)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + # delete vnet if test is being recorded and if the vnet is not a dev rg + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + + +class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='subnet', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + vnet_name=None, + vnet_key=KEY_VIRTUAL_NETWORK, + address_prefixes="11.0.0.0/24", + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', + random_name_length=24, key=KEY_VNET_SUBNET): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetSubnetPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.vnet_name = vnet_name + self.vnet_key = vnet_key + self.address_prefixes = address_prefixes + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + if not self.vnet_name: + self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) + if not self.vnet_name: + raise CliTestError("Error: No vnet configured!") + + self.test_class_instance.kwargs[self.key] = 'default' + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + pass diff --git a/src/portal/azext_portal/tests/latest/test_portal_scenario.py b/src/portal/azext_portal/tests/latest/test_portal_scenario.py new file mode 100644 index 00000000000..1847d1f6582 --- /dev/null +++ b/src/portal/azext_portal/tests/latest/test_portal_scenario.py @@ -0,0 +1,56 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import unittest + +from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import ScenarioTest +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +class PortalScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_portal_testRG'[:9], key='rg') + def test_portal(self, resource_group): + + self.kwargs.update({ + 'testDashboard': self.create_random_name(prefix='cli_test_dashboards'[:9], length=24), + }) + + self.cmd('az portal dashboard create ' + '--location "eastus" ' + '--properties-lenses "{{\\"aLens\\":{{\\"order\\":1,\\"parts\\":{{\\"aPart\\":{{\\"position\\":{{\\"colSpan\\":3,\\"rowSpan\\":4,\\"x\\":1,\\"y\\":2}}}},\\"bPart\\":{{\\"position\\":{{\\"colSpan\\":6,\\"rowSpan\\":6,\\"x\\":5,\\"y\\":5}}}}}}}},\\"bLens\\":{{\\"order\\":2,\\"parts\\":{{}}}}}}" ' + '--properties-metadata metadata=[object Object]=undefined ' + '--tags aKey=aValue anotherKey=anotherValue ' + '--dashboard-name "{testDashboard}" ' + '--resource-group "{rg}"', + checks=[]) + + self.cmd('az portal dashboard show ' + '--dashboard-name "{testDashboard}" ' + '--resource-group "{rg}"', + checks=[]) + + self.cmd('az portal dashboard list ' + '--resource-group "{rg}"', + checks=[]) + + self.cmd('az portal dashboard list', + checks=[]) + + self.cmd('az portal dashboard update ' + '--tags aKey=bValue anotherKey=anotherValue2 ' + '--dashboard-name "{testDashboard}" ' + '--resource-group "{rg}"', + checks=[]) + + self.cmd('az portal dashboard delete ' + '--dashboard-name "{testDashboard}" ' + '--resource-group "{rg}"', + checks=[]) diff --git a/src/portal/azext_portal/vendored_sdks/__init__.py b/src/portal/azext_portal/vendored_sdks/__init__.py new file mode 100644 index 00000000000..8d86d5a6be1 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/src/portal/azext_portal/vendored_sdks/portal/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/__init__.py new file mode 100644 index 00000000000..a2795e0ed3f --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._portal import Portal +__all__ = ['Portal'] diff --git a/src/portal/azext_portal/vendored_sdks/portal/_configuration.py b/src/portal/azext_portal/vendored_sdks/portal/_configuration.py new file mode 100644 index 00000000000..69420dd4e61 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/_configuration.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 typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +VERSION = "unknown" + +class PortalConfiguration(Configuration): + """Configuration for Portal + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: azure.core.credentials.TokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(PortalConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-01-01-preview" + self._configure(**kwargs) + self.user_agent_policy.add_user_agent('azsdk-python-portal/{}'.format(VERSION)) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, **kwargs) diff --git a/src/portal/azext_portal/vendored_sdks/portal/_portal.py b/src/portal/azext_portal/vendored_sdks/portal/_portal.py new file mode 100644 index 00000000000..1ca59444489 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/_portal.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import PortalConfiguration +from .operations import OperationOperations +from .operations import DashboardOperations +from . import models + + +class Portal(object): + """Allows creation and deletion of Azure Shared Dashboards. + + :ivar operation: OperationOperations operations + :vartype operation: portal.operations.OperationOperations + :ivar dashboard: DashboardOperations operations + :vartype dashboard: portal.operations.DashboardOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: azure.core.credentials.TokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = PortalConfiguration(credential, subscription_id, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.dashboard = DashboardOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> Portal + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py new file mode 100644 index 00000000000..508cf5a4695 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._portal_async import Portal +__all__ = ['Portal'] diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py b/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py new file mode 100644 index 00000000000..f696a3c65d2 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +VERSION = "unknown" + +class PortalConfiguration(Configuration): + """Configuration for Portal + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: azure.core.credentials.TokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(PortalConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-01-01-preview" + self._configure(**kwargs) + self.user_agent_policy.add_user_agent('azsdk-python-portal/{}'.format(VERSION)) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, **kwargs) diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py b/src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py new file mode 100644 index 00000000000..878f1ca00ae --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.core import AsyncPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import PortalConfiguration +from .operations_async import OperationOperations +from .operations_async import DashboardOperations +from .. import models + + +class Portal(object): + """Allows creation and deletion of Azure Shared Dashboards. + + :ivar operation: OperationOperations operations + :vartype operation: portal.aio.operations_async.OperationOperations + :ivar dashboard: DashboardOperations operations + :vartype dashboard: portal.aio.operations_async.DashboardOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: azure.core.credentials.TokenCredential + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = PortalConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.dashboard = DashboardOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "Portal": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/__init__.py new file mode 100644 index 00000000000..1511df6e3b9 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operation_operations_async import OperationOperations +from ._dashboard_operations_async import DashboardOperations + +__all__ = [ + 'OperationOperations', + 'DashboardOperations', +] diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_dashboard_operations_async.py b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_dashboard_operations_async.py new file mode 100644 index 00000000000..000cbf46828 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_dashboard_operations_async.py @@ -0,0 +1,422 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DashboardOperations: + """DashboardOperations async operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~portal.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def create_or_update( + self, + resource_group_name: str, + dashboard_name: str, + location: str, + tags: Optional[Dict[str, str]] = None, + lenses: Optional[Dict[str, "DashboardLens"]] = None, + metadata: Optional[Dict[str, object]] = None, + **kwargs + ) -> "models.Dashboard": + """Creates or updates a Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :param location: Resource location. + :type location: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard or Dashboard or the result of cls(response) + :rtype: ~portal.models.Dashboard or ~portal.models.Dashboard + :raises: ~portal.models.ErrorResponseException: + """ + cls: ClsType["models.Dashboard"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + + dashboard = models.Dashboard(location=location, tags=tags, lenses=lenses, metadata=metadata) + api_version = "2019-01-01-preview" + + # 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'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(dashboard, 'Dashboard') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Dashboard', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Dashboard', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + async def delete( + self, + resource_group_name: str, + dashboard_name: str, + **kwargs + ) -> None: + """Deletes the Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~portal.models.ErrorResponseException: + """ + cls: ClsType[None] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + # 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'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + async def get( + self, + resource_group_name: str, + dashboard_name: str, + **kwargs + ) -> "models.Dashboard": + """Gets the Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard or the result of cls(response) + :rtype: ~portal.models.Dashboard + :raises: ~portal.models.ErrorResponseException: + """ + cls: ClsType["models.Dashboard"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = self._deserialize('Dashboard', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + async def update( + self, + resource_group_name: str, + dashboard_name: str, + tags: Optional[Dict[str, str]] = None, + lenses: Optional[Dict[str, "DashboardLens"]] = None, + metadata: Optional[Dict[str, object]] = None, + **kwargs + ) -> "models.Dashboard": + """Updates an existing Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard or the result of cls(response) + :rtype: ~portal.models.Dashboard + :raises: ~portal.models.ErrorResponseException: + """ + cls: ClsType["models.Dashboard"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + + dashboard = models.PatchableDashboard(tags=tags, lenses=lenses, metadata=metadata) + api_version = "2019-01-01-preview" + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(dashboard, 'PatchableDashboard') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = self._deserialize('Dashboard', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> "models.DashboardListResult": + """Gets all the Dashboards within a resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DashboardListResult or the result of cls(response) + :rtype: ~portal.models.DashboardListResult + :raises: ~portal.models.ErrorResponseException: + """ + cls: ClsType["models.DashboardListResult"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DashboardListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} + + def list_by_subscription( + self, + **kwargs + ) -> "models.DashboardListResult": + """Gets all the dashboards within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DashboardListResult or the result of cls(response) + :rtype: ~portal.models.DashboardListResult + :raises: ~portal.models.ErrorResponseException: + """ + cls: ClsType["models.DashboardListResult"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DashboardListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_operation_operations_async.py b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_operation_operations_async.py new file mode 100644 index 00000000000..aebe6bdf31d --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~portal.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> "models.ResourceProviderOperationList": + """The Microsoft Portal operations API. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceProviderOperationList or the result of cls(response) + :rtype: ~portal.models.ResourceProviderOperationList + :raises: ~portal.models.ErrorResponseException: + """ + cls: ClsType["models.ResourceProviderOperationList"] = kwargs.pop('cls', None ) + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # Construct parameters + query_parameters: Dict[str, Any] = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters: Dict[str, Any] = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Portal/operations'} diff --git a/src/portal/azext_portal/vendored_sdks/portal/models/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/models/__init__.py new file mode 100644 index 00000000000..84909621e71 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/models/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import Dashboard + from ._models_py3 import DashboardLens + from ._models_py3 import DashboardListResult + from ._models_py3 import DashboardParts + from ._models_py3 import DashboardPartsPosition + from ._models_py3 import DashboardProperties + from ._models_py3 import ErrorDefinition + from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import PatchableDashboard + from ._models_py3 import ResourceProviderOperation + from ._models_py3 import ResourceProviderOperationDisplay + from ._models_py3 import ResourceProviderOperationList +except (SyntaxError, ImportError): + from ._models import Dashboard # type: ignore + from ._models import DashboardLens # type: ignore + from ._models import DashboardListResult # type: ignore + from ._models import DashboardParts # type: ignore + from ._models import DashboardPartsPosition # type: ignore + from ._models import DashboardProperties # type: ignore + from ._models import ErrorDefinition # type: ignore + from ._models import ErrorResponse, ErrorResponseException # type: ignore + from ._models import PatchableDashboard # type: ignore + from ._models import ResourceProviderOperation # type: ignore + from ._models import ResourceProviderOperationDisplay # type: ignore + from ._models import ResourceProviderOperationList # type: ignore + +__all__ = [ + 'Dashboard', + 'DashboardLens', + 'DashboardListResult', + 'DashboardParts', + 'DashboardPartsPosition', + 'DashboardProperties', + 'ErrorDefinition', + 'ErrorResponse', 'ErrorResponseException', + 'PatchableDashboard', + 'ResourceProviderOperation', + 'ResourceProviderOperationDisplay', + 'ResourceProviderOperationList', +] diff --git a/src/portal/azext_portal/vendored_sdks/portal/models/_models.py b/src/portal/azext_portal/vendored_sdks/portal/models/_models.py new file mode 100644 index 00000000000..bc70d849819 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/models/_models.py @@ -0,0 +1,405 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Dashboard(msrest.serialization.Model): + """The shared dashboard resource definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Required. Resource location. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + """ + + _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}'}, + 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(Dashboard, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = kwargs.get('location', None) + self.tags = kwargs.get('tags', None) + self.lenses = kwargs.get('lenses', None) + self.metadata = kwargs.get('metadata', None) + + +class DashboardLens(msrest.serialization.Model): + """A dashboard lens. + + All required parameters must be populated in order to send to Azure. + + :param order: Required. The lens order. + :type order: int + :param parts: Required. The dashboard parts. + :type parts: dict[str, ~portal.models.DashboardParts] + :param metadata: The dashboard len's metadata. + :type metadata: dict[str, object] + """ + + _validation = { + 'order': {'required': True}, + 'parts': {'required': True}, + } + + _attribute_map = { + 'order': {'key': 'order', 'type': 'int'}, + 'parts': {'key': 'parts', 'type': '{DashboardParts}'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(DashboardLens, self).__init__(**kwargs) + self.order = kwargs.get('order', None) + self.parts = kwargs.get('parts', None) + self.metadata = kwargs.get('metadata', None) + + +class DashboardListResult(msrest.serialization.Model): + """List of dashboards. + + :param value: The array of custom resource provider manifests. + :type value: list[~portal.models.Dashboard] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Dashboard]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DashboardListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class DashboardParts(msrest.serialization.Model): + """A dashboard part. + + All required parameters must be populated in order to send to Azure. + + :param position: Required. The dashboard's part position. + :type position: ~portal.models.DashboardPartsPosition + :param metadata: The dashboard part's metadata. + :type metadata: dict[str, object] + """ + + _validation = { + 'position': {'required': True}, + } + + _attribute_map = { + 'position': {'key': 'position', 'type': 'DashboardPartsPosition'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(DashboardParts, self).__init__(**kwargs) + self.position = kwargs.get('position', None) + self.metadata = kwargs.get('metadata', None) + + +class DashboardPartsPosition(msrest.serialization.Model): + """The dashboard's part position. + + All required parameters must be populated in order to send to Azure. + + :param x: Required. The dashboard's part x coordinate. + :type x: int + :param y: Required. The dashboard's part y coordinate. + :type y: int + :param row_span: Required. The dashboard's part row span. + :type row_span: int + :param col_span: Required. The dashboard's part column span. + :type col_span: int + :param metadata: The dashboard part's metadata. + :type metadata: dict[str, object] + """ + + _validation = { + 'x': {'required': True}, + 'y': {'required': True}, + 'row_span': {'required': True}, + 'col_span': {'required': True}, + } + + _attribute_map = { + 'x': {'key': 'x', 'type': 'int'}, + 'y': {'key': 'y', 'type': 'int'}, + 'row_span': {'key': 'rowSpan', 'type': 'int'}, + 'col_span': {'key': 'colSpan', 'type': 'int'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(DashboardPartsPosition, self).__init__(**kwargs) + self.x = kwargs.get('x', None) + self.y = kwargs.get('y', None) + self.row_span = kwargs.get('row_span', None) + self.col_span = kwargs.get('col_span', None) + self.metadata = kwargs.get('metadata', None) + + +class DashboardProperties(msrest.serialization.Model): + """The shared dashboard properties. + + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + """ + + _attribute_map = { + 'lenses': {'key': 'lenses', 'type': '{DashboardLens}'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(DashboardProperties, self).__init__(**kwargs) + self.lenses = kwargs.get('lenses', None) + self.metadata = kwargs.get('metadata', None) + + +class ErrorDefinition(msrest.serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar details: Internal error details. + :vartype details: list[~portal.models.ErrorDefinition] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class ErrorResponseException(HttpResponseError): + """Server responded with exception of type: 'ErrorResponse'. + + :param response: Server response to be deserialized. + :param error_model: A deserialized model of the response body as model. + """ + + def __init__(self, response, error_model): + self.error = error_model + super(ErrorResponseException, self).__init__(response=response, error_model=error_model) + + @classmethod + def from_response(cls, response, deserialize): + """Deserialize this response as this exception, or a subclass of this exception. + + :param response: Server response to be deserialized. + :param deserialize: A deserializer + """ + model_name = 'ErrorResponse' + error = deserialize(model_name, response) + if error is None: + error = deserialize.dependencies[model_name]() + return error._EXCEPTION_TYPE(response, error) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: Error definition. + :type error: ~portal.models.ErrorDefinition + """ + _EXCEPTION_TYPE = ErrorResponseException + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class PatchableDashboard(msrest.serialization.Model): + """The shared dashboard resource definition. + + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(PatchableDashboard, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.lenses = kwargs.get('lenses', None) + self.metadata = kwargs.get('metadata', None) + + +class ResourceProviderOperation(msrest.serialization.Model): + """Supported operations of this resource provider. + + :param name: Operation name, in format of {provider}/{resource}/{operation}. + :type name: str + :param is_data_action: Indicates whether the operation applies to data-plane. + :type is_data_action: str + :param display: Display metadata associated with the operation. + :type display: ~portal.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.is_data_action = kwargs.get('is_data_action', None) + self.display = kwargs.get('display', None) + + +class ResourceProviderOperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft Custom Providers. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class ResourceProviderOperationList(msrest.serialization.Model): + """Results of the request to list operations. + + :param value: List of operations supported by this resource provider. + :type value: list[~portal.models.ResourceProviderOperation] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) diff --git a/src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py b/src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py new file mode 100644 index 00000000000..47507e86168 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py @@ -0,0 +1,449 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Dashboard(msrest.serialization.Model): + """The shared dashboard resource definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param location: Required. Resource location. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + """ + + _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}'}, + 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + lenses: Optional[Dict[str, "DashboardLens"]] = None, + metadata: Optional[Dict[str, object]] = None, + **kwargs + ): + super(Dashboard, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.lenses = lenses + self.metadata = metadata + + +class DashboardLens(msrest.serialization.Model): + """A dashboard lens. + + All required parameters must be populated in order to send to Azure. + + :param order: Required. The lens order. + :type order: int + :param parts: Required. The dashboard parts. + :type parts: dict[str, ~portal.models.DashboardParts] + :param metadata: The dashboard len's metadata. + :type metadata: dict[str, object] + """ + + _validation = { + 'order': {'required': True}, + 'parts': {'required': True}, + } + + _attribute_map = { + 'order': {'key': 'order', 'type': 'int'}, + 'parts': {'key': 'parts', 'type': '{DashboardParts}'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + *, + order: int, + parts: Dict[str, "DashboardParts"], + metadata: Optional[Dict[str, object]] = None, + **kwargs + ): + super(DashboardLens, self).__init__(**kwargs) + self.order = order + self.parts = parts + self.metadata = metadata + + +class DashboardListResult(msrest.serialization.Model): + """List of dashboards. + + :param value: The array of custom resource provider manifests. + :type value: list[~portal.models.Dashboard] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Dashboard]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Dashboard"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DashboardListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DashboardParts(msrest.serialization.Model): + """A dashboard part. + + All required parameters must be populated in order to send to Azure. + + :param position: Required. The dashboard's part position. + :type position: ~portal.models.DashboardPartsPosition + :param metadata: The dashboard part's metadata. + :type metadata: dict[str, object] + """ + + _validation = { + 'position': {'required': True}, + } + + _attribute_map = { + 'position': {'key': 'position', 'type': 'DashboardPartsPosition'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + *, + position: "DashboardPartsPosition", + metadata: Optional[Dict[str, object]] = None, + **kwargs + ): + super(DashboardParts, self).__init__(**kwargs) + self.position = position + self.metadata = metadata + + +class DashboardPartsPosition(msrest.serialization.Model): + """The dashboard's part position. + + All required parameters must be populated in order to send to Azure. + + :param x: Required. The dashboard's part x coordinate. + :type x: int + :param y: Required. The dashboard's part y coordinate. + :type y: int + :param row_span: Required. The dashboard's part row span. + :type row_span: int + :param col_span: Required. The dashboard's part column span. + :type col_span: int + :param metadata: The dashboard part's metadata. + :type metadata: dict[str, object] + """ + + _validation = { + 'x': {'required': True}, + 'y': {'required': True}, + 'row_span': {'required': True}, + 'col_span': {'required': True}, + } + + _attribute_map = { + 'x': {'key': 'x', 'type': 'int'}, + 'y': {'key': 'y', 'type': 'int'}, + 'row_span': {'key': 'rowSpan', 'type': 'int'}, + 'col_span': {'key': 'colSpan', 'type': 'int'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + *, + x: int, + y: int, + row_span: int, + col_span: int, + metadata: Optional[Dict[str, object]] = None, + **kwargs + ): + super(DashboardPartsPosition, self).__init__(**kwargs) + self.x = x + self.y = y + self.row_span = row_span + self.col_span = col_span + self.metadata = metadata + + +class DashboardProperties(msrest.serialization.Model): + """The shared dashboard properties. + + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + """ + + _attribute_map = { + 'lenses': {'key': 'lenses', 'type': '{DashboardLens}'}, + 'metadata': {'key': 'metadata', 'type': '{object}'}, + } + + def __init__( + self, + *, + lenses: Optional[Dict[str, "DashboardLens"]] = None, + metadata: Optional[Dict[str, object]] = None, + **kwargs + ): + super(DashboardProperties, self).__init__(**kwargs) + self.lenses = lenses + self.metadata = metadata + + +class ErrorDefinition(msrest.serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar details: Internal error details. + :vartype details: list[~portal.models.ErrorDefinition] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinition, self).__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class ErrorResponseException(HttpResponseError): + """Server responded with exception of type: 'ErrorResponse'. + + :param response: Server response to be deserialized. + :param error_model: A deserialized model of the response body as model. + """ + + def __init__(self, response, error_model): + self.error = error_model + super(ErrorResponseException, self).__init__(response=response, error_model=error_model) + + @classmethod + def from_response(cls, response, deserialize): + """Deserialize this response as this exception, or a subclass of this exception. + + :param response: Server response to be deserialized. + :param deserialize: A deserializer + """ + model_name = 'ErrorResponse' + error = deserialize(model_name, response) + if error is None: + error = deserialize.dependencies[model_name]() + return error._EXCEPTION_TYPE(response, error) + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :param error: Error definition. + :type error: ~portal.models.ErrorDefinition + """ + _EXCEPTION_TYPE = ErrorResponseException + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinition"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class PatchableDashboard(msrest.serialization.Model): + """The shared dashboard resource definition. + + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + lenses: Optional[Dict[str, "DashboardLens"]] = None, + metadata: Optional[Dict[str, object]] = None, + **kwargs + ): + super(PatchableDashboard, self).__init__(**kwargs) + self.tags = tags + self.lenses = lenses + self.metadata = metadata + + +class ResourceProviderOperation(msrest.serialization.Model): + """Supported operations of this resource provider. + + :param name: Operation name, in format of {provider}/{resource}/{operation}. + :type name: str + :param is_data_action: Indicates whether the operation applies to data-plane. + :type is_data_action: str + :param display: Display metadata associated with the operation. + :type display: ~portal.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[str] = None, + display: Optional["ResourceProviderOperationDisplay"] = None, + **kwargs + ): + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + + +class ResourceProviderOperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :param provider: Resource provider: Microsoft Custom Providers. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description of this operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(msrest.serialization.Model): + """Results of the request to list operations. + + :param value: List of operations supported by this resource provider. + :type value: list[~portal.models.ResourceProviderOperation] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceProviderOperation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link diff --git a/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py new file mode 100644 index 00000000000..9bffae3d64c --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operation_operations import OperationOperations +from ._dashboard_operations import DashboardOperations + +__all__ = [ + 'OperationOperations', + 'DashboardOperations', +] diff --git a/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py b/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py new file mode 100644 index 00000000000..2fc60a72680 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py @@ -0,0 +1,428 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DashboardOperations(object): + """DashboardOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~portal.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def create_or_update( + self, + resource_group_name, # type: str + dashboard_name, # type: str + location, # type: str + tags=None, # type: Optional[Dict[str, str]] + lenses=None, # type: Optional[Dict[str, "DashboardLens"]] + metadata=None, # type: Optional[Dict[str, object]] + **kwargs # type: Any + ): + # type: (...) -> "models.Dashboard" + """Creates or updates a Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :param location: Resource location. + :type location: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard or Dashboard or the result of cls(response) + :rtype: ~portal.models.Dashboard or ~portal.models.Dashboard + :raises: ~portal.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.Dashboard"] + error_map = kwargs.pop('error_map', {}) + + dashboard = models.Dashboard(location=location, tags=tags, lenses=lenses, metadata=metadata) + api_version = "2019-01-01-preview" + + # 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'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(dashboard, 'Dashboard') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Dashboard', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Dashboard', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + def delete( + self, + resource_group_name, # type: str + dashboard_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes the Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~portal.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType[None] + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + # 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'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + def get( + self, + resource_group_name, # type: str + dashboard_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Dashboard" + """Gets the Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard or the result of cls(response) + :rtype: ~portal.models.Dashboard + :raises: ~portal.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.Dashboard"] + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = self._deserialize('Dashboard', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + def update( + self, + resource_group_name, # type: str + dashboard_name, # type: str + tags=None, # type: Optional[Dict[str, str]] + lenses=None, # type: Optional[Dict[str, "DashboardLens"]] + metadata=None, # type: Optional[Dict[str, object]] + **kwargs # type: Any + ): + # type: (...) -> "models.Dashboard" + """Updates an existing Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param lenses: The dashboard lenses. + :type lenses: dict[str, ~portal.models.DashboardLens] + :param metadata: The dashboard metadata. + :type metadata: dict[str, object] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard or the result of cls(response) + :rtype: ~portal.models.Dashboard + :raises: ~portal.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.Dashboard"] + error_map = kwargs.pop('error_map', {}) + + dashboard = models.PatchableDashboard(tags=tags, lenses=lenses, metadata=metadata) + api_version = "2019-01-01-preview" + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json' + + # Construct body + body_content = self._serialize.body(dashboard, 'PatchableDashboard') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + deserialized = self._deserialize('Dashboard', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DashboardListResult" + """Gets all the Dashboards within a resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DashboardListResult or the result of cls(response) + :rtype: ~portal.models.DashboardListResult + :raises: ~portal.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.DashboardListResult"] + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DashboardListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.DashboardListResult" + """Gets all the dashboards within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DashboardListResult or the result of cls(response) + :rtype: ~portal.models.DashboardListResult + :raises: ~portal.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.DashboardListResult"] + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DashboardListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} diff --git a/src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py b/src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py new file mode 100644 index 00000000000..59145766d1b --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~portal.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.ResourceProviderOperationList" + """The Microsoft Portal operations API. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceProviderOperationList or the result of cls(response) + :rtype: ~portal.models.ResourceProviderOperationList + :raises: ~portal.models.ErrorResponseException: + """ + cls = kwargs.pop('cls', None ) # type: ClsType["models.ResourceProviderOperationList"] + error_map = kwargs.pop('error_map', {}) + api_version = "2019-01-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise models.ErrorResponseException.from_response(response, self._deserialize) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Portal/operations'} diff --git a/src/portal/report.md b/src/portal/report.md new file mode 100644 index 00000000000..2f8ada27cbf --- /dev/null +++ b/src/portal/report.md @@ -0,0 +1,48 @@ +# Azure CLI Module Creation Report + +### portal dashboard create + +create a portal dashboard. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource_group_name**|string|The name of the resource group.|resource_group_name|resource_group_name| +|**--dashboard_name**|string|The name of the dashboard.|dashboard_name|dashboard_name| +|**--location**|string|Resource location|location|location| +|**--tags**|dictionary|Resource tags|tags|tags| +|**--lenses**|dictionary|The dashboard lenses.|lenses|properties_lenses| +|**--metadata**|dictionary|The dashboard metadata.|metadata|properties_metadata| +### portal dashboard delete + +delete a portal dashboard. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource_group_name**|string|The name of the resource group.|resource_group_name|resource_group_name| +|**--dashboard_name**|string|The name of the dashboard.|dashboard_name|dashboard_name| +### portal dashboard list + +list a portal dashboard. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource_group_name**|string|The name of the resource group.|resource_group_name|resource_group_name| +### portal dashboard show + +show a portal dashboard. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource_group_name**|string|The name of the resource group.|resource_group_name|resource_group_name| +|**--dashboard_name**|string|The name of the dashboard.|dashboard_name|dashboard_name| +### portal dashboard update + +update a portal dashboard. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource_group_name**|string|The name of the resource group.|resource_group_name|resource_group_name| +|**--dashboard_name**|string|The name of the dashboard.|dashboard_name|dashboard_name| +|**--tags**|dictionary|Resource tags|tags|tags| +|**--lenses**|dictionary|The dashboard lenses.|lenses|properties_lenses| +|**--metadata**|dictionary|The dashboard metadata.|metadata|properties_metadata| \ No newline at end of file diff --git a/src/portal/setup.cfg b/src/portal/setup.cfg new file mode 100644 index 00000000000..5eab412034f --- /dev/null +++ b/src/portal/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/portal/setup.py b/src/portal/setup.py new file mode 100644 index 00000000000..40b3612ccf9 --- /dev/null +++ b/src/portal/setup.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.rst', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='portal', + version=VERSION, + description='Microsoft Azure Command-Line Tools Portal 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_portal': ['azext_metadata.json']}, +)