From 0fa1718a8542133541a10242af8e115034dafecc Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 21 Jun 2021 15:10:27 +0000 Subject: [PATCH] CodeGen from PR 14908 in Azure/azure-rest-api-specs Merge 2f8a27c7263bdfa50b39cc00dbc07312e8f4e2d9 into c7616be749e60dc269e2bb50800f06dbca065098 --- 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 | 28 +- src/portal/azext_portal/generated/_help.py | 96 +++- src/portal/azext_portal/generated/_params.py | 78 +-- .../azext_portal/generated/_validators.py | 9 + src/portal/azext_portal/generated/action.py | 32 +- src/portal/azext_portal/generated/commands.py | 46 +- src/portal/azext_portal/generated/custom.py | 146 +++-- .../operations_async => manual}/__init__.py | 15 +- src/portal/azext_portal/tests/__init__.py | 116 ++++ .../azext_portal/tests/latest/__init__.py | 14 +- .../azext_portal/tests/latest/dashboard.json | 60 -- .../tests/latest/example_steps.py | 130 +++++ .../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 | 189 +++--- .../azext_portal/vendored_sdks/__init__.py | 2 +- .../vendored_sdks/portal/__init__.py | 6 + .../vendored_sdks/portal/_configuration.py | 22 +- .../vendored_sdks/portal/_portal.py | 40 +- .../vendored_sdks/portal/aio/__init__.py | 2 +- ...nfiguration_async.py => _configuration.py} | 22 +- .../aio/{_portal_async.py => _portal.py} | 42 +- .../portal/aio/operations/__init__.py | 19 + .../_dashboards_operations.py} | 301 +++++----- ...ant_configuration_violations_operations.py | 105 ++++ .../_operations.py} | 61 +- .../_tenant_configurations_operations.py | 279 +++++++++ .../vendored_sdks/portal/models/__init__.py | 47 +- .../vendored_sdks/portal/models/_models.py | 423 +++++++++++--- .../portal/models/_models_py3.py | 444 +++++++++++--- .../portal/models/_portal_enums.py | 31 + .../portal/operations/__init__.py | 12 +- .../operations/_dashboard_operations.py | 540 ------------------ .../operations/_dashboards_operations.py | 447 +++++++++++++++ ...ant_configuration_violations_operations.py | 110 ++++ ...operation_operations.py => _operations.py} | 69 ++- .../_tenant_configurations_operations.py | 287 ++++++++++ .../vendored_sdks/portal/py.typed | 1 + src/portal/report.md | 171 ++++++ src/portal/setup.cfg | 1 + src/portal/setup.py | 19 +- 49 files changed, 3232 insertions(+), 1490 deletions(-) delete mode 100644 src/portal/azext_portal/commands.py create mode 100644 src/portal/azext_portal/generated/_validators.py rename src/portal/azext_portal/{vendored_sdks/portal/aio/operations_async => manual}/__init__.py (63%) create mode 100644 src/portal/azext_portal/tests/__init__.py delete mode 100644 src/portal/azext_portal/tests/latest/dashboard.json create mode 100644 src/portal/azext_portal/tests/latest/example_steps.py 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 rename src/portal/azext_portal/vendored_sdks/portal/aio/{_configuration_async.py => _configuration.py} (75%) rename src/portal/azext_portal/vendored_sdks/portal/aio/{_portal_async.py => _portal.py} (51%) create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/operations/__init__.py rename src/portal/azext_portal/vendored_sdks/portal/aio/{operations_async/_dashboard_operations_async.py => operations/_dashboards_operations.py} (56%) create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/operations/_list_tenant_configuration_violations_operations.py rename src/portal/azext_portal/vendored_sdks/portal/aio/{operations_async/_operation_operations_async.py => operations/_operations.py} (55%) create mode 100644 src/portal/azext_portal/vendored_sdks/portal/aio/operations/_tenant_configurations_operations.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/models/_portal_enums.py delete mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/_dashboards_operations.py create mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/_list_tenant_configuration_violations_operations.py rename src/portal/azext_portal/vendored_sdks/portal/operations/{_operation_operations.py => _operations.py} (51%) create mode 100644 src/portal/azext_portal/vendored_sdks/portal/operations/_tenant_configurations_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..cfc30c747c7 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.15.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..bbc4907cb53 100644 --- a/src/portal/azext_portal/generated/_client_factory.py +++ b/src/portal/azext_portal/generated/_client_factory.py @@ -1,14 +1,28 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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) + from azext_portal.vendored_sdks.portal import 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).dashboards + + +def cf_tenant_configuration(cli_ctx, *_): + return cf_portal_cl(cli_ctx).tenant_configurations + + +def cf_list_tenant_configuration_violation(cli_ctx, *_): + return cf_portal_cl(cli_ctx).list_tenant_configuration_violations diff --git a/src/portal/azext_portal/generated/_help.py b/src/portal/azext_portal/generated/_help.py index e702c567cbc..8d7b3e39f83 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,25 @@ helps['portal dashboard'] = """ type: group - short-summary: Manage portal dashboards + short-summary: Manage dashboard with portal """ 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 resource group. And 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 + - name: List all custom resource providers on the 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 +41,87 @@ helps['portal dashboard create'] = """ type: command - short-summary: Creates or updates a dashboard. + short-summary: "Create 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: Manage tenant configuration with portal +""" + +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: "Delete the tenant configuration. User has to be a Tenant Admin for this operation." + examples: + - name: Delete Tenant configuration + text: |- + az portal tenant-configuration delete +""" + +helps['portal list-tenant-configuration-violation'] = """ + type: group + short-summary: Manage list tenant configuration violation with portal +""" + +helps['portal list-tenant-configuration-violation list'] = """ type: command - short-summary: Imports a dashboard from a JSON file. + short-summary: "Gets list of items that violate tenant's configuration." examples: - - name: Import a Dashboard + - name: Get list of of items that violate tenant's configuration text: |- - az portal dashboard import --name "testDashboard" --resource-group "testRG" \\ - --input-path "/src/json/dashboard.json" + az portal list-tenant-configuration-violation list """ diff --git a/src/portal/azext_portal/generated/_params.py b/src/portal/azext_portal/generated/_params.py index e036901b70c..e120f246b46 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('location', arg_type=get_location_type(self.cli_ctx), + 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), required=False, 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..1a4ba48cff5 100644 --- a/src/portal/azext_portal/generated/commands.py +++ b/src/portal/azext_portal/generated/commands.py @@ -1,25 +1,51 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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.{}', + operations_tmpl='azext_portal.vendored_sdks.portal.operations._dashboards_operations#DashboardsOperations.{}', client_factory=cf_dashboard) with self.command_group('portal dashboard', portal_dashboard, client_factory=cf_dashboard) as g: g.custom_command('list', 'portal_dashboard_list') g.custom_show_command('show', 'portal_dashboard_show') g.custom_command('create', 'portal_dashboard_create') g.custom_command('update', 'portal_dashboard_update') - g.custom_command('delete', 'portal_dashboard_delete', - 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_configurations_operations#TenantConfigura' + 'tionsOperations.{}', + client_factory=cf_tenant_configuration) + with self.command_group('portal tenant-configuration', portal_tenant_configuration, + client_factory=cf_tenant_configuration) 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) + + from azext_portal.generated._client_factory import cf_list_tenant_configuration_violation + portal_list_tenant_configuration_violation = CliCommandType( + operations_tmpl='azext_portal.vendored_sdks.portal.operations._list_tenant_configuration_violations_operations#' + 'ListTenantConfigurationViolationsOperations.{}', + client_factory=cf_list_tenant_configuration_violation) + with self.command_group('portal list-tenant-configuration-violation', portal_list_tenant_configuration_violation, + client_factory=cf_list_tenant_configuration_violation) as g: + g.custom_command('list', 'portal_list_tenant_configuration_violation_list') + + with self.command_group('portal', is_experimental=True): + pass diff --git a/src/portal/azext_portal/generated/custom.py b/src/portal/azext_portal/generated/custom.py index 1d4557ac4ab..ff36dcd641d 100644 --- a/src/portal/azext_portal/generated/custom.py +++ b/src/portal/azext_portal/generated/custom.py @@ -1,100 +1,86 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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): + dashboard = {} + dashboard['location'] = location + dashboard['tags'] = tags + dashboard['lenses'] = lenses + dashboard['metadata'] = metadata + return client.create_or_update(resource_group_name=resource_group_name, + dashboard_name=dashboard_name, + dashboard=dashboard) + + +def portal_dashboard_update(client, + resource_group_name, + dashboard_name, + tags=None, + lenses=None, + metadata=None): + dashboard = {} + dashboard['tags'] = tags + dashboard['lenses'] = lenses + dashboard['metadata'] = metadata + return client.update(resource_group_name=resource_group_name, + dashboard_name=dashboard_name, + dashboard=dashboard) + + +def portal_dashboard_delete(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): + 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): + tenant_configuration = {} + tenant_configuration['enforce_private_markdown_storage'] = enforce_private_markdown_storage + return client.create(tenant_configuration=tenant_configuration) + + +def portal_tenant_configuration_delete(client): + return client.delete() + + +def portal_list_tenant_configuration_violation_list(client): + return client.list() diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/__init__.py b/src/portal/azext_portal/manual/__init__.py similarity index 63% rename from src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/__init__.py rename to src/portal/azext_portal/manual/__init__.py index 1511df6e3b9..c9cfdc73e77 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/__init__.py +++ b/src/portal/azext_portal/manual/__init__.py @@ -1,15 +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. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. # -------------------------------------------------------------------------- -from ._operation_operations_async import OperationOperations -from ._dashboard_operations_async import DashboardOperations - -__all__ = [ - 'OperationOperations', - 'DashboardOperations', -] +__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..70488e93851 --- /dev/null +++ b/src/portal/azext_portal/tests/__init__.py @@ -0,0 +1,116 @@ +# 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).lower() + module_path = __path__[0].lower() + 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) + 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: + use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE") + if use_exception_cache is None or use_exception_cache.lower() != "true": + raise + 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/example_steps.py b/src/portal/azext_portal/tests/latest/example_steps.py new file mode 100644 index 00000000000..f7a68ebe803 --- /dev/null +++ b/src/portal/azext_portal/tests/latest/example_steps.py @@ -0,0 +1,130 @@ +# -------------------------------------------------------------------------- +# 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 .. import try_manual + + +# EXAMPLE: /Dashboards/put/Create or update a Dashboard +@try_manual +def step_dashboard_create(test, rg, checks=None): + if checks is None: + checks = [] + 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=checks) + + +# EXAMPLE: /Dashboards/get/Get a Dashboard +@try_manual +def step_dashboard_show(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal dashboard show ' + '--name "{myDashboard}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Dashboards/get/List all custom resource providers on the resourceGroup +@try_manual +def step_dashboard_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal dashboard list ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Dashboards/get/List all custom resource providers on the subscription +@try_manual +def step_dashboard_list2(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal dashboard list ' + '-g ""', + checks=checks) + + +# EXAMPLE: /Dashboards/patch/Update a Dashboard +@try_manual +def step_dashboard_update(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal dashboard update ' + '--tags aKey="bValue" anotherKey="anotherValue2" ' + '--name "{myDashboard}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /Dashboards/delete/Delete a Dashboard +@try_manual +def step_dashboard_delete(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal dashboard delete -y ' + '--name "{myDashboard}" ' + '--resource-group "{rg}"', + checks=checks) + + +# EXAMPLE: /ListTenantConfigurationViolations/post/Get list of of items that violate tenant's configuration +@try_manual +def step_list_tenant_configuration_violation_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal list-tenant-configuration-violation list', + checks=checks) + + +# EXAMPLE: /TenantConfigurations/put/Create or update Tenant configuration +@try_manual +def step_tenant_configuration_create(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal tenant-configuration create ' + '--enforce-private-markdown-storage true', + checks=checks) + + +# EXAMPLE: /TenantConfigurations/get/Get list of Tenant configurations +@try_manual +def step_tenant_configuration_list(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal tenant-configuration list', + checks=checks) + + +# EXAMPLE: /TenantConfigurations/get/Get Tenant configuration +@try_manual +def step_tenant_configuration_show(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal tenant-configuration show', + checks=checks) + + +# EXAMPLE: /TenantConfigurations/delete/Delete Tenant configuration +@try_manual +def step_tenant_configuration_delete(test, rg, checks=None): + if checks is None: + checks = [] + test.cmd('az portal tenant-configuration delete -y', + checks=checks) + 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..c3bca4986c3 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,112 @@ -# -------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------- # 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 azure.cli.testsdk import ResourceGroupPreparer +from .example_steps import step_dashboard_create +from .example_steps import step_dashboard_show +from .example_steps import step_dashboard_list +from .example_steps import step_dashboard_list2 +from .example_steps import step_dashboard_update +from .example_steps import step_dashboard_delete +from .example_steps import step_list_tenant_configuration_violation_list +from .example_steps import step_tenant_configuration_create +from .example_steps import step_tenant_configuration_list +from .example_steps import step_tenant_configuration_show +from .example_steps import step_tenant_configuration_delete +from .. import ( + try_manual, + raise_if, + calc_coverage +) TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) +# Env setup_scenario +@try_manual +def setup_scenario(test, rg): + pass + + +# Env cleanup_scenario +@try_manual +def cleanup_scenario(test, rg): + pass + + +# Testcase: Scenario +@try_manual +def call_scenario(test, rg): + setup_scenario(test, rg) + step_dashboard_create(test, 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), + ]) + step_dashboard_show(test, 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), + ]) + step_dashboard_list(test, rg, checks=[ + test.check('length(@)', 1), + ]) + step_dashboard_list2(test, rg, checks=[ + test.check('length(@)', 1), + ]) + step_dashboard_update(test, 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), + ]) + step_dashboard_delete(test, rg, checks=[]) + step_list_tenant_configuration_violation_list(test, rg, checks=[]) + step_tenant_configuration_create(test, rg, checks=[]) + step_tenant_configuration_list(test, rg, checks=[]) + step_tenant_configuration_show(test, rg, checks=[]) + step_tenant_configuration_delete(test, rg, checks=[]) + cleanup_scenario(test, rg) + + +# Test class for Scenario +@try_manual class PortalScenarioTest(ScenarioTest): - @ResourceGroupPreparer(name_prefix='cli_test_portal_testRG'[:9], key='rg') - def test_portal(self, resource_group): - + def __init__(self, *args, **kwargs): + super(PortalScenarioTest, self).__init__(*args, **kwargs) 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()]) + @ResourceGroupPreparer(name_prefix='clitestportal_testRG'[:7], key='rg', parameter_name='rg') + def test_portal_Scenario(self, rg): + call_scenario(self, rg) + calc_coverage(__file__) + raise_if() - 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}}}}}')]) 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..e39325b3408 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,10 @@ 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 = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + 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 +61,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..6bc14509b12 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/_portal.py +++ b/src/portal/azext_portal/vendored_sdks/portal/_portal.py @@ -6,26 +6,38 @@ # 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 Operations +from .operations import DashboardsOperations +from .operations import TenantConfigurationsOperations +from .operations import ListTenantConfigurationViolationsOperations from . import models class Portal(object): """Allows creation and deletion of Azure Shared Dashboards. - :ivar operation: OperationOperations operations - :vartype operation: portal.operations.OperationOperations - :ivar dashboard: DashboardOperations operations - :vartype dashboard: portal.operations.DashboardOperations + :ivar operations: Operations operations + :vartype operations: portal.operations.Operations + :ivar dashboards: DashboardsOperations operations + :vartype dashboards: portal.operations.DashboardsOperations + :ivar tenant_configurations: TenantConfigurationsOperations operations + :vartype tenant_configurations: portal.operations.TenantConfigurationsOperations + :ivar list_tenant_configuration_violations: ListTenantConfigurationViolationsOperations operations + :vartype list_tenant_configuration_violations: portal.operations.ListTenantConfigurationViolationsOperations :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 @@ -42,15 +54,19 @@ 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) self._deserialize = Deserializer(client_models) - self.operation = OperationOperations( + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.dashboards = DashboardsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenant_configurations = TenantConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize) - self.dashboard = DashboardOperations( + self.list_tenant_configuration_violations = ListTenantConfigurationViolationsOperations( self._client, self._config, self._serialize, self._deserialize) def close(self): diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py index 508cf5a4695..a2795e0ed3f 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._portal_async import Portal +from ._portal import Portal __all__ = ['Portal'] diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py b/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration.py similarity index 75% rename from src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py rename to src/portal/azext_portal/vendored_sdks/portal/aio/_configuration.py index f696a3c65d2..21d0ce805db 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration_async.py +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/_configuration.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,10 @@ 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 = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + 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 +57,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.py similarity index 51% rename from src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py rename to src/portal/azext_portal/vendored_sdks/portal/aio/_portal.py index 878f1ca00ae..06a087d1d45 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/aio/_portal_async.py +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/_portal.py @@ -6,26 +6,36 @@ # 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 -from ._configuration_async import PortalConfiguration -from .operations_async import OperationOperations -from .operations_async import DashboardOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import PortalConfiguration +from .operations import Operations +from .operations import DashboardsOperations +from .operations import TenantConfigurationsOperations +from .operations import ListTenantConfigurationViolationsOperations from .. import models class Portal(object): """Allows creation and deletion of Azure Shared Dashboards. - :ivar operation: OperationOperations operations - :vartype operation: portal.aio.operations_async.OperationOperations - :ivar dashboard: DashboardOperations operations - :vartype dashboard: portal.aio.operations_async.DashboardOperations + :ivar operations: Operations operations + :vartype operations: portal.aio.operations.Operations + :ivar dashboards: DashboardsOperations operations + :vartype dashboards: portal.aio.operations.DashboardsOperations + :ivar tenant_configurations: TenantConfigurationsOperations operations + :vartype tenant_configurations: portal.aio.operations.TenantConfigurationsOperations + :ivar list_tenant_configuration_violations: ListTenantConfigurationViolationsOperations operations + :vartype list_tenant_configuration_violations: portal.aio.operations.ListTenantConfigurationViolationsOperations :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 @@ -33,7 +43,7 @@ class Portal(object): def __init__( self, - credential: "TokenCredential", + credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any @@ -41,15 +51,19 @@ 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) self._deserialize = Deserializer(client_models) - self.operation = OperationOperations( + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.dashboards = DashboardsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenant_configurations = TenantConfigurationsOperations( self._client, self._config, self._serialize, self._deserialize) - self.dashboard = DashboardOperations( + self.list_tenant_configuration_violations = ListTenantConfigurationViolationsOperations( self._client, self._config, self._serialize, self._deserialize) async def close(self) -> None: diff --git a/src/portal/azext_portal/vendored_sdks/portal/aio/operations/__init__.py b/src/portal/azext_portal/vendored_sdks/portal/aio/operations/__init__.py new file mode 100644 index 00000000000..2858885252d --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._dashboards_operations import DashboardsOperations +from ._tenant_configurations_operations import TenantConfigurationsOperations +from ._list_tenant_configuration_violations_operations import ListTenantConfigurationViolationsOperations + +__all__ = [ + 'Operations', + 'DashboardsOperations', + 'TenantConfigurationsOperations', + 'ListTenantConfigurationViolationsOperations', +] 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/_dashboards_operations.py similarity index 56% rename from src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_dashboard_operations_async.py rename to src/portal/azext_portal/vendored_sdks/portal/aio/operations/_dashboards_operations.py index 000cbf46828..0409320f1ee 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/_dashboards_operations.py @@ -5,23 +5,25 @@ # 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, 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 ClientAuthenticationError, 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 DashboardOperations: - """DashboardOperations async operations. +class DashboardsOperations: + """DashboardsOperations 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 @@ -43,10 +45,7 @@ async def create_or_update( self, resource_group_name: str, dashboard_name: str, - location: str, - tags: Optional[Dict[str, str]] = None, - lenses: Optional[Dict[str, "DashboardLens"]] = None, - metadata: Optional[Dict[str, object]] = None, + dashboard: "models.Dashboard", **kwargs ) -> "models.Dashboard": """Creates or updates a Dashboard. @@ -55,27 +54,24 @@ async def create_or_update( :type resource_group_name: str :param dashboard_name: The name of the dashboard. :type dashboard_name: str - :param location: Resource location. - :type location: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param lenses: The dashboard lenses. - :type lenses: dict[str, ~portal.models.DashboardLens] - :param metadata: The dashboard metadata. - :type metadata: dict[str, object] + :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: + :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', {}) - - dashboard = models.Dashboard(location=location, tags=tags, lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "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 +80,26 @@ 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['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(dashboard, 'Dashboard') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) + 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) - 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 +107,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 +125,20 @@ 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" # 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,32 +147,33 @@ 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] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # 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, resource_group_name: str, dashboard_name: str, **kwargs - ) -> "models.Dashboard": + ) -> Optional["models.Dashboard"]: """Gets the Dashboard. :param resource_group_name: The name of the resource group. @@ -181,16 +181,20 @@ 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) - :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: + :return: Dashboard, or the result of cls(response) + :rtype: ~portal.models.Dashboard or None + :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[Optional["models.Dashboard"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" # 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,64 +203,63 @@ 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['Accept'] = 'application/json' + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # 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]: + if response.status_code not in [200, 404]: 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) + deserialized = None + if response.status_code == 200: + 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, - metadata: Optional[Dict[str, object]] = None, + dashboard: "models.PatchableDashboard", **kwargs - ) -> "models.Dashboard": + ) -> Optional["models.Dashboard"]: """Updates an existing Dashboard. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param dashboard_name: The name of the dashboard. :type dashboard_name: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param lenses: The dashboard lenses. - :type lenses: dict[str, ~portal.models.DashboardLens] - :param metadata: The dashboard metadata. - :type metadata: dict[str, object] + :param dashboard: The updatable fields of a Dashboard. + :type dashboard: ~portal.models.PatchableDashboard :keyword callable cls: A custom type or function that will be passed the direct response - :return: Dashboard or the result of cls(response) - :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: + :return: Dashboard, or the result of cls(response) + :rtype: ~portal.models.Dashboard or None + :raises: ~azure.core.exceptions.HttpResponseError """ - cls: ClsType["models.Dashboard"] = kwargs.pop('cls', None ) - error_map = kwargs.pop('error_map', {}) - - dashboard = models.PatchableDashboard(tags=tags, lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Dashboard"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "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 +268,80 @@ 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['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(dashboard, 'PatchableDashboard') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 404]: 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) + deserialized = None + if response.status_code == 200: + 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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 +349,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 +358,57 @@ 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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 +416,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 +425,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/_list_tenant_configuration_violations_operations.py b/src/portal/azext_portal/vendored_sdks/portal/aio/operations/_list_tenant_configuration_violations_operations.py new file mode 100644 index 00000000000..c97d7dd5b6c --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/operations/_list_tenant_configuration_violations_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, 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 ListTenantConfigurationViolationsOperations: + """ListTenantConfigurationViolationsOperations 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.ViolationsList"]: + """Gets list of items that violate tenant's configuration. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ViolationsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~portal.models.ViolationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ViolationsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ViolationsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Portal/listTenantConfigurationViolations'} # 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/_operations.py similarity index 55% rename from src/portal/azext_portal/vendored_sdks/portal/aio/operations_async/_operation_operations_async.py rename to src/portal/azext_portal/vendored_sdks/portal/aio/operations/_operations.py index aebe6bdf31d..47af01139c9 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/_operations.py @@ -5,23 +5,25 @@ # 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class OperationOperations: - """OperationOperations async operations. +class Operations: + """Operations 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,39 @@ 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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 +84,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 +93,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/_tenant_configurations_operations.py b/src/portal/azext_portal/vendored_sdks/portal/aio/operations/_tenant_configurations_operations.py new file mode 100644 index 00000000000..24ad1d3e3aa --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/aio/operations/_tenant_configurations_operations.py @@ -0,0 +1,279 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, 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 TenantConfigurationsOperations: + """TenantConfigurationsOperations 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 + + def list( + self, + **kwargs + ) -> AsyncIterable["models.ConfigurationList"]: + """Gets list of the tenant configurations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~portal.models.ConfigurationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ConfigurationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations'} # type: ignore + + async def get( + self, + configuration_name: Union[str, "models.ConfigurationName"], + **kwargs + ) -> Optional["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 or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Configuration"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + # 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'] = self._serialize.header("accept", accept, 'str') + + 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, 404]: + 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('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"], + tenant_configuration: "models.Configuration", + **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 tenant_configuration: The parameters required to create or update tenant configuration. + :type tenant_configuration: ~portal.models.Configuration + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "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'] = self._serialize.header("accept", accept, 'str') + + 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + # 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] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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..fe3f3d8d58c 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,78 @@ # -------------------------------------------------------------------------- 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 + from ._models_py3 import Violation + from ._models_py3 import ViolationsList 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 ._models import Violation # type: ignore + from ._models import ViolationsList # 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', + 'Violation', + 'ViolationsList', + '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..185553b92f5 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): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + 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. E.g. "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. E.g. "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 tenant configurations. + :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[~portal.models.DashboardLens] :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': '[DashboardLens]'}, '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[~portal.models.DashboardParts] :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': '[DashboardParts]'}, '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,43 @@ 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 additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :param type: Required. The type of dashboard part.Constant filled by server. + :type type: str + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'Extension/HubsExtension/PartType/MarkdownPart': 'MarkdownPartMetadata'} + } + + def __init__( + self, + **kwargs + ): + super(DashboardPartMetadata, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.type = 'DashboardPartMetadata' # type: str + + class DashboardParts(msrest.serialization.Model): """A dashboard part. @@ -129,7 +265,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 +274,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 +282,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 +323,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) @@ -223,7 +336,7 @@ class ErrorDefinition(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str + :vartype code: int :ivar message: Description of the error. :vartype message: str :ivar details: Internal error details. @@ -237,7 +350,7 @@ class ErrorDefinition(msrest.serialization.Model): } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'int'}, 'message': {'key': 'message', 'type': 'str'}, 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, } @@ -252,49 +365,133 @@ 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 additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :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'}, + 'additional_properties': {'key': '', 'type': '{object}'}, + '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: int + :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': 'int'}, + '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 +500,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[~portal.models.DashboardLens] :param metadata: The dashboard metadata. :type metadata: dict[str, object] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'lenses': {'key': 'properties.lenses', 'type': '[DashboardLens]'}, 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, } @@ -324,6 +521,40 @@ def __init__( self.metadata = kwargs.get('metadata', None) +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + 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. E.g. "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. @@ -403,3 +634,61 @@ def __init__( super(ResourceProviderOperationList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) + + +class Violation(msrest.serialization.Model): + """Violation information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Id of the item that violates tenant configuration. + :vartype id: str + :ivar user_id: Id of the user who owns violated item. + :vartype user_id: str + :ivar error_message: Error message. + :vartype error_message: str + """ + + _validation = { + 'id': {'readonly': True}, + 'user_id': {'readonly': True}, + 'error_message': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'error_message': {'key': 'errorMessage', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Violation, self).__init__(**kwargs) + self.id = None + self.user_id = None + self.error_message = None + + +class ViolationsList(msrest.serialization.Model): + """List of list of items that violate tenant's configuration. + + :param value: The array of violations. + :type value: list[~portal.models.Violation] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Violation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ViolationsList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) diff --git a/src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py b/src/portal/azext_portal/vendored_sdks/portal/models/_models_py3.py index 47507e86168..5b096495140 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): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + 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. E.g. "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. E.g. "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 tenant configurations. + :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[~portal.models.DashboardLens] :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': '[DashboardLens]'}, '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["DashboardLens"]] = 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[~portal.models.DashboardParts] :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': '[DashboardParts]'}, 'metadata': {'key': 'metadata', 'type': '{object}'}, } @@ -99,7 +203,7 @@ def __init__( self, *, order: int, - parts: Dict[str, "DashboardParts"], + parts: List["DashboardParts"], metadata: Optional[Dict[str, object]] = None, **kwargs ): @@ -135,6 +239,45 @@ 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 additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :param type: Required. The type of dashboard part.Constant filled by server. + :type type: str + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'Extension/HubsExtension/PartType/MarkdownPart': 'MarkdownPartMetadata'} + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, object]] = None, + **kwargs + ): + super(DashboardPartMetadata, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.type = 'DashboardPartMetadata' # type: str + + class DashboardParts(msrest.serialization.Model): """A dashboard part. @@ -143,7 +286,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 +295,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,39 +360,13 @@ 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. Variables are only populated by the server, and will be ignored when sending a request. :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str + :vartype code: int :ivar message: Description of the error. :vartype message: str :ivar details: Internal error details. @@ -263,7 +380,7 @@ class ErrorDefinition(msrest.serialization.Model): } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'int'}, 'message': {'key': 'message', 'type': 'str'}, 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, } @@ -278,38 +395,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 +416,144 @@ def __init__( self.error = error +class MarkdownPartMetadata(DashboardPartMetadata): + """Markdown part metadata. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :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 = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'type': {'key': 'type', 'type': 'str'}, + 'inputs': {'key': 'inputs', 'type': '[object]'}, + 'settings': {'key': 'settings', 'type': 'MarkdownPartMetadataSettings'}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, object]] = None, + inputs: Optional[List[object]] = None, + settings: Optional["MarkdownPartMetadataSettings"] = None, + **kwargs + ): + super(MarkdownPartMetadata, self).__init__(additional_properties=additional_properties, **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: int + :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': 'int'}, + 'markdown_uri': {'key': 'markdownUri', 'type': 'str'}, + } + + def __init__( + self, + *, + content: Optional[str] = None, + title: Optional[str] = None, + subtitle: Optional[str] = None, + markdown_source: Optional[int] = 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[~portal.models.DashboardLens] :param metadata: The dashboard metadata. :type metadata: dict[str, object] """ _attribute_map = { 'tags': {'key': 'tags', 'type': '{str}'}, - 'lenses': {'key': 'properties.lenses', 'type': '{DashboardLens}'}, + 'lenses': {'key': 'properties.lenses', 'type': '[DashboardLens]'}, 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, } @@ -346,7 +561,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - lenses: Optional[Dict[str, "DashboardLens"]] = None, + lenses: Optional[List["DashboardLens"]] = None, metadata: Optional[Dict[str, object]] = None, **kwargs ): @@ -356,6 +571,40 @@ def __init__( self.metadata = metadata +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + 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. E.g. "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. @@ -447,3 +696,64 @@ def __init__( super(ResourceProviderOperationList, self).__init__(**kwargs) self.value = value self.next_link = next_link + + +class Violation(msrest.serialization.Model): + """Violation information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Id of the item that violates tenant configuration. + :vartype id: str + :ivar user_id: Id of the user who owns violated item. + :vartype user_id: str + :ivar error_message: Error message. + :vartype error_message: str + """ + + _validation = { + 'id': {'readonly': True}, + 'user_id': {'readonly': True}, + 'error_message': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + 'error_message': {'key': 'errorMessage', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Violation, self).__init__(**kwargs) + self.id = None + self.user_id = None + self.error_message = None + + +class ViolationsList(msrest.serialization.Model): + """List of list of items that violate tenant's configuration. + + :param value: The array of violations. + :type value: list[~portal.models.Violation] + :param next_link: The URL to use for getting the next set of results. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Violation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Violation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ViolationsList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link 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..2858885252d 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/__init__.py @@ -6,10 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._operation_operations import OperationOperations -from ._dashboard_operations import DashboardOperations +from ._operations import Operations +from ._dashboards_operations import DashboardsOperations +from ._tenant_configurations_operations import TenantConfigurationsOperations +from ._list_tenant_configuration_violations_operations import ListTenantConfigurationViolationsOperations __all__ = [ - 'OperationOperations', - 'DashboardOperations', + 'Operations', + 'DashboardsOperations', + 'TenantConfigurationsOperations', + 'ListTenantConfigurationViolationsOperations', ] 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 deleted file mode 100644 index 403f882f8a6..00000000000 --- a/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboard_operations.py +++ /dev/null @@ -1,540 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from .. import models - -T = TypeVar('T') -ClsType = Optional[Callable[[ - PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - - -class DashboardOperations(object): - """DashboardOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~portal.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def create_or_update( - self, - resource_group_name, # type: str - dashboard_name, # type: str - location, # type: str - tags=None, # type: Optional[Dict[str, str]] - lenses=None, # type: Optional[Dict[str, "DashboardLens"]] - metadata=None, # type: Optional[Dict[str, object]] - **kwargs # type: Any - ): - # type: (...) -> "models.Dashboard" - """Creates or updates a Dashboard. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param dashboard_name: The name of the dashboard. - :type dashboard_name: str - :param location: Resource location. - :type location: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param lenses: The dashboard lenses. - :type lenses: dict[str, ~portal.models.DashboardLens] - :param metadata: The dashboard metadata. - :type metadata: dict[str, object] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Dashboard or Dashboard or the result of cls(response) - :rtype: ~portal.models.Dashboard or ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] - error_map = kwargs.pop('error_map', {}) - - dashboard = models.Dashboard( - location=location, tags=tags, lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" - - # Construct URL - url = self.create_or_update.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query( - "api_version", api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' - - # Construct body - body_content = self._serialize.body(dashboard, 'Dashboard') - - # Construct and send request - request = self._client.put( - url, query_parameters, header_parameters, body_content) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, - response=response, error_map=error_map) - raise models.ErrorResponseException.from_response( - response, self._deserialize) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('Dashboard', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Dashboard', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} - - def delete( - self, - resource_group_name, # type: str - dashboard_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes the Dashboard. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param dashboard_name: The name of the dashboard. - :type dashboard_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None or the result of cls(response) - :rtype: None - :raises: ~portal.models.ErrorResponseException: - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" - - # Construct URL - url = self.delete.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query( - "api_version", api_version, 'str') - - # Construct headers - header_parameters = {} - - # Construct and send request - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, - response=response, error_map=error_map) - raise models.ErrorResponseException.from_response( - response, self._deserialize) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} - - def get( - self, - resource_group_name, # type: str - dashboard_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.Dashboard" - """Gets the Dashboard. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param dashboard_name: The name of the dashboard. - :type dashboard_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Dashboard or the result of cls(response) - :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" - - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query( - "api_version", api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, - response=response, error_map=error_map) - raise models.ErrorResponseException.from_response( - response, self._deserialize) - - deserialized = self._deserialize('Dashboard', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} - - def update( - self, - resource_group_name, # type: str - dashboard_name, # type: str - lenses=None, # type: Optional[Dict[str, "DashboardLens"]] - metadata=None, # type: Optional[Dict[str, object]] - **kwargs # type: Any - ): - # type: (...) -> "models.Dashboard" - """Updates an existing Dashboard. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param dashboard_name: The name of the dashboard. - :type dashboard_name: str - :param lenses: The dashboard lenses. - :type lenses: dict[str, ~portal.models.DashboardLens] - :param metadata: The dashboard metadata. - :type metadata: dict[str, object] - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Dashboard or the result of cls(response) - :rtype: ~portal.models.Dashboard - :raises: ~portal.models.ErrorResponseException: - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Dashboard"] - error_map = kwargs.pop('error_map', {}) - - dashboard = models.PatchableDashboard(lenses=lenses, metadata=metadata) - api_version = "2019-01-01-preview" - - # Construct URL - url = self.update.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'dashboardName': self._serialize.url("dashboard_name", dashboard_name, 'str', max_length=64, min_length=3), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query( - "api_version", api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json' - - # Construct body - body_content = self._serialize.body(dashboard, 'PatchableDashboard') - - # Construct and send request - request = self._client.patch( - url, query_parameters, header_parameters, body_content) - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, - response=response, error_map=error_map) - raise models.ErrorResponseException.from_response( - response, self._deserialize) - - deserialized = self._deserialize('Dashboard', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} - - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.DashboardListResult" - """Gets all the Dashboards within a resource group. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DashboardListResult or the result of cls(response) - :rtype: ~portal.models.DashboardListResult - :raises: ~portal.models.ErrorResponseException: - """ - cls = kwargs.pop( - 'cls', None) # type: ClsType["models.DashboardListResult"] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" - - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - else: - url = next_link - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query( - "api_version", api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get( - url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - 'DashboardListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, - response=response, error_map=error_map) - raise models.ErrorResponseException.from_response( - response, self._deserialize) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = { - 'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} - - def list_by_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> "models.DashboardListResult" - """Gets all the dashboards within a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DashboardListResult or the result of cls(response) - :rtype: ~portal.models.DashboardListResult - :raises: ~portal.models.ErrorResponseException: - """ - cls = kwargs.pop( - 'cls', None) # type: ClsType["models.DashboardListResult"] - error_map = kwargs.pop('error_map', {}) - api_version = "2019-01-01-preview" - - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - else: - url = next_link - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query( - "api_version", api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - - # Construct and send request - request = self._client.get( - url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize( - 'DashboardListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run( - request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, - response=response, error_map=error_map) - raise models.ErrorResponseException.from_response( - response, self._deserialize) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = { - 'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} - - 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}'} diff --git a/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboards_operations.py b/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboards_operations.py new file mode 100644 index 00000000000..d017d9810a8 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_dashboards_operations.py @@ -0,0 +1,447 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class DashboardsOperations(object): + """DashboardsOperations 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 create_or_update( + 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 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct 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'), + '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 = {} # 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'] = self._serialize.header("accept", accept, 'str') + + 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) + 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('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}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + dashboard_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes the Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + # Construct 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'), + '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 = {} # 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'] = self._serialize.header("accept", accept, 'str') + + 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': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards/{dashboardName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + dashboard_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["models.Dashboard"] + """Gets the Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard, or the result of cls(response) + :rtype: ~portal.models.Dashboard or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Dashboard"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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 = {} # 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'] = self._serialize.header("accept", accept, 'str') + + 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, 404]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 + dashboard, # type: "models.PatchableDashboard" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.Dashboard"] + """Updates an existing Dashboard. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param dashboard_name: The name of the dashboard. + :type dashboard_name: str + :param dashboard: The updatable fields of a Dashboard. + :type dashboard: ~portal.models.PatchableDashboard + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Dashboard, or the result of cls(response) + :rtype: ~portal.models.Dashboard or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Dashboard"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + '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 = {} # 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'] = self._serialize.header("accept", accept, 'str') + + 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) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + 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) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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: (...) -> 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: 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Portal/dashboards'} # type: ignore + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # 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: 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + 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) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Portal/dashboards'} # type: ignore diff --git a/src/portal/azext_portal/vendored_sdks/portal/operations/_list_tenant_configuration_violations_operations.py b/src/portal/azext_portal/vendored_sdks/portal/operations/_list_tenant_configuration_violations_operations.py new file mode 100644 index 00000000000..4c4422a2936 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_list_tenant_configuration_violations_operations.py @@ -0,0 +1,110 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ListTenantConfigurationViolationsOperations(object): + """ListTenantConfigurationViolationsOperations 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: (...) -> Iterable["models.ViolationsList"] + """Gets list of items that violate tenant's configuration. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ViolationsList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~portal.models.ViolationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ViolationsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + else: + url = next_link + 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('ViolationsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Portal/listTenantConfigurationViolations'} # 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/_operations.py similarity index 51% rename from src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py rename to src/portal/azext_portal/vendored_sdks/portal/operations/_operations.py index 59145766d1b..ddd440d1c38 100644 --- a/src/portal/azext_portal/vendored_sdks/portal/operations/_operation_operations.py +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_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 ClientAuthenticationError, 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 -class OperationOperations(object): - """OperationOperations operations. + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. +class Operations(object): + """Operations 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 @@ -43,35 +49,39 @@ 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + 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 +89,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 +98,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_configurations_operations.py b/src/portal/azext_portal/vendored_sdks/portal/operations/_tenant_configurations_operations.py new file mode 100644 index 00000000000..a5d9fd55fc5 --- /dev/null +++ b/src/portal/azext_portal/vendored_sdks/portal/operations/_tenant_configurations_operations.py @@ -0,0 +1,287 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TenantConfigurationsOperations(object): + """TenantConfigurationsOperations 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: (...) -> Iterable["models.ConfigurationList"] + """Gets list of the tenant configurations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConfigurationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~portal.models.ConfigurationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + 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('ConfigurationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Portal/tenantConfigurations'} # type: ignore + + def get( + self, + configuration_name, # type: Union[str, "models.ConfigurationName"] + **kwargs # type: Any + ): + # type: (...) -> Optional["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 or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Configuration"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + # 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'] = self._serialize.header("accept", accept, 'str') + + 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, 404]: + 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('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"] + tenant_configuration, # type: "models.Configuration" + **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 tenant_configuration: The parameters required to create or update tenant configuration. + :type tenant_configuration: ~portal.models.Configuration + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "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'] = self._serialize.header("accept", accept, 'str') + + 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-09-01-preview" + accept = "application/json" + + # 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] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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..992b83774ac --- /dev/null +++ b/src/portal/report.md @@ -0,0 +1,171 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az portal|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az portal` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az portal dashboard|Dashboards|[commands](#CommandsInDashboards)| +|az portal tenant-configuration|TenantConfigurations|[commands](#CommandsInTenantConfigurations)| +|az portal list-tenant-configuration-violation|ListTenantConfigurationViolations|[commands](#CommandsInListTenantConfigurationViolations)| + +## COMMANDS +### Commands in `az portal dashboard` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az portal dashboard list](#DashboardsListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersDashboardsListByResourceGroup)|[Example](#ExamplesDashboardsListByResourceGroup)| +|[az portal dashboard list](#DashboardsListBySubscription)|ListBySubscription|[Parameters](#ParametersDashboardsListBySubscription)|[Example](#ExamplesDashboardsListBySubscription)| +|[az portal dashboard show](#DashboardsGet)|Get|[Parameters](#ParametersDashboardsGet)|[Example](#ExamplesDashboardsGet)| +|[az portal dashboard create](#DashboardsCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersDashboardsCreateOrUpdate#Create)|[Example](#ExamplesDashboardsCreateOrUpdate#Create)| +|[az portal dashboard update](#DashboardsUpdate)|Update|[Parameters](#ParametersDashboardsUpdate)|[Example](#ExamplesDashboardsUpdate)| +|[az portal dashboard delete](#DashboardsDelete)|Delete|[Parameters](#ParametersDashboardsDelete)|[Example](#ExamplesDashboardsDelete)| + +### Commands in `az portal list-tenant-configuration-violation` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az portal list-tenant-configuration-violation list](#ListTenantConfigurationViolationsList)|List|[Parameters](#ParametersListTenantConfigurationViolationsList)|[Example](#ExamplesListTenantConfigurationViolationsList)| + +### Commands in `az portal tenant-configuration` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az portal tenant-configuration list](#TenantConfigurationsList)|List|[Parameters](#ParametersTenantConfigurationsList)|[Example](#ExamplesTenantConfigurationsList)| +|[az portal tenant-configuration show](#TenantConfigurationsGet)|Get|[Parameters](#ParametersTenantConfigurationsGet)|[Example](#ExamplesTenantConfigurationsGet)| +|[az portal tenant-configuration create](#TenantConfigurationsCreate)|Create|[Parameters](#ParametersTenantConfigurationsCreate)|[Example](#ExamplesTenantConfigurationsCreate)| +|[az portal tenant-configuration delete](#TenantConfigurationsDelete)|Delete|[Parameters](#ParametersTenantConfigurationsDelete)|[Example](#ExamplesTenantConfigurationsDelete)| + + +## COMMAND DETAILS + +### group `az portal dashboard` +#### Command `az portal dashboard list` + +##### Example +``` +az portal dashboard list --resource-group "testRG" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group.|resource_group_name|resourceGroupName| + +#### Command `az portal dashboard list` + +##### Example +``` +az portal dashboard list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az portal dashboard show` + +##### Example +``` +az portal dashboard show --name "testDashboard" --resource-group "testRG" +``` +##### 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| + +#### Command `az portal dashboard create` + +##### Example +``` +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}}]},{\\"orde\ +r\\":2,\\"parts\\":[]}]" --metadata "{\\"metadata\\":{\\"ColSpan\\":2,\\"RowSpan\\":1,\\"X\\":4,\\"Y\\":3}}" --tags \ +aKey="aValue" anotherKey="anotherValue" --name "testDashboard" --resource-group "testRG" +``` +##### 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| + +#### Command `az portal dashboard update` + +##### Example +``` +az portal dashboard update --tags aKey="bValue" anotherKey="anotherValue2" --name "testDashboard" --resource-group \ +"testRG" +``` +##### 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| + +#### Command `az portal dashboard delete` + +##### Example +``` +az portal dashboard delete --name "testDashboard" --resource-group "testRG" +``` +##### 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| + +### group `az portal list-tenant-configuration-violation` +#### Command `az portal list-tenant-configuration-violation list` + +##### Example +``` +az portal list-tenant-configuration-violation list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +### group `az portal tenant-configuration` +#### Command `az portal tenant-configuration list` + +##### Example +``` +az portal tenant-configuration list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az portal tenant-configuration show` + +##### Example +``` +az portal tenant-configuration show +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az portal tenant-configuration create` + +##### Example +``` +az portal tenant-configuration create --enforce-private-markdown-storage true +``` +##### 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| + +#### Command `az portal tenant-configuration delete` + +##### Example +``` +az portal tenant-configuration delete +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| \ No newline at end of file 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 3e4dc5dd0fe..0569b0051dd 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,9 +30,13 @@ 'License :: OSI Approved :: MIT License', ] -# TODO: Add any additional SDK dependencies here DEPENDENCIES = [] +try: + from azext_portal.manual.dependency import DEPENDENCIES +except ImportError: + pass + with open('README.md', 'r', encoding='utf-8') as f: README = f.read() with open('HISTORY.rst', 'r', encoding='utf-8') as f: @@ -44,7 +46,6 @@ 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', url='https://github.com/Azure/azure-cli-extensions/tree/master/src/portal',