From d77132e7e39c7a3fd586629f92afab25256efccc Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Tue, 22 Sep 2020 04:46:13 +0000 Subject: [PATCH] Generated from 692005a0f4e7bf6408bf20193ec16166b80b4a38 --- src/portal/HISTORY.rst | 2 +- src/portal/azext_portal/__init__.py | 39 +- src/portal/azext_portal/action.py | 11 +- src/portal/azext_portal/azext_metadata.json | 2 +- src/portal/azext_portal/commands.py | 12 - src/portal/azext_portal/custom.py | 11 +- src/portal/azext_portal/generated/__init__.py | 2 + .../azext_portal/generated/_client_factory.py | 22 +- src/portal/azext_portal/generated/_help.py | 82 ++-- src/portal/azext_portal/generated/_params.py | 76 ++-- .../azext_portal/generated/_validators.py | 9 + src/portal/azext_portal/generated/action.py | 32 +- src/portal/azext_portal/generated/commands.py | 35 +- src/portal/azext_portal/generated/custom.py | 136 +++---- src/portal/azext_portal/manual/__init__.py | 12 + src/portal/azext_portal/tests/__init__.py | 114 ++++++ .../azext_portal/tests/latest/__init__.py | 14 +- .../azext_portal/tests/latest/dashboard.json | 60 --- .../azext_portal/tests/latest/preparers.py | 111 ----- .../tests/latest/properties-update.json | 35 -- .../azext_portal/tests/latest/properties.json | 35 -- .../tests/latest/test_portal_scenario.py | 256 +++++++----- .../azext_portal/vendored_sdks/__init__.py | 2 +- .../vendored_sdks/portal/__init__.py | 6 + .../vendored_sdks/portal/_configuration.py | 23 +- .../vendored_sdks/portal/_portal.py | 20 +- .../portal/aio/_configuration_async.py | 23 +- .../vendored_sdks/portal/aio/_portal_async.py | 20 +- .../portal/aio/operations_async/__init__.py | 2 + .../_dashboard_operations_async.py | 235 ++++++----- .../_operation_operations_async.py | 54 +-- .../_tenant_configuration_operations_async.py | 251 ++++++++++++ .../vendored_sdks/portal/models/__init__.py | 41 +- .../vendored_sdks/portal/models/_models.py | 352 +++++++++++++--- .../portal/models/_models_py3.py | 367 ++++++++++++++--- .../portal/models/_portal_enums.py | 31 ++ .../portal/operations/__init__.py | 2 + .../operations/_dashboard_operations.py | 379 +++++++----------- .../operations/_operation_operations.py | 62 +-- .../_tenant_configuration_operations.py | 259 ++++++++++++ .../vendored_sdks/portal/py.typed | 1 + src/portal/report.md | 181 +++++++++ src/portal/setup.cfg | 1 + src/portal/setup.py | 21 +- 44 files changed, 2322 insertions(+), 1119 deletions(-) delete mode 100644 src/portal/azext_portal/commands.py create mode 100644 src/portal/azext_portal/generated/_validators.py create mode 100644 src/portal/azext_portal/manual/__init__.py create mode 100644 src/portal/azext_portal/tests/__init__.py delete mode 100644 src/portal/azext_portal/tests/latest/dashboard.json delete mode 100644 src/portal/azext_portal/tests/latest/preparers.py delete mode 100644 src/portal/azext_portal/tests/latest/properties-update.json delete mode 100644 src/portal/azext_portal/tests/latest/properties.json create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_tenant_configuration_operations_async.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/models/_portal_enums.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/_tenant_configuration_operations.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/py.typed create mode 100644 src/portal/report.md diff --git a/src/portal/HISTORY.rst b/src/portal/HISTORY.rst index 10e842bc040..1c139576ba0 100644 --- a/src/portal/HISTORY.rst +++ b/src/portal/HISTORY.rst @@ -3,6 +3,6 @@ Release History =============== -0.1.1 +0.1.0 ++++++ * Initial release. diff --git a/src/portal/azext_portal/__init__.py b/src/portal/azext_portal/__init__.py index aa06a723e75..722135cbd50 100644 --- a/src/portal/azext_portal/__init__.py +++ b/src/portal/azext_portal/__init__.py @@ -1,31 +1,50 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- from azure.cli.core import AzCommandsLoader -from .generated._help import helps # pylint: disable=unused-import +from azext_portal.generated._help import helps # pylint: disable=unused-import +try: + from azext_portal.manual._help import helps # pylint: disable=reimported +except ImportError: + pass class PortalCommandsLoader(AzCommandsLoader): def __init__(self, cli_ctx=None): from azure.cli.core.commands import CliCommandType - from .generated._client_factory import cf_portal + from azext_portal.generated._client_factory import cf_portal_cl 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) + client_factory=cf_portal_cl) + parent = super(PortalCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=portal_custom) def load_command_table(self, args): - from .generated.commands import load_command_table + from azext_portal.generated.commands import load_command_table load_command_table(self, args) + try: + from azext_portal.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass return self.command_table def load_arguments(self, command): - from .generated._params import load_arguments + from azext_portal.generated._params import load_arguments load_arguments(self, command) + try: + from azext_portal.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass COMMAND_LOADER_CLS = PortalCommandsLoader diff --git a/src/portal/azext_portal/action.py b/src/portal/azext_portal/action.py index d66d3c5d0d7..d95d53bf711 100644 --- a/src/portal/azext_portal/action.py +++ b/src/portal/azext_portal/action.py @@ -1,7 +1,12 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- # pylint: disable=wildcard-import # pylint: disable=unused-wildcard-import diff --git a/src/portal/azext_portal/azext_metadata.json b/src/portal/azext_portal/azext_metadata.json index 13025150393..4f48fa652a5 100644 --- a/src/portal/azext_portal/azext_metadata.json +++ b/src/portal/azext_portal/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isExperimental": true, - "azext.minCliCoreVersion": "2.3.1" + "azext.minCliCoreVersion": "2.11.0" } \ No newline at end of file diff --git a/src/portal/azext_portal/commands.py b/src/portal/azext_portal/commands.py deleted file mode 100644 index 42f0c1a991e..00000000000 --- a/src/portal/azext_portal/commands.py +++ /dev/null @@ -1,12 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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 index d1fd3543ed0..dbe9d5f9742 100644 --- a/src/portal/azext_portal/custom.py +++ b/src/portal/azext_portal/custom.py @@ -1,7 +1,12 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- # pylint: disable=wildcard-import # pylint: disable=unused-wildcard-import diff --git a/src/portal/azext_portal/generated/__init__.py b/src/portal/azext_portal/generated/__init__.py index 59333308532..c9cfdc73e77 100644 --- a/src/portal/azext_portal/generated/__init__.py +++ b/src/portal/azext_portal/generated/__init__.py @@ -8,3 +8,5 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/portal/azext_portal/generated/_client_factory.py b/src/portal/azext_portal/generated/_client_factory.py index da39dd7f9fb..75b3d559aea 100644 --- a/src/portal/azext_portal/generated/_client_factory.py +++ b/src/portal/azext_portal/generated/_client_factory.py @@ -1,14 +1,24 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- -def cf_portal(cli_ctx, *_): +def cf_portal_cl(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) + return get_mgmt_service_client(cli_ctx, + Portal) def cf_dashboard(cli_ctx, *_): - return cf_portal(cli_ctx).dashboard + return cf_portal_cl(cli_ctx).dashboard + + +def cf_tenant_configuration(cli_ctx, *_): + return cf_portal_cl(cli_ctx).tenant_configuration diff --git a/src/portal/azext_portal/generated/_help.py b/src/portal/azext_portal/generated/_help.py index e702c567cbc..9e7401e5c3e 100644 --- a/src/portal/azext_portal/generated/_help.py +++ b/src/portal/azext_portal/generated/_help.py @@ -1,8 +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=line-too-long +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- # pylint: disable=too-many-lines from knack.help_files import helps @@ -10,24 +14,21 @@ helps['portal dashboard'] = """ type: group - short-summary: Manage portal dashboards + short-summary: portal dashboard """ helps['portal dashboard list'] = """ type: command - short-summary: Lists the dashboards within a subscription or resource group. + short-summary: "Gets all the dashboards within a subscription." examples: - - name: List all dashboards in a resourceGroup + - name: List all custom resource providers on the resourceGroup text: |- az portal dashboard list --resource-group "testRG" - - name: List all dashboards in a subscription - text: |- - az portal dashboard list """ helps['portal dashboard show'] = """ type: command - short-summary: Gets details for a single dashboard. + short-summary: "Gets the Dashboard." examples: - name: Get a Dashboard text: |- @@ -36,40 +37,73 @@ helps['portal dashboard create'] = """ type: command - short-summary: Creates or updates a dashboard. + short-summary: "Creates or updates a Dashboard." examples: - name: Create or update a Dashboard text: |- - az portal dashboard create --location "eastus" --name "testDashboard" \\ - --resource-group "testRG" --input-path "/src/json/properties.json" \\ - --tags aKey=aValue anotherKey=anotherValue + az portal dashboard create --location "eastus" --lenses "[{\\"order\\":1,\\"parts\\":[{\\"position\\":{\ +\\"colSpan\\":3,\\"rowSpan\\":4,\\"x\\":1,\\"y\\":2}},{\\"position\\":{\\"colSpan\\":6,\\"rowSpan\\":6,\\"x\\":5,\\"y\\\ +":5}}]},{\\"order\\":2,\\"parts\\":[]}]" --metadata "{\\"metadata\\":{\\"ColSpan\\":2,\\"RowSpan\\":1,\\"X\\":4,\\"Y\\"\ +:3}}" --tags aKey="aValue" anotherKey="anotherValue" --name "testDashboard" --resource-group "testRG" """ helps['portal dashboard update'] = """ type: command - short-summary: Updates an existing dashboard. + short-summary: "Updates an existing Dashboard." examples: - name: Update a Dashboard text: |- - az portal dashboard update --name "testDashboard" --resource-group "testRG" \\ - --input-path "/src/json/properties.json" + az portal dashboard update --tags aKey="bValue" anotherKey="anotherValue2" --name "testDashboard" \ +--resource-group "testRG" """ helps['portal dashboard delete'] = """ type: command - short-summary: Deletes a dashboard. + short-summary: "Deletes the Dashboard." examples: - name: Delete a Dashboard text: |- az portal dashboard delete --name "testDashboard" --resource-group "testRG" """ -helps['portal dashboard import'] = """ +helps['portal tenant-configuration'] = """ + type: group + short-summary: portal tenant-configuration +""" + +helps['portal tenant-configuration list'] = """ + type: command + short-summary: "Gets list of the tenant configurations." + examples: + - name: Get list of Tenant configurations + text: |- + az portal tenant-configuration list +""" + +helps['portal tenant-configuration show'] = """ + type: command + short-summary: "Gets the tenant configuration." + examples: + - name: Get Tenant configuration + text: |- + az portal tenant-configuration show +""" + +helps['portal tenant-configuration create'] = """ + type: command + short-summary: "Create the tenant configuration. If configuration already exists - update it. User has to be a \ +Tenant Admin for this operation." + examples: + - name: Create or update Tenant configuration + text: |- + az portal tenant-configuration create --enforce-private-markdown-storage true +""" + +helps['portal tenant-configuration delete'] = """ type: command - short-summary: Imports a dashboard from a JSON file. + short-summary: "Delete the tenant configuration. User has to be a Tenant Admin for this operation." examples: - - name: Import a Dashboard + - name: Delete Tenant configuration text: |- - az portal dashboard import --name "testDashboard" --resource-group "testRG" \\ - --input-path "/src/json/dashboard.json" + az portal tenant-configuration delete """ diff --git a/src/portal/azext_portal/generated/_params.py b/src/portal/azext_portal/generated/_params.py index e036901b70c..6c4ce1fa9ab 100644 --- a/src/portal/azext_portal/generated/_params.py +++ b/src/portal/azext_portal/generated/_params.py @@ -1,61 +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 +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- # pylint: disable=too-many-lines # pylint: disable=too-many-statements -from argcomplete.completers import FilesCompleter from azure.cli.core.commands.parameters import ( tags_type, + get_three_state_flag, resource_group_name_type, - get_location_type, - file_type + get_location_type +) +from azure.cli.core.commands.validators import ( + get_default_location_from_resource_group, + validate_file_or_dict ) -from azure.cli.core.commands.validators import get_default_location_from_resource_group 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.') + c.argument('resource_group_name', resource_group_name_type) with self.argument_context('portal dashboard show') as c: c.argument('resource_group_name', resource_group_name_type) - c.argument('name', options_list=[ - '--name', '-n'], help='The name of the dashboard.') + c.argument('dashboard_name', options_list=['--name', '-n', '--dashboard-name'], type=str, help='The name of ' + 'the dashboard.', id_part='name') 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('name', options_list=[ - '--name', '-n'], help='The name of the dashboard.') + c.argument('resource_group_name', resource_group_name_type) + c.argument('dashboard_name', options_list=['--name', '-n', '--dashboard-name'], type=str, help='The name of ' + 'the dashboard.') c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group) c.argument('tags', tags_type) - c.argument('input_path', type=file_type, - help='The path to the dashboard properties JSON file.', completer=FilesCompleter()) + c.argument('lenses', type=validate_file_or_dict, help='The dashboard lenses. Expected value: ' + 'json-string/@json-file.') + c.argument('metadata', type=validate_file_or_dict, help='The dashboard metadata. Expected value: ' + 'json-string/@json-file.') 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('name', options_list=[ - '--name', '-n'], help='The name of the dashboard.') - c.argument('input_path', type=file_type, - help='The path to the dashboard properties JSON file.', completer=FilesCompleter()) + c.argument('resource_group_name', resource_group_name_type) + c.argument('dashboard_name', options_list=['--name', '-n', '--dashboard-name'], type=str, help='The name of ' + 'the dashboard.', id_part='name') + c.argument('tags', tags_type) + c.argument('lenses', type=validate_file_or_dict, help='The dashboard lenses. Expected value: ' + 'json-string/@json-file.') + c.argument('metadata', type=validate_file_or_dict, help='The dashboard metadata. Expected value: ' + 'json-string/@json-file.') 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('name', options_list=[ - '--name', '-n'], help='The name of the dashboard.') - - with self.argument_context('portal dashboard import') as c: - c.argument('resource_group_name', resource_group_name_type, - help='The name of the resource group.') - c.argument('name', options_list=[ - '--name', '-n'], help='The name of the dashboard.') - c.argument('input_path', type=file_type, - help='The path to the dashboard json file.', completer=FilesCompleter()) + c.argument('resource_group_name', resource_group_name_type) + c.argument('dashboard_name', options_list=['--name', '-n', '--dashboard-name'], type=str, help='The name of ' + 'the dashboard.', id_part='name') + + with self.argument_context('portal tenant-configuration create') as c: + c.argument('enforce_private_markdown_storage', arg_type=get_three_state_flag(), help='When flag is set to true ' + 'Markdown tile will require external storage configuration (URI). The inline content configuration ' + 'will be prohibited.') diff --git a/src/portal/azext_portal/generated/_validators.py b/src/portal/azext_portal/generated/_validators.py new file mode 100644 index 00000000000..b33a44c1ebf --- /dev/null +++ b/src/portal/azext_portal/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- diff --git a/src/portal/azext_portal/generated/action.py b/src/portal/azext_portal/generated/action.py index d7d2d91da6b..b49bfaeeefe 100644 --- a/src/portal/azext_portal/generated/action.py +++ b/src/portal/azext_portal/generated/action.py @@ -1,26 +1,10 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- # pylint: disable=protected-access - -import argparse -from knack.util import CLIError - - -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: - 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 index 937cd6d167a..b96b349b95e 100644 --- a/src/portal/azext_portal/generated/commands.py +++ b/src/portal/azext_portal/generated/commands.py @@ -1,25 +1,40 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals from azure.cli.core.commands import CliCommandType def load_command_table(self, _): - with self.command_group('portal', is_experimental=True): - pass - 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: + with self.command_group('portal dashboard', portal_dashboard, client_factory=cf_dashboard, + is_experimental=True) 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', - confirmation=True) - g.custom_command('import', 'portal_dashboard_import') + g.custom_command('delete', 'portal_dashboard_delete', confirmation=True) + + from azext_portal.generated._client_factory import cf_tenant_configuration + portal_tenant_configuration = CliCommandType( + operations_tmpl='azext_portal.vendored_sdks.portal.operations._tenant_configuration_operations#TenantConfigurat' + 'ionOperations.{}', + client_factory=cf_tenant_configuration) + with self.command_group('portal tenant-configuration', portal_tenant_configuration, + client_factory=cf_tenant_configuration, is_experimental=True) as g: + g.custom_command('list', 'portal_tenant_configuration_list') + g.custom_show_command('show', 'portal_tenant_configuration_show') + g.custom_command('create', 'portal_tenant_configuration_create') + g.custom_command('delete', 'portal_tenant_configuration_delete', confirmation=True) diff --git a/src/portal/azext_portal/generated/custom.py b/src/portal/azext_portal/generated/custom.py index 1d4557ac4ab..ec8c2e7adff 100644 --- a/src/portal/azext_portal/generated/custom.py +++ b/src/portal/azext_portal/generated/custom.py @@ -1,100 +1,76 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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 +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- # pylint: disable=too-many-lines -import json -from knack.util import CLIError - -def portal_dashboard_list(cmd, client, +def portal_dashboard_list(client, resource_group_name=None): if resource_group_name: return client.list_by_resource_group(resource_group_name=resource_group_name) return client.list_by_subscription() -def portal_dashboard_show(cmd, client, +def portal_dashboard_show(client, resource_group_name, - name): - return client.get(resource_group_name=resource_group_name, dashboard_name=name) + dashboard_name): + return client.get(resource_group_name=resource_group_name, + dashboard_name=dashboard_name) -def portal_dashboard_create(cmd, client, +def portal_dashboard_create(client, + resource_group_name, + dashboard_name, + location, + tags=None, + lenses=None, + metadata=None): + return client.create_or_update(resource_group_name=resource_group_name, + dashboard_name=dashboard_name, + location=location, + tags=tags, + lenses=lenses, + metadata=metadata) + + +def portal_dashboard_update(client, resource_group_name, - name, - input_path, - location=None, - tags=None): - properties_lenses, properties_metadata = parse_properties_json(input_path) - return client.create_or_update(resource_group_name=resource_group_name, dashboard_name=name, location=location, tags=tags, lenses=properties_lenses, metadata=properties_metadata) + dashboard_name, + tags=None, + lenses=None, + metadata=None): + return client.update(resource_group_name=resource_group_name, + dashboard_name=dashboard_name, + tags=tags, + lenses=lenses, + metadata=metadata) + + +def portal_dashboard_delete(client, + resource_group_name, + dashboard_name): + return client.delete(resource_group_name=resource_group_name, + dashboard_name=dashboard_name) -def portal_dashboard_update(cmd, client, - resource_group_name, - name, - input_path): - properties_lenses, properties_metadata = parse_properties_json(input_path) - return client.update(resource_group_name=resource_group_name, dashboard_name=name, lenses=properties_lenses, metadata=properties_metadata) +def portal_tenant_configuration_list(client): + return client.list() -def portal_dashboard_delete(cmd, client, - resource_group_name, - name): - return client.delete(resource_group_name=resource_group_name, dashboard_name=name) +def portal_tenant_configuration_show(client): + return client.get() -def portal_dashboard_import(cmd, client, - resource_group_name, - input_path, - name=None): - dashboard = parse_dashboard_json(input_path) - return client.dashboard_import(resource_group_name=resource_group_name, dashboard_name=dashboard.get('name', name), dashboard=dashboard) - - -def parse_properties_json(input_path): - try: - with open(input_path) as json_file: - try: - properties = json.load(json_file) - except json.decoder.JSONDecodeError as ex: - raise CLIError( - 'JSON decode error for {}: {}'.format(json_file, str(ex))) - if 'lenses' not in properties: - raise CLIError(str(json_file) + - " does not contain the property 'lenses'") - properties_lenses = properties['lenses'] - if 'metadata' not in properties: - raise CLIError(str(json_file) + - " does not contain the property 'metadata'") - properties_metadata = properties['metadata'] - return properties_lenses, properties_metadata - except FileNotFoundError as ex: - raise CLIError('File not Found: {}'.format(str(ex))) - - -def parse_dashboard_json(input_path): - try: - with open(input_path) as json_file: - try: - dashboard = json.load(json_file) - except json.decoder.JSONDecodeError as ex: - raise CLIError( - 'There was an error decoding the JSON file {}: {}'.format(json_file, str(ex))) - if 'location' not in dashboard: - raise CLIError(str(json_file) + - " does not contain the property 'location'") - if 'properties' not in dashboard: - raise CLIError(str(json_file) + - " does not contain the property 'properties'") - if 'lenses' not in dashboard['properties']: - raise CLIError( - str(json_file) + " does not contain the property 'lenses' in 'properties'") - if 'metadata' not in dashboard['properties']: - raise CLIError( - str(json_file) + " does not contain the property 'metadata' in 'properties'") - return dashboard - except FileNotFoundError as ex: - raise CLIError('File not Found: {}'.format(str(ex))) +def portal_tenant_configuration_create(client, + enforce_private_markdown_storage=None): + return client.create(enforce_private_markdown_storage=enforce_private_markdown_storage) + + +def portal_tenant_configuration_delete(client): + return client.delete() diff --git a/src/portal/azext_portal/manual/__init__.py b/src/portal/azext_portal/manual/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/portal/azext_portal/manual/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/portal/azext_portal/tests/__init__.py b/src/portal/azext_portal/tests/__init__.py new file mode 100644 index 00000000000..50e0627daff --- /dev/null +++ b/src/portal/azext_portal/tests/__init__.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +import inspect +import logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/portal/azext_portal/tests/latest/__init__.py b/src/portal/azext_portal/tests/latest/__init__.py index 34913fb394d..c9cfdc73e77 100644 --- a/src/portal/azext_portal/tests/latest/__init__.py +++ b/src/portal/azext_portal/tests/latest/__init__.py @@ -1,4 +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. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/portal/azext_portal/tests/latest/dashboard.json b/src/portal/azext_portal/tests/latest/dashboard.json deleted file mode 100644 index c05eb79cd5b..00000000000 --- a/src/portal/azext_portal/tests/latest/dashboard.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "properties": { - "lenses": { - "0": { - "order": 0, - "parts": { - "0": { - "position": { - "x": 0, - "y": 0, - "colSpan": 6, - "rowSpan": 4 - }, - "metadata": { - "inputs": [ - { - "name": "resourceType", - "value": "Microsoft.Resources/subscriptions/resourcegroups", - "isOptional": true - }, - { - "name": "filter", - "isOptional": true - }, - { - "name": "scope", - "isOptional": true - }, - { - "name": "kind", - "isOptional": true - } - ], - "type": "Extension/HubsExtension/PartType/BrowseResourceGroupPinnedPart" - } - } - } - } - }, - "metadata": { - "model": { - "timeRange": { - "value": { - "relative": { - "duration": 24, - "timeUnit": 1 - } - }, - "type": "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange" - } - } - } - }, - "name": "7c0464ec-b1cd-4a98-a4a5-1ebe2d980260", - "type": "Microsoft.Portal/dashboards", - "location": "eastus", - "tags": { - "hidden-title": "test dashboard" - } -} \ No newline at end of file diff --git a/src/portal/azext_portal/tests/latest/preparers.py b/src/portal/azext_portal/tests/latest/preparers.py deleted file mode 100644 index 1388cfd22cc..00000000000 --- a/src/portal/azext_portal/tests/latest/preparers.py +++ /dev/null @@ -1,111 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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/properties-update.json b/src/portal/azext_portal/tests/latest/properties-update.json deleted file mode 100644 index 2e3e9bd56d4..00000000000 --- a/src/portal/azext_portal/tests/latest/properties-update.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "lenses": { - "0": { - "order": 0, - "parts": { - "0": { - "position": { - "x": 6, - "y": 2, - "colSpan": 2, - "rowSpan": 2 - }, - "metadata": { - "inputs": [], - "type": "Extension/HubsExtension/PartType/ClockPart", - "settings": {} - } - } - } - } - }, - "metadata": { - "model": { - "timeRange": { - "value": { - "relative": { - "duration": 12, - "timeUnit": 1 - } - }, - "type": "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange" - } - } - } -} \ No newline at end of file diff --git a/src/portal/azext_portal/tests/latest/properties.json b/src/portal/azext_portal/tests/latest/properties.json deleted file mode 100644 index 212a8ead593..00000000000 --- a/src/portal/azext_portal/tests/latest/properties.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "lenses": { - "0": { - "order": 0, - "parts": { - "0": { - "position": { - "x": 6, - "y": 2, - "colSpan": 2, - "rowSpan": 2 - }, - "metadata": { - "inputs": [], - "type": "Extension/HubsExtension/PartType/ClockPart", - "settings": {} - } - } - } - } - }, - "metadata": { - "model": { - "timeRange": { - "value": { - "relative": { - "duration": 24, - "timeUnit": 1 - } - }, - "type": "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange" - } - } - } -} \ No newline at end of file diff --git a/src/portal/azext_portal/tests/latest/test_portal_scenario.py b/src/portal/azext_portal/tests/latest/test_portal_scenario.py index 314740bbbe6..8fbb805ee36 100644 --- a/src/portal/azext_portal/tests/latest/test_portal_scenario.py +++ b/src/portal/azext_portal/tests/latest/test_portal_scenario.py @@ -1,111 +1,177 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- import os -import unittest - -from azure_devtools.scenario_tests import AllowLargeResponse -from azure.cli.testsdk import JMESPathCheck -from azure.cli.testsdk import JMESPathCheckExists -from azure.cli.testsdk import NoneCheck from azure.cli.testsdk import ScenarioTest +from .. import try_manual, raise_if, calc_coverage from azure.cli.testsdk import ResourceGroupPreparer TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) +@try_manual +def setup(test, rg): + pass + + +# EXAMPLE: /Dashboards/put/Create or update a Dashboard +@try_manual +def step__dashboards_put_create_or_update_a_dashboard(test, rg): + test.cmd('az portal dashboard create ' + '--location "eastus" ' + '--lenses "[{{\\"order\\":1,\\"parts\\":[{{\\"position\\":{{\\"colSpan\\":3,\\"rowSpan\\":4,\\"x\\":1,\\"y' + '\\":2}}}},{{\\"position\\":{{\\"colSpan\\":6,\\"rowSpan\\":6,\\"x\\":5,\\"y\\":5}}}}]}},{{\\"order\\":2,' + '\\"parts\\":[]}}]" ' + '--metadata "{{\\"metadata\\":{{\\"ColSpan\\":2,\\"RowSpan\\":1,\\"X\\":4,\\"Y\\":3}}}}" ' + '--tags aKey="aValue" anotherKey="anotherValue" ' + '--name "{myDashboard}" ' + '--resource-group "{rg}"', + checks=[ + test.check("location", "eastus", case_sensitive=False), + test.check("metadata.metadata.ColSpan", 2), + test.check("metadata.metadata.RowSpan", 1), + test.check("metadata.metadata.X", 4), + test.check("metadata.metadata.Y", 3), + test.check("tags.aKey", "aValue", case_sensitive=False), + test.check("tags.anotherKey", "anotherValue", case_sensitive=False), + test.check("name", "{myDashboard}", case_sensitive=False), + ]) + + +# EXAMPLE: /Dashboards/get/Get a Dashboard +@try_manual +def step__dashboards_get_get_a_dashboard(test, rg): + test.cmd('az portal dashboard show ' + '--name "{myDashboard}" ' + '--resource-group "{rg}"', + checks=[ + test.check("location", "eastus", case_sensitive=False), + test.check("metadata.metadata.ColSpan", 2), + test.check("metadata.metadata.RowSpan", 1), + test.check("metadata.metadata.X", 4), + test.check("metadata.metadata.Y", 3), + test.check("tags.aKey", "aValue", case_sensitive=False), + test.check("tags.anotherKey", "anotherValue", case_sensitive=False), + test.check("name", "{myDashboard}", case_sensitive=False), + ]) + + +# EXAMPLE: /Dashboards/get/List all custom resource providers on the resourceGroup +@try_manual +def step__dashboards_get(test, rg): + test.cmd('az portal dashboard list ' + '--resource-group "{rg}"', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Dashboards/get/List all custom resource providers on the subscription +@try_manual +def step__dashboards_get2(test, rg): + test.cmd('az portal dashboard list ' + '-g ""', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Dashboards/patch/Update a Dashboard +@try_manual +def step__dashboards_patch_update_a_dashboard(test, rg): + test.cmd('az portal dashboard update ' + '--tags aKey="bValue" anotherKey="anotherValue2" ' + '--name "{myDashboard}" ' + '--resource-group "{rg}"', + checks=[ + test.check("location", "eastus", case_sensitive=False), + test.check("metadata.metadata.ColSpan", 2), + test.check("metadata.metadata.RowSpan", 1), + test.check("metadata.metadata.X", 4), + test.check("metadata.metadata.Y", 3), + test.check("tags.aKey", "bValue", case_sensitive=False), + test.check("tags.anotherKey", "anotherValue2", case_sensitive=False), + test.check("name", "{myDashboard}", case_sensitive=False), + ]) + + +# EXAMPLE: /TenantConfigurations/put/Create or update Tenant configuration +@try_manual +def step__tenantconfigurations_put(test, rg): + test.cmd('az portal tenant-configuration create ' + '--enforce-private-markdown-storage true', + checks=[]) + + +# EXAMPLE: /TenantConfigurations/get/Get Tenant configuration +@try_manual +def step__tenantconfigurations_get(test, rg): + test.cmd('az portal tenant-configuration show', + checks=[]) + + +# EXAMPLE: /TenantConfigurations/get/Get list of Tenant configurations +@try_manual +def step__tenantconfigurations_get2(test, rg): + test.cmd('az portal tenant-configuration list', + checks=[]) + + +# EXAMPLE: /Dashboards/delete/Delete a Dashboard +@try_manual +def step__dashboards_delete_delete_a_dashboard(test, rg): + test.cmd('az portal dashboard delete -y ' + '--name "{myDashboard}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /TenantConfigurations/delete/Delete Tenant configuration +@try_manual +def step__tenantconfigurations_delete(test, rg): + test.cmd('az portal tenant-configuration delete -y', + checks=[]) + + +@try_manual +def cleanup(test, rg): + pass + + +@try_manual +def call_scenario(test, rg): + setup(test, rg) + step__dashboards_put_create_or_update_a_dashboard(test, rg) + step__dashboards_get_get_a_dashboard(test, rg) + step__dashboards_get(test, rg) + step__dashboards_get2(test, rg) + step__dashboards_patch_update_a_dashboard(test, rg) + step__tenantconfigurations_put(test, rg) + step__tenantconfigurations_get(test, rg) + step__tenantconfigurations_get2(test, rg) + step__dashboards_delete_delete_a_dashboard(test, rg) + step__tenantconfigurations_delete(test, rg) + cleanup(test, rg) + + +@try_manual class PortalScenarioTest(ScenarioTest): - @ResourceGroupPreparer(name_prefix='cli_test_portal_testRG'[:9], key='rg') - def test_portal(self, resource_group): + @ResourceGroupPreparer(name_prefix='clitestportal_testRG'[:7], key='rg', parameter_name='rg') + def test_portal(self, rg): self.kwargs.update({ - 'testDashboard': self.create_random_name(prefix='cli_test_dashboards'[:9], length=24) + 'myDashboard': 'testDashboard', }) - self.cmd('az portal dashboard create ' - '--location "eastus" ' - '--input- "src/portal/azext_portal/tests/latest/properties.json" ' - '--tags aKey=aValue anotherKey=anotherValue ' - '--name "{testDashboard}" ' - '--resource-group "{rg}"', - checks=[JMESPathCheck('name', self.kwargs.get('testDashboard', ''))]) - - self.cmd('az portal dashboard show ' - '--name "{testDashboard}" ' - '--resource-group "{rg}"', - checks=[ - JMESPathCheck('name', self.kwargs.get( - 'testDashboard', '')), - JMESPathCheck('resourceGroup', self.kwargs.get('rg', '')), - JMESPathCheck( - 'tags', '{\'aKey\': \'aValue\', \'anotherKey\': \'anotherValue\'}'), - JMESPathCheck('lenses', '{\'0\': {\'metadata\': None, \'order\': 0, \'parts\': ' - '{\'0\': {\'metadata\': {\'inputs\': [], \'settings\': {}, \'type\': ' - '\'Extension/HubsExtension/PartType/ClockPart\'}, \'position\': {\'colSpan\': 2, ' - '\'metadata\': None, \'rowSpan\': 2, \'x\': 6, \'y\': 2}}}}}'), - JMESPathCheck('metadata', '{\'model\': {\'timeRange\': {\'type\': ' - '\'MsPortalFx.Composition.Configuration.ValueTypes.TimeRange\', \'value\': ' - '{\'relative\': {\'duration\': 24, \'timeUnit\': 1}}}}}')]) - - self.cmd('az portal dashboard list ' - '--resource-group "{rg}"', - checks=[JMESPathCheckExists('[?name==\'{}\']'.format(self.kwargs.get('testDashboard', '')))]) - - self.cmd('az portal dashboard list ' - '--resource-group=', - checks=[JMESPathCheckExists('[?name==\'{}\']'.format(self.kwargs.get('testDashboard', '')))]) - - self.cmd('az portal dashboard update ' - '--input-path "src/portal/azext_portal/tests/latest/properties-update.json" ' - '--name "{testDashboard}" ' - '--resource-group "{rg}"', - checks=[ - JMESPathCheck('name', self.kwargs.get( - 'testDashboard', '')), - JMESPathCheck('resourceGroup', self.kwargs.get('rg', '')), - JMESPathCheck( - 'tags', '{\'aKey\': \'aValue\', \'anotherKey\': \'anotherValue\'}'), - JMESPathCheck('lenses', '{\'0\': {\'metadata\': None, \'order\': 0, \'parts\': ' - '{\'0\': {\'metadata\': {\'inputs\': [], \'settings\': {}, \'type\': ' - '\'Extension/HubsExtension/PartType/ClockPart\'}, \'position\': {\'colSpan\': 2, ' - '\'metadata\': None, \'rowSpan\': 2, \'x\': 6, \'y\': 2}}}}}'), - JMESPathCheck('metadata', '{\'model\': {\'timeRange\': {\'type\': ' - '\'MsPortalFx.Composition.Configuration.ValueTypes.TimeRange\', \'value\': ' - '{\'relative\': {\'duration\': 12, \'timeUnit\': 1}}}}}')]) - - self.cmd('az portal dashboard delete ' - '--name "{testDashboard}" ' - '--resource-group "{rg}" ' - '--y', - checks=[]) - - self.cmd('az portal dashboard list ' - '--resource-group "{rg}"', - checks=[NoneCheck()]) - - self.cmd('az portal dashboard import ' - '--input-path "src/portal/azext_portal/tests/latest/dashboard.json" ' - '--name "{testDashboard}" ' - '--resource-group "{rg}"', - checks=[ - JMESPathCheck( - 'name', '7c0464ec-b1cd-4a98-a4a5-1ebe2d980260'), - JMESPathCheck('resourceGroup', self.kwargs.get('rg', '')), - JMESPathCheck('location', 'eastus'), - JMESPathCheck('type', 'Microsoft.Portal/dashboards'), - JMESPathCheck( - 'tags', '{\'hidden-title\': \'test dashboard\'}'), - JMESPathCheck('lenses', '{\'0\': {\'metadata\': None, \'order\': 0, \'parts\': ' - '{\'0\': {\'metadata\': {\'inputs\': [{\'isOptional\': True, \'name\': ' - '\'resourceType\', \'value\': \'Microsoft.Resources/subscriptions/resourcegroups\'},' - ' {\'isOptional\': True, \'name\': \'filter\'}, {\'isOptional\': True, \'name\':' - ' \'scope\'}, {\'isOptional\': True, \'name\': \'kind\'}], \'type\': ' - '\'Extension/HubsExtension/PartType/BrowseResourceGroupPinnedPart\'}, \'position\': ' - '{\'colSpan\': 6, \'metadata\': None, \'rowSpan\': 4, \'x\': 0, \'y\': 0}}}}}'), - JMESPathCheck('metadata', '{\'model\': {\'timeRange\': {\'type\': ' - '\'MsPortalFx.Composition.Configuration.ValueTypes.TimeRange\', \'value\': ' - '{\'relative\': {\'duration\': 24, \'timeUnit\': 1}}}}}')]) + call_scenario(self, rg) + calc_coverage(__file__) + raise_if() diff --git a/src/portal/azext_portal/vendored_sdks/__init__.py b/src/portal/azext_portal/vendored_sdks/__init__.py index be1a152630c..c9cfdc73e77 100644 --- a/src/portal/azext_portal/vendored_sdks/__init__.py +++ b/src/portal/azext_portal/vendored_sdks/__init__.py @@ -9,4 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/portal/azext_portal/vendored_sdks/portal/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/__init__.py index a2795e0ed3f..52743869853 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/__init__.py +++ b/src/portal/azext_portal/vendored_sdks/portal/__init__.py @@ -8,3 +8,9 @@ from ._portal import Portal __all__ = ['Portal'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/portal/azext_portal/vendored_sdks/portal/_configuration.py b/src/portal/azext_portal/vendored_sdks/portal/_configuration.py index 69420dd4e61..459509ef6db 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/_configuration.py +++ b/src/portal/azext_portal/vendored_sdks/portal/_configuration.py @@ -6,20 +6,28 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from typing import TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential VERSION = "unknown" class PortalConfiguration(Configuration): - """Configuration for Portal + """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 + :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 """ @@ -39,9 +47,11 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-01-01-preview" + self.api_version = "2020-09-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'portal/{}'.format(VERSION)) self._configure(**kwargs) - self.user_agent_policy.add_user_agent('azsdk-python-portal/{}'.format(VERSION)) def _configure( self, @@ -52,9 +62,10 @@ def _configure( 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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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) + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/portal/azext_portal/vendored_sdks/portal/_portal.py b/src/portal/azext_portal/vendored_sdks/portal/_portal.py index 1ca59444489..b222cecb485 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/_portal.py +++ b/src/portal/azext_portal/vendored_sdks/portal/_portal.py @@ -6,14 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional +from typing import TYPE_CHECKING -from azure.core import PipelineClient +from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from ._configuration import PortalConfiguration from .operations import OperationOperations from .operations import DashboardOperations +from .operations import TenantConfigurationOperations from . import models @@ -24,11 +31,14 @@ class Portal(object): :vartype operation: portal.operations.OperationOperations :ivar dashboard: DashboardOperations operations :vartype dashboard: portal.operations.DashboardOperations + :ivar tenant_configuration: TenantConfigurationOperations operations + :vartype tenant_configuration: portal.operations.TenantConfigurationOperations :param credential: Credential needed for the client to connect to Azure. - :type credential: azure.core.credentials.TokenCredential + :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). :type subscription_id: str :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( @@ -42,7 +52,7 @@ def __init__( 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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -52,6 +62,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.dashboard = DashboardOperations( self._client, self._config, self._serialize, self._deserialize) + self.tenant_configuration = TenantConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize) def close(self): # type: () -> None 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 index f696a3c65d2..194a125a825 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py @@ -6,27 +6,33 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential VERSION = "unknown" class PortalConfiguration(Configuration): - """Configuration for Portal + """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 + :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). :type subscription_id: str """ def __init__( self, - credential: "TokenCredential", + credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any ) -> None: @@ -38,9 +44,11 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-01-01-preview" + self.api_version = "2020-09-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + kwargs.setdefault('sdk_moniker', 'portal/{}'.format(VERSION)) self._configure(**kwargs) - self.user_agent_policy.add_user_agent('azsdk-python-portal/{}'.format(VERSION)) def _configure( self, @@ -50,9 +58,10 @@ def _configure( 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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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) + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **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 index 878f1ca00ae..87792650e50 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py @@ -6,14 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional +from typing import Any, Optional, TYPE_CHECKING -from azure.core import AsyncPipelineClient +from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + from ._configuration_async import PortalConfiguration from .operations_async import OperationOperations from .operations_async import DashboardOperations +from .operations_async import TenantConfigurationOperations from .. import models @@ -24,16 +29,19 @@ class Portal(object): :vartype operation: portal.aio.operations_async.OperationOperations :ivar dashboard: DashboardOperations operations :vartype dashboard: portal.aio.operations_async.DashboardOperations + :ivar tenant_configuration: TenantConfigurationOperations operations + :vartype tenant_configuration: portal.aio.operations_async.TenantConfigurationOperations :param credential: Credential needed for the client to connect to Azure. - :type credential: azure.core.credentials.TokenCredential + :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). :type subscription_id: str :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( self, - credential: "TokenCredential", + credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any @@ -41,7 +49,7 @@ def __init__( 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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -51,6 +59,8 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.dashboard = DashboardOperations( self._client, self._config, self._serialize, self._deserialize) + self.tenant_configuration = TenantConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize) async def close(self) -> None: await self._client.close() 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 index 1511df6e3b9..7a987f579e7 100644 --- 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 @@ -8,8 +8,10 @@ from ._operation_operations_async import OperationOperations from ._dashboard_operations_async import DashboardOperations +from ._tenant_configuration_operations_async import TenantConfigurationOperations __all__ = [ 'OperationOperations', 'DashboardOperations', + 'TenantConfigurationOperations', ] 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 index 000cbf46828..d5d6382a7c4 100644 --- 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 @@ -5,13 +5,14 @@ # 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 +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import map_error +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models @@ -21,7 +22,8 @@ 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. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~portal.models @@ -45,7 +47,7 @@ async def create_or_update( dashboard_name: str, location: str, tags: Optional[Dict[str, str]] = None, - lenses: Optional[Dict[str, "DashboardLens"]] = None, + lenses: Optional[List[object]] = None, metadata: Optional[Dict[str, object]] = None, **kwargs ) -> "models.Dashboard": @@ -60,22 +62,24 @@ async def create_or_update( :param tags: Resource tags. :type tags: dict[str, str] :param lenses: The dashboard lenses. - :type lenses: dict[str, ~portal.models.DashboardLens] + :type lenses: list[object] :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: + :return: Dashboard, or the result of cls(response) + :rtype: ~portal.models.Dashboard + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType["models.Dashboard"] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) + cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) - dashboard = models.Dashboard(location=location, tags=tags, lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" + _dashboard = models.Dashboard(location=location, tags=tags, lenses=lenses, metadata=metadata) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -84,27 +88,27 @@ async def create_or_update( url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters: Dict[str, Any] = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters: Dict[str, Any] = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' - # Construct body - body_content = self._serialize.body(dashboard, 'Dashboard') + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_dashboard, 'Dashboard') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - # 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) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Dashboard', pipeline_response) @@ -112,10 +116,10 @@ async def create_or_update( deserialized = self._deserialize('Dashboard', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore async def delete( self, @@ -130,16 +134,17 @@ async def delete( :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) + :return: None, or the result of cls(response) :rtype: None - :raises: ~portal.models.ErrorResponseException: + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType[None] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -148,25 +153,25 @@ async def delete( url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters: Dict[str, Any] = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters: Dict[str, Any] = {} + header_parameters = {} # type: Dict[str, Any] - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorResponseException.from_response(response, self._deserialize) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore async def get( self, @@ -181,16 +186,17 @@ async def get( :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) + :return: Dashboard, or the result of cls(response) :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType["models.Dashboard"] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -199,36 +205,36 @@ async def get( url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters: Dict[str, Any] = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters: Dict[str, Any] = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorResponseException.from_response(response, self._deserialize) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Dashboard', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore async def update( self, resource_group_name: str, dashboard_name: str, tags: Optional[Dict[str, str]] = None, - lenses: Optional[Dict[str, "DashboardLens"]] = None, + lenses: Optional[List[object]] = None, metadata: Optional[Dict[str, object]] = None, **kwargs ) -> "models.Dashboard": @@ -241,22 +247,24 @@ async def update( :param tags: Resource tags. :type tags: dict[str, str] :param lenses: The dashboard lenses. - :type lenses: dict[str, ~portal.models.DashboardLens] + :type lenses: list[object] :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) + :return: Dashboard, or the result of cls(response) :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType["models.Dashboard"] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) + cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) - dashboard = models.PatchableDashboard(tags=tags, lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" + _dashboard = models.PatchableDashboard(tags=tags, lenses=lenses, metadata=metadata) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -265,74 +273,76 @@ async def update( url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters: Dict[str, Any] = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters: Dict[str, Any] = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' - # Construct body - body_content = self._serialize.body(dashboard, 'PatchableDashboard') + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_dashboard, 'PatchableDashboard') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - # 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) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Dashboard', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore def list_by_resource_group( self, resource_group_name: str, **kwargs - ) -> "models.DashboardListResult": + ) -> AsyncIterable["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: + :return: An iterator like instance of either DashboardListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~portal.models.DashboardListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType["models.DashboardListResult"] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.DashboardListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['url'] + url = self.list_by_resource_group.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) 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) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -340,7 +350,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) - return deserialized.next_link, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) @@ -349,52 +359,54 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorResponseException.from_response(response, self._deserialize) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} # type: ignore def list_by_subscription( self, **kwargs - ) -> "models.DashboardListResult": + ) -> AsyncIterable["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: + :return: An iterator like instance of either DashboardListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~portal.models.DashboardListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType["models.DashboardListResult"] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.DashboardListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + if not next_link: # Construct URL - url = self.list_by_subscription.metadata['url'] + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) 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) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -402,7 +414,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) - return deserialized.next_link, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) @@ -411,12 +423,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorResponseException.from_response(response, self._deserialize) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} # type: ignore 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 index aebe6bdf31d..b5f2de4c458 100644 --- 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 @@ -5,13 +5,14 @@ # 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 +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import map_error +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models @@ -21,7 +22,8 @@ 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. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~portal.models @@ -42,35 +44,36 @@ def __init__(self, client, config, serializer, deserializer) -> None: def list( self, **kwargs - ) -> "models.ResourceProviderOperationList": + ) -> AsyncIterable["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: + :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~portal.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType["models.ResourceProviderOperationList"] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceProviderOperationList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) 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) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -78,7 +81,7 @@ async def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) - return deserialized.next_link, AsyncList(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) @@ -87,12 +90,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorResponseException.from_response(response, self._deserialize) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Portal/operations'} + list.metadata = {'url': '/providers/Microsoft.Portal/operations'} # type: ignore diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_tenant_configuration_operations_async.py b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_tenant_configuration_operations_async.py new file mode 100644 index 00000000000..89b502ab63c --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_tenant_configuration_operations_async.py @@ -0,0 +1,251 @@ +# 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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantConfigurationOperations: + """TenantConfigurationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~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 list( + self, + **kwargs + ) -> "models.ConfigurationList": + """Gets list of the tenant configurations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationList, or the result of cls(response) + :rtype: ~portal.models.ConfigurationList + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations'} # type: ignore + + async def get( + self, + configuration_name: Union[str, "models.ConfigurationName"], + **kwargs + ) -> "models.Configuration": + """Gets the tenant configuration. + + :param configuration_name: The configuration name. Value must be 'default'. + :type configuration_name: str or ~portal.models.ConfigurationName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Configuration, or the result of cls(response) + :rtype: ~portal.models.Configuration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Configuration"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Configuration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations/{configurationName}'} # type: ignore + + async def create( + self, + configuration_name: Union[str, "models.ConfigurationName"], + enforce_private_markdown_storage: Optional[bool] = None, + **kwargs + ) -> "models.Configuration": + """Create the tenant configuration. If configuration already exists - update it. User has to be a + Tenant Admin for this operation. + + :param configuration_name: The configuration name. Value must be 'default'. + :type configuration_name: str or ~portal.models.ConfigurationName + :param enforce_private_markdown_storage: When flag is set to true Markdown tile will require + external storage configuration (URI). The inline content configuration will be prohibited. + :type enforce_private_markdown_storage: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Configuration, or the result of cls(response) + :rtype: ~portal.models.Configuration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Configuration"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _tenant_configuration = models.Configuration(enforce_private_markdown_storage=enforce_private_markdown_storage) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_tenant_configuration, 'Configuration') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Configuration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Configuration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations/{configurationName}'} # type: ignore + + async def delete( + self, + configuration_name: Union[str, "models.ConfigurationName"], + **kwargs + ) -> None: + """Delete the tenant configuration. User has to be a Tenant Admin for this operation. + + :param configuration_name: The configuration name. Value must be 'default'. + :type configuration_name: str or ~portal.models.ConfigurationName + :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: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + 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) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations/{configurationName}'} # type: ignore diff --git a/src/portal/azext_portal/vendored_sdks/portal/models/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/models/__init__.py index 84909621e71..1fda759a3e3 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/models/__init__.py +++ b/src/portal/azext_portal/vendored_sdks/portal/models/__init__.py @@ -7,43 +7,72 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import Configuration + from ._models_py3 import ConfigurationList from ._models_py3 import Dashboard from ._models_py3 import DashboardLens from ._models_py3 import DashboardListResult + from ._models_py3 import DashboardPartMetadata 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 ErrorResponse + from ._models_py3 import MarkdownPartMetadata + from ._models_py3 import MarkdownPartMetadataSettings + from ._models_py3 import MarkdownPartMetadataSettingsContent + from ._models_py3 import MarkdownPartMetadataSettingsContentSettings from ._models_py3 import PatchableDashboard + from ._models_py3 import ProxyResource + from ._models_py3 import Resource from ._models_py3 import ResourceProviderOperation from ._models_py3 import ResourceProviderOperationDisplay from ._models_py3 import ResourceProviderOperationList except (SyntaxError, ImportError): + from ._models import Configuration # type: ignore + from ._models import ConfigurationList # type: ignore from ._models import Dashboard # type: ignore from ._models import DashboardLens # type: ignore from ._models import DashboardListResult # type: ignore + from ._models import DashboardPartMetadata # 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 ErrorResponse # type: ignore + from ._models import MarkdownPartMetadata # type: ignore + from ._models import MarkdownPartMetadataSettings # type: ignore + from ._models import MarkdownPartMetadataSettingsContent # type: ignore + from ._models import MarkdownPartMetadataSettingsContentSettings # type: ignore from ._models import PatchableDashboard # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import Resource # type: ignore from ._models import ResourceProviderOperation # type: ignore from ._models import ResourceProviderOperationDisplay # type: ignore from ._models import ResourceProviderOperationList # type: ignore +from ._portal_enums import ( + ConfigurationName, +) + __all__ = [ + 'Configuration', + 'ConfigurationList', 'Dashboard', 'DashboardLens', 'DashboardListResult', + 'DashboardPartMetadata', 'DashboardParts', 'DashboardPartsPosition', - 'DashboardProperties', 'ErrorDefinition', - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', + 'MarkdownPartMetadata', + 'MarkdownPartMetadataSettings', + 'MarkdownPartMetadataSettingsContent', + 'MarkdownPartMetadataSettingsContentSettings', 'PatchableDashboard', + 'ProxyResource', + 'Resource', 'ResourceProviderOperation', 'ResourceProviderOperationDisplay', 'ResourceProviderOperationList', + 'ConfigurationName', ] diff --git a/src/portal/azext_portal/vendored_sdks/portal/models/_models.py b/src/portal/azext_portal/vendored_sdks/portal/models/_models.py index bc70d849819..f678d2c9586 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/models/_models.py +++ b/src/portal/azext_portal/vendored_sdks/portal/models/_models.py @@ -10,6 +10,105 @@ import msrest.serialization +class Resource(msrest.serialization.Model): + """Resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Configuration(Resource): + """Tenant configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :param enforce_private_markdown_storage: When flag is set to true Markdown tile will require + external storage configuration (URI). The inline content configuration will be prohibited. + :type enforce_private_markdown_storage: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'enforce_private_markdown_storage': {'key': 'properties.enforcePrivateMarkdownStorage', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(Configuration, self).__init__(**kwargs) + self.enforce_private_markdown_storage = kwargs.get('enforce_private_markdown_storage', None) + + +class ConfigurationList(msrest.serialization.Model): + """List of tenant configurations. + + :param value: The array of custom resource provider manifests. + :type value: list[~portal.models.Configuration] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Configuration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ConfigurationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class Dashboard(msrest.serialization.Model): """The shared dashboard resource definition. @@ -28,7 +127,7 @@ class Dashboard(msrest.serialization.Model): :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] + :type lenses: list[object] :param metadata: The dashboard metadata. :type metadata: dict[str, object] """ @@ -46,7 +145,7 @@ class Dashboard(msrest.serialization.Model): 'type': {'key': 'type', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'lenses': {'key': 'properties.lenses', 'type': '[object]'}, 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, } @@ -58,7 +157,7 @@ def __init__( self.id = None self.name = None self.type = None - self.location = kwargs.get('location', None) + self.location = kwargs['location'] self.tags = kwargs.get('tags', None) self.lenses = kwargs.get('lenses', None) self.metadata = kwargs.get('metadata', None) @@ -72,7 +171,7 @@ class DashboardLens(msrest.serialization.Model): :param order: Required. The lens order. :type order: int :param parts: Required. The dashboard parts. - :type parts: dict[str, ~portal.models.DashboardParts] + :type parts: list[object] :param metadata: The dashboard len's metadata. :type metadata: dict[str, object] """ @@ -84,7 +183,7 @@ class DashboardLens(msrest.serialization.Model): _attribute_map = { 'order': {'key': 'order', 'type': 'int'}, - 'parts': {'key': 'parts', 'type': '{DashboardParts}'}, + 'parts': {'key': 'parts', 'type': '[object]'}, 'metadata': {'key': 'metadata', 'type': '{object}'}, } @@ -93,8 +192,8 @@ def __init__( **kwargs ): super(DashboardLens, self).__init__(**kwargs) - self.order = kwargs.get('order', None) - self.parts = kwargs.get('parts', None) + self.order = kwargs['order'] + self.parts = kwargs['parts'] self.metadata = kwargs.get('metadata', None) @@ -121,6 +220,38 @@ def __init__( self.next_link = kwargs.get('next_link', None) +class DashboardPartMetadata(msrest.serialization.Model): + """A dashboard part metadata. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: MarkdownPartMetadata. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The type of dashboard part.Constant filled by server. + :type type: str + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'Extension/HubsExtension/PartType/MarkdownPart': 'MarkdownPartMetadata'} + } + + def __init__( + self, + **kwargs + ): + super(DashboardPartMetadata, self).__init__(**kwargs) + self.type = None # type: Optional[str] + + class DashboardParts(msrest.serialization.Model): """A dashboard part. @@ -129,7 +260,7 @@ class DashboardParts(msrest.serialization.Model): :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] + :type metadata: ~portal.models.DashboardPartMetadata """ _validation = { @@ -138,7 +269,7 @@ class DashboardParts(msrest.serialization.Model): _attribute_map = { 'position': {'key': 'position', 'type': 'DashboardPartsPosition'}, - 'metadata': {'key': 'metadata', 'type': '{object}'}, + 'metadata': {'key': 'metadata', 'type': 'DashboardPartMetadata'}, } def __init__( @@ -146,7 +277,7 @@ def __init__( **kwargs ): super(DashboardParts, self).__init__(**kwargs) - self.position = kwargs.get('position', None) + self.position = kwargs['position'] self.metadata = kwargs.get('metadata', None) @@ -187,33 +318,10 @@ def __init__( **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.x = kwargs['x'] + self.y = kwargs['y'] + self.row_span = kwargs['row_span'] + self.col_span = kwargs['col_span'] self.metadata = kwargs.get('metadata', None) @@ -252,49 +360,129 @@ def __init__( self.details = None -class ErrorResponseException(HttpResponseError): - """Server responded with exception of type: 'ErrorResponse'. +class ErrorResponse(msrest.serialization.Model): + """Error response. - :param response: Server response to be deserialized. - :param error_model: A deserialized model of the response body as model. + :param error: The error details. + :type error: ~portal.models.ErrorDefinition """ - def __init__(self, response, error_model): - self.error = error_model - super(ErrorResponseException, self).__init__(response=response, error_model=error_model) + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } - @classmethod - def from_response(cls, response, deserialize): - """Deserialize this response as this exception, or a subclass of this exception. + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) - :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 MarkdownPartMetadata(DashboardPartMetadata): + """Markdown part metadata. -class ErrorResponse(msrest.serialization.Model): - """Error response. + All required parameters must be populated in order to send to Azure. - :param error: Error definition. - :type error: ~portal.models.ErrorDefinition + :param type: Required. The type of dashboard part.Constant filled by server. + :type type: str + :param inputs: Input to dashboard part. + :type inputs: list[object] + :param settings: Markdown part settings. + :type settings: ~portal.models.MarkdownPartMetadataSettings """ - _EXCEPTION_TYPE = ErrorResponseException + + _validation = { + 'type': {'required': True}, + } _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + 'type': {'key': 'type', 'type': 'str'}, + 'inputs': {'key': 'inputs', 'type': '[object]'}, + 'settings': {'key': 'settings', 'type': 'MarkdownPartMetadataSettings'}, } def __init__( self, **kwargs ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) + super(MarkdownPartMetadata, self).__init__(**kwargs) + self.type = 'Extension/HubsExtension/PartType/MarkdownPart' # type: str + self.inputs = kwargs.get('inputs', None) + self.settings = kwargs.get('settings', None) + + +class MarkdownPartMetadataSettings(msrest.serialization.Model): + """Markdown part settings. + + :param content: The content of markdown part. + :type content: ~portal.models.MarkdownPartMetadataSettingsContent + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'MarkdownPartMetadataSettingsContent'}, + } + + def __init__( + self, + **kwargs + ): + super(MarkdownPartMetadataSettings, self).__init__(**kwargs) + self.content = kwargs.get('content', None) + + +class MarkdownPartMetadataSettingsContent(msrest.serialization.Model): + """The content of markdown part. + + :param settings: The setting of the content of markdown part. + :type settings: ~portal.models.MarkdownPartMetadataSettingsContentSettings + """ + + _attribute_map = { + 'settings': {'key': 'settings', 'type': 'MarkdownPartMetadataSettingsContentSettings'}, + } + + def __init__( + self, + **kwargs + ): + super(MarkdownPartMetadataSettingsContent, self).__init__(**kwargs) + self.settings = kwargs.get('settings', None) + + +class MarkdownPartMetadataSettingsContentSettings(msrest.serialization.Model): + """The setting of the content of markdown part. + + :param content: The content of the markdown part. + :type content: str + :param title: The title of the markdown part. + :type title: str + :param subtitle: The subtitle of the markdown part. + :type subtitle: str + :param markdown_source: The source of the content of the markdown part. + :type markdown_source: object + :param markdown_uri: The uri of markdown content. + :type markdown_uri: str + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'subtitle': {'key': 'subtitle', 'type': 'str'}, + 'markdown_source': {'key': 'markdownSource', 'type': 'object'}, + 'markdown_uri': {'key': 'markdownUri', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(MarkdownPartMetadataSettingsContentSettings, self).__init__(**kwargs) + self.content = kwargs.get('content', None) + self.title = kwargs.get('title', None) + self.subtitle = kwargs.get('subtitle', None) + self.markdown_source = kwargs.get('markdown_source', None) + self.markdown_uri = kwargs.get('markdown_uri', None) class PatchableDashboard(msrest.serialization.Model): @@ -303,14 +491,14 @@ class PatchableDashboard(msrest.serialization.Model): :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] + :type lenses: list[object] :param metadata: The dashboard metadata. :type metadata: dict[str, object] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'lenses': {'key': 'properties.lenses', 'type': '[object]'}, 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, } @@ -324,6 +512,40 @@ def __init__( self.metadata = kwargs.get('metadata', None) +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + class ResourceProviderOperation(msrest.serialization.Model): """Supported operations of this resource provider. 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 index 47507e86168..0cd8b23c23c 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py +++ b/src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py @@ -12,6 +12,110 @@ import msrest.serialization +class Resource(msrest.serialization.Model): + """Resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Configuration(Resource): + """Tenant configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + :param enforce_private_markdown_storage: When flag is set to true Markdown tile will require + external storage configuration (URI). The inline content configuration will be prohibited. + :type enforce_private_markdown_storage: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'enforce_private_markdown_storage': {'key': 'properties.enforcePrivateMarkdownStorage', 'type': 'bool'}, + } + + def __init__( + self, + *, + enforce_private_markdown_storage: Optional[bool] = None, + **kwargs + ): + super(Configuration, self).__init__(**kwargs) + self.enforce_private_markdown_storage = enforce_private_markdown_storage + + +class ConfigurationList(msrest.serialization.Model): + """List of tenant configurations. + + :param value: The array of custom resource provider manifests. + :type value: list[~portal.models.Configuration] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Configuration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Configuration"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ConfigurationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class Dashboard(msrest.serialization.Model): """The shared dashboard resource definition. @@ -30,7 +134,7 @@ class Dashboard(msrest.serialization.Model): :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] + :type lenses: list[object] :param metadata: The dashboard metadata. :type metadata: dict[str, object] """ @@ -48,7 +152,7 @@ class Dashboard(msrest.serialization.Model): 'type': {'key': 'type', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'lenses': {'key': 'properties.lenses', 'type': '[object]'}, 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, } @@ -57,7 +161,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - lenses: Optional[Dict[str, "DashboardLens"]] = None, + lenses: Optional[List[object]] = None, metadata: Optional[Dict[str, object]] = None, **kwargs ): @@ -79,7 +183,7 @@ class DashboardLens(msrest.serialization.Model): :param order: Required. The lens order. :type order: int :param parts: Required. The dashboard parts. - :type parts: dict[str, ~portal.models.DashboardParts] + :type parts: list[object] :param metadata: The dashboard len's metadata. :type metadata: dict[str, object] """ @@ -91,7 +195,7 @@ class DashboardLens(msrest.serialization.Model): _attribute_map = { 'order': {'key': 'order', 'type': 'int'}, - 'parts': {'key': 'parts', 'type': '{DashboardParts}'}, + 'parts': {'key': 'parts', 'type': '[object]'}, 'metadata': {'key': 'metadata', 'type': '{object}'}, } @@ -99,7 +203,7 @@ def __init__( self, *, order: int, - parts: Dict[str, "DashboardParts"], + parts: List[object], metadata: Optional[Dict[str, object]] = None, **kwargs ): @@ -135,6 +239,38 @@ def __init__( self.next_link = next_link +class DashboardPartMetadata(msrest.serialization.Model): + """A dashboard part metadata. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: MarkdownPartMetadata. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The type of dashboard part.Constant filled by server. + :type type: str + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'Extension/HubsExtension/PartType/MarkdownPart': 'MarkdownPartMetadata'} + } + + def __init__( + self, + **kwargs + ): + super(DashboardPartMetadata, self).__init__(**kwargs) + self.type = None # type: Optional[str] + + class DashboardParts(msrest.serialization.Model): """A dashboard part. @@ -143,7 +279,7 @@ class DashboardParts(msrest.serialization.Model): :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] + :type metadata: ~portal.models.DashboardPartMetadata """ _validation = { @@ -152,14 +288,14 @@ class DashboardParts(msrest.serialization.Model): _attribute_map = { 'position': {'key': 'position', 'type': 'DashboardPartsPosition'}, - 'metadata': {'key': 'metadata', 'type': '{object}'}, + 'metadata': {'key': 'metadata', 'type': 'DashboardPartMetadata'}, } def __init__( self, *, position: "DashboardPartsPosition", - metadata: Optional[Dict[str, object]] = None, + metadata: Optional["DashboardPartMetadata"] = None, **kwargs ): super(DashboardParts, self).__init__(**kwargs) @@ -217,32 +353,6 @@ def __init__( 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. @@ -278,38 +388,12 @@ def __init__( 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. + :param error: The error details. :type error: ~portal.models.ErrorDefinition """ - _EXCEPTION_TYPE = ErrorResponseException _attribute_map = { 'error': {'key': 'error', 'type': 'ErrorDefinition'}, @@ -325,20 +409,139 @@ def __init__( self.error = error +class MarkdownPartMetadata(DashboardPartMetadata): + """Markdown part metadata. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. The type of dashboard part.Constant filled by server. + :type type: str + :param inputs: Input to dashboard part. + :type inputs: list[object] + :param settings: Markdown part settings. + :type settings: ~portal.models.MarkdownPartMetadataSettings + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'inputs': {'key': 'inputs', 'type': '[object]'}, + 'settings': {'key': 'settings', 'type': 'MarkdownPartMetadataSettings'}, + } + + def __init__( + self, + *, + inputs: Optional[List[object]] = None, + settings: Optional["MarkdownPartMetadataSettings"] = None, + **kwargs + ): + super(MarkdownPartMetadata, self).__init__(**kwargs) + self.type = 'Extension/HubsExtension/PartType/MarkdownPart' # type: str + self.inputs = inputs + self.settings = settings + + +class MarkdownPartMetadataSettings(msrest.serialization.Model): + """Markdown part settings. + + :param content: The content of markdown part. + :type content: ~portal.models.MarkdownPartMetadataSettingsContent + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'MarkdownPartMetadataSettingsContent'}, + } + + def __init__( + self, + *, + content: Optional["MarkdownPartMetadataSettingsContent"] = None, + **kwargs + ): + super(MarkdownPartMetadataSettings, self).__init__(**kwargs) + self.content = content + + +class MarkdownPartMetadataSettingsContent(msrest.serialization.Model): + """The content of markdown part. + + :param settings: The setting of the content of markdown part. + :type settings: ~portal.models.MarkdownPartMetadataSettingsContentSettings + """ + + _attribute_map = { + 'settings': {'key': 'settings', 'type': 'MarkdownPartMetadataSettingsContentSettings'}, + } + + def __init__( + self, + *, + settings: Optional["MarkdownPartMetadataSettingsContentSettings"] = None, + **kwargs + ): + super(MarkdownPartMetadataSettingsContent, self).__init__(**kwargs) + self.settings = settings + + +class MarkdownPartMetadataSettingsContentSettings(msrest.serialization.Model): + """The setting of the content of markdown part. + + :param content: The content of the markdown part. + :type content: str + :param title: The title of the markdown part. + :type title: str + :param subtitle: The subtitle of the markdown part. + :type subtitle: str + :param markdown_source: The source of the content of the markdown part. + :type markdown_source: object + :param markdown_uri: The uri of markdown content. + :type markdown_uri: str + """ + + _attribute_map = { + 'content': {'key': 'content', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'subtitle': {'key': 'subtitle', 'type': 'str'}, + 'markdown_source': {'key': 'markdownSource', 'type': 'object'}, + 'markdown_uri': {'key': 'markdownUri', 'type': 'str'}, + } + + def __init__( + self, + *, + content: Optional[str] = None, + title: Optional[str] = None, + subtitle: Optional[str] = None, + markdown_source: Optional[object] = None, + markdown_uri: Optional[str] = None, + **kwargs + ): + super(MarkdownPartMetadataSettingsContentSettings, self).__init__(**kwargs) + self.content = content + self.title = title + self.subtitle = subtitle + self.markdown_source = markdown_source + self.markdown_uri = markdown_uri + + 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] + :type lenses: list[object] :param metadata: The dashboard metadata. :type metadata: dict[str, object] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'lenses': {'key': 'properties.lenses', 'type': '[object]'}, 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, } @@ -346,7 +549,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - lenses: Optional[Dict[str, "DashboardLens"]] = None, + lenses: Optional[List[object]] = None, metadata: Optional[Dict[str, object]] = None, **kwargs ): @@ -356,6 +559,40 @@ def __init__( self.metadata = metadata +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or + Microsoft.Storage/storageAccounts. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + class ResourceProviderOperation(msrest.serialization.Model): """Supported operations of this resource provider. diff --git a/src/portal/azext_portal/vendored_sdks/portal/models/_portal_enums.py b/src/portal/azext_portal/vendored_sdks/portal/models/_portal_enums.py new file mode 100644 index 00000000000..b5b2f04d97b --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/models/_portal_enums.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ConfigurationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + DEFAULT = "default" diff --git a/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py index 9bffae3d64c..97c28d22bd3 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py @@ -8,8 +8,10 @@ from ._operation_operations import OperationOperations from ._dashboard_operations import DashboardOperations +from ._tenant_configuration_operations import TenantConfigurationOperations __all__ = [ 'OperationOperations', 'DashboardOperations', + 'TenantConfigurationOperations', ] 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 index 403f882f8a6..48aab8ef3ab 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py @@ -5,25 +5,29 @@ # 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 +from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import map_error +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models -T = TypeVar('T') -ClsType = Optional[Callable[[ - PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class 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. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~portal.models @@ -47,7 +51,7 @@ def create_or_update( dashboard_name, # type: str location, # type: str tags=None, # type: Optional[Dict[str, str]] - lenses=None, # type: Optional[Dict[str, "DashboardLens"]] + lenses=None, # type: Optional[List[object]] metadata=None, # type: Optional[Dict[str, object]] **kwargs # type: Any ): @@ -63,23 +67,24 @@ def create_or_update( :param tags: Resource tags. :type tags: dict[str, str] :param lenses: The dashboard lenses. - :type lenses: dict[str, ~portal.models.DashboardLens] + :type lenses: list[object] :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: + :return: Dashboard, or the result of cls(response) + :rtype: ~portal.models.Dashboard + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] - error_map = kwargs.pop('error_map', {}) + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) - dashboard = models.Dashboard( - location=location, tags=tags, lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" + _dashboard = models.Dashboard(location=location, tags=tags, lenses=lenses, metadata=metadata) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -88,32 +93,27 @@ def create_or_update( 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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' - # Construct body - body_content = self._serialize.body(dashboard, 'Dashboard') + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_dashboard, 'Dashboard') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - # 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) + 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) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Dashboard', pipeline_response) @@ -124,8 +124,7 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore def delete( self, @@ -141,16 +140,17 @@ def delete( :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) + :return: None, or the result of cls(response) :rtype: None - :raises: ~portal.models.ErrorResponseException: + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -159,30 +159,25 @@ def delete( 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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) + 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) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore def get( self, @@ -198,16 +193,17 @@ def get( :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) + :return: Dashboard, or the result of cls(response) :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -216,25 +212,21 @@ def get( 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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' - # Construct and send request request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) + 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) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Dashboard', pipeline_response) @@ -242,14 +234,14 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore def update( self, resource_group_name, # type: str dashboard_name, # type: str - lenses=None, # type: Optional[Dict[str, "DashboardLens"]] + tags=None, # type: Optional[Dict[str, str]] + lenses=None, # type: Optional[List[object]] metadata=None, # type: Optional[Dict[str, object]] **kwargs # type: Any ): @@ -260,23 +252,27 @@ def update( :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] + :type lenses: list[object] :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) + :return: Dashboard, or the result of cls(response) :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: + :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] - error_map = kwargs.pop('error_map', {}) + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) - dashboard = models.PatchableDashboard(lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" + _dashboard = models.PatchableDashboard(tags=tags, lenses=lenses, metadata=metadata) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), @@ -285,30 +281,26 @@ def update( 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') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' - # Construct body - body_content = self._serialize.body(dashboard, 'PatchableDashboard') + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_dashboard, 'PatchableDashboard') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - # 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) + 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) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Dashboard', pipeline_response) @@ -316,225 +308,138 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore def list_by_resource_group( self, resource_group_name, # type: str **kwargs # type: Any ): - # type: (...) -> "models.DashboardListResult" + # type: (...) -> Iterable["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: + :return: An iterator like instance of either DashboardListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~portal.models.DashboardListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop( - 'cls', None) # type: ClsType["models.DashboardListResult"] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.DashboardListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['url'] + url = self.list_by_resource_group.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) 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) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): - deserialized = self._deserialize( - 'DashboardListResult', 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) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) + 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) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} # type: ignore def list_by_subscription( self, **kwargs # type: Any ): - # type: (...) -> "models.DashboardListResult" + # type: (...) -> Iterable["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: + :return: An iterator like instance of either DashboardListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~portal.models.DashboardListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop( - 'cls', None) # type: ClsType["models.DashboardListResult"] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.DashboardListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + if not next_link: # Construct URL - url = self.list_by_subscription.metadata['url'] + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) 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) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): - deserialized = self._deserialize( - 'DashboardListResult', 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) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) + 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) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = { - 'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} - - def dashboard_import( - self, - resource_group_name, # type: str - dashboard_name, # type: str - dashboard, # type: "models.Dashboard" - **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 dashboard: The parameters required to create or update a dashboard. - :type dashboard: ~portal.models.Dashboard - :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', {}) - 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}'} + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} # type: ignore 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 index 59145766d1b..3b68c7e76f1 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py @@ -5,23 +5,29 @@ # 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 +from typing import TYPE_CHECKING import warnings -from azure.core.exceptions import map_error +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class OperationOperations(object): """OperationOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~portal.models @@ -43,35 +49,36 @@ def list( self, **kwargs # type: Any ): - # type: (...) -> "models.ResourceProviderOperationList" + # type: (...) -> Iterable["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: + :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~portal.models.ResourceProviderOperationList] + :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None ) # type: ClsType["models.ResourceProviderOperationList"] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceProviderOperationList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) 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) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -79,7 +86,7 @@ def extract_data(pipeline_response): list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) - return deserialized.next_link, iter(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) @@ -88,12 +95,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise models.ErrorResponseException.from_response(response, self._deserialize) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Portal/operations'} + list.metadata = {'url': '/providers/Microsoft.Portal/operations'} # type: ignore diff --git a/src/portal/azext_portal/vendored_sdks/portal/operations/_tenant_configuration_operations.py b/src/portal/azext_portal/vendored_sdks/portal/operations/_tenant_configuration_operations.py new file mode 100644 index 00000000000..7eee5d82d0d --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_tenant_configuration_operations.py @@ -0,0 +1,259 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TenantConfigurationOperations(object): + """TenantConfigurationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~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.ConfigurationList" + """Gets list of the tenant configurations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConfigurationList, or the result of cls(response) + :rtype: ~portal.models.ConfigurationList + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationList"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConfigurationList', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations'} # type: ignore + + def get( + self, + configuration_name, # type: Union[str, "models.ConfigurationName"] + **kwargs # type: Any + ): + # type: (...) -> "models.Configuration" + """Gets the tenant configuration. + + :param configuration_name: The configuration name. Value must be 'default'. + :type configuration_name: str or ~portal.models.ConfigurationName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Configuration, or the result of cls(response) + :rtype: ~portal.models.Configuration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Configuration"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Configuration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations/{configurationName}'} # type: ignore + + def create( + self, + configuration_name, # type: Union[str, "models.ConfigurationName"] + enforce_private_markdown_storage=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> "models.Configuration" + """Create the tenant configuration. If configuration already exists - update it. User has to be a + Tenant Admin for this operation. + + :param configuration_name: The configuration name. Value must be 'default'. + :type configuration_name: str or ~portal.models.ConfigurationName + :param enforce_private_markdown_storage: When flag is set to true Markdown tile will require + external storage configuration (URI). The inline content configuration will be prohibited. + :type enforce_private_markdown_storage: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Configuration, or the result of cls(response) + :rtype: ~portal.models.Configuration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Configuration"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + _tenant_configuration = models.Configuration(enforce_private_markdown_storage=enforce_private_markdown_storage) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_tenant_configuration, 'Configuration') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Configuration', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Configuration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations/{configurationName}'} # type: ignore + + def delete( + self, + configuration_name, # type: Union[str, "models.ConfigurationName"] + **kwargs # type: Any + ): + # type: (...) -> None + """Delete the tenant configuration. User has to be a Tenant Admin for this operation. + + :param configuration_name: The configuration name. Value must be 'default'. + :type configuration_name: str or ~portal.models.ConfigurationName + :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: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + 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) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations/{configurationName}'} # type: ignore diff --git a/src/portal/azext_portal/vendored_sdks/portal/py.typed b/src/portal/azext_portal/vendored_sdks/portal/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/portal/report.md b/src/portal/report.md new file mode 100644 index 00000000000..35efc392186 --- /dev/null +++ b/src/portal/report.md @@ -0,0 +1,181 @@ +# Azure CLI Module Creation Report + +### portal dashboard create + +create a portal dashboard. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal dashboard|Dashboards| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|create|CreateOrUpdate#Create| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| +|**--dashboard-name**|string|The name of the dashboard.|dashboard_name|dashboardName| +|**--location**|string|Resource location|location|location| +|**--tags**|dictionary|Resource tags|tags|tags| +|**--lenses**|array|The dashboard lenses.|lenses|lenses| +|**--metadata**|dictionary|The dashboard metadata.|metadata|metadata| + +### portal dashboard delete + +delete a portal dashboard. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal dashboard|Dashboards| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|delete|Delete| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| +|**--dashboard-name**|string|The name of the dashboard.|dashboard_name|dashboardName| + +### portal dashboard list + +list a portal dashboard. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal dashboard|Dashboards| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|ListByResourceGroup| +|list|ListBySubscription| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| + +### portal dashboard show + +show a portal dashboard. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal dashboard|Dashboards| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|show|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| +|**--dashboard-name**|string|The name of the dashboard.|dashboard_name|dashboardName| + +### portal dashboard update + +update a portal dashboard. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal dashboard|Dashboards| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|update|Update| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| +|**--dashboard-name**|string|The name of the dashboard.|dashboard_name|dashboardName| +|**--tags**|dictionary|Resource tags|tags|tags| +|**--lenses**|array|The dashboard lenses.|lenses|lenses| +|**--metadata**|dictionary|The dashboard metadata.|metadata|metadata| + +### portal tenant-configuration create + +create a portal tenant-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal tenant-configuration|TenantConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|create|Create| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--enforce-private-markdown-storage**|boolean|When flag is set to true Markdown tile will require external storage configuration (URI). The inline content configuration will be prohibited.|enforce_private_markdown_storage|enforcePrivateMarkdownStorage| + +### portal tenant-configuration delete + +delete a portal tenant-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal tenant-configuration|TenantConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|delete|Delete| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| + +### portal tenant-configuration list + +list a portal tenant-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal tenant-configuration|TenantConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|list|List| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| + +### portal tenant-configuration show + +show a portal tenant-configuration. + +#### Command group +|Name (az)|Swagger name| +|---------|------------| +|portal tenant-configuration|TenantConfigurations| + +#### Methods +|Name (az)|Swagger name| +|---------|------------| +|show|Get| + +#### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| diff --git a/src/portal/setup.cfg b/src/portal/setup.cfg index e69de29bb2d..2fdd96e5d39 100644 --- a/src/portal/setup.cfg +++ b/src/portal/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/portal/setup.py b/src/portal/setup.py index 32e97984c49..da4d7c1df5c 100644 --- a/src/portal/setup.py +++ b/src/portal/setup.py @@ -8,15 +8,13 @@ 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.1' +VERSION = '0.1.0' +try: + from azext_portal.manual.version import VERSION +except ImportError: + pass # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -32,8 +30,11 @@ 'License :: OSI Approved :: MIT License', ] -# TODO: Add any additional SDK dependencies here DEPENDENCIES = [] +try: + from .manual.dependency import DEPENDENCIES +except ImportError: + pass with open('README.md', 'r', encoding='utf-8') as f: README = f.read() @@ -44,11 +45,9 @@ 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', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/portal', long_description=README + '\n\n' + HISTORY, license='MIT', classifiers=CLASSIFIERS,