diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a988612eff1..04e86c8ce86 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -226,6 +226,8 @@ /src/datamigration/ @ashutoshsuman99 +/src/amg/ @yugangw-msft + /src/confidentialledger/ @kairu-ms @lynshi -/src/quota/ @kairu-ms @ZengTaoxu +/src/quota/ @kairu-ms @ZengTaoxu \ No newline at end of file diff --git a/src/amg/HISTORY.rst b/src/amg/HISTORY.rst new file mode 100644 index 00000000000..8c34bccfff8 --- /dev/null +++ b/src/amg/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. \ No newline at end of file diff --git a/src/amg/README.md b/src/amg/README.md new file mode 100644 index 00000000000..f3a6a8df8db --- /dev/null +++ b/src/amg/README.md @@ -0,0 +1,55 @@ +# Microsoft Azure CLI 'amg' Extension +This is an extension to manage Azure Manaaged Grafana instances + +## How to use ## +Install this extension using the below CLI command +``` +az extension add --name amg +``` + +## Included Features +### Create, show, and delete instances + +#### create an instance +*Examples:* +``` +az grafana create \ + -g MyResourceGroup \ + -n MyGrafanaInstance \ + --tags department=financial +``` + +#### delete an instance +*Examples:* +``` +az grafana delete \ + -n MyGrafanaInstance +``` + +### Configure folder, data sources and dashboard + +#### create a folder +*Examples:* +``` +az grafana folder create \ + -n MyGrafanaInstance \ + --title "Health KPI" +``` + +#### configure a data source +*Examples:* +``` +az grafana data-source create \ + -n MyGrafanaInstance \ + --definition ~/data-source-sql.json +``` + +#### Create a dashboard +*Examples:* +``` +az grafana dashboard create \ + -n MyGrafanaInstance \ + --folder "Health KPI" \ + --title "SQL status" \ + --definition ~/dashboard-sql.json +``` \ No newline at end of file diff --git a/src/amg/azext_amg/__init__.py b/src/amg/azext_amg/__init__.py new file mode 100644 index 00000000000..3940cb1b4ca --- /dev/null +++ b/src/amg/azext_amg/__init__.py @@ -0,0 +1,31 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader + +from azext_amg._help import helps # pylint: disable=unused-import + + +class AmgCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + amg_custom = CliCommandType( + operations_tmpl='azext_amg.custom#{}') + # pylint: disable=super-with-arguments + super(AmgCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=amg_custom) + + def load_command_table(self, args): + from azext_amg.commands import load_command_table + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azext_amg._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = AmgCommandsLoader diff --git a/src/amg/azext_amg/_client_factory.py b/src/amg/azext_amg/_client_factory.py new file mode 100644 index 00000000000..da746bc832a --- /dev/null +++ b/src/amg/azext_amg/_client_factory.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +def cf_amg(cli_ctx, *_): + # pylint: disable=unused-argument + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azext_amg.vendored_sdks import DashboardManagementClient + return get_mgmt_service_client(cli_ctx, DashboardManagementClient) diff --git a/src/amg/azext_amg/_help.py b/src/amg/azext_amg/_help.py new file mode 100644 index 00000000000..c70b58c3bb6 --- /dev/null +++ b/src/amg/azext_amg/_help.py @@ -0,0 +1,212 @@ +# 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. +# -------------------------------------------------------------------------------------------- + +from knack.help_files import helps # pylint: disable=unused-import + + +helps['grafana'] = """ + type: group + short-summary: Commands to manage Azure Grafana instanced. + long-summary: For optimized experience, not all data plane Apis, documented at https://grafana.com/docs/grafana/latest/http_api/, are exposed. On coverage gap, please reach out to ad4g@microsoft.com +""" + +helps['grafana create'] = """ + type: command + short-summary: Create a Azure Managed Grafana instance. +""" + +helps['grafana list'] = """ + type: command + short-summary: List Azure Managed Grafana instances. +""" + +helps['grafana delete'] = """ + type: command + short-summary: Delete a Azure Managed Grafana instance. +""" + +helps['grafana show'] = """ + type: command + short-summary: Show details of a Azure Managed Grafana instance. +""" + +helps['grafana data-source'] = """ + type: group + short-summary: Commands to manage data sources of an instance. +""" + +helps['grafana data-source create'] = """ + type: command + short-summary: Create a data source. + examples: + - name: create a data source of Azure SQL + text: | + az grafana data-source create -n MyGrafana --definition '{ + "access": "proxy", + "database": "testdb", + "jsonData": { + "authenticationType": "SQL Server Authentication", + "encrypt": "false" + }, + "secureJsonData": { + "password": "verySecretPassword" + }, + "name": "Microsoft SQL Server", + "type": "mssql", + "url": "testsql.database.windows.net", + "user": "admin1" + }' +""" + + +helps['grafana data-source update'] = """ + type: command + short-summary: Update a data source. +""" + +helps['grafana data-source show'] = """ + type: command + short-summary: get details of a data source +""" + +helps['grafana data-source delete'] = """ + type: command + short-summary: delete a data source +""" + +helps['grafana data-source list'] = """ + type: command + short-summary: List all data sources of an instance. +""" + +helps['grafana data-source query'] = """ + type: command + short-summary: query a data source having backend implementation +""" + +helps['grafana dashboard'] = """ + type: group + short-summary: Commands to manage dashboards of an instance. +""" + +helps['grafana dashboard create'] = """ + type: command + short-summary: Create a new dashboard. + examples: + - name: Create a dashboard with definition in a json file. For quick start, clone from the output of "az grafana dashboard show", remove "id" and "uid", and apply changes. + text: | + az grafana dashboard create -g MyResourceGroup -n MyGrafana --title "My dashboard" --folder folder1 --definition '{ + "dashboard": { + "annotations": { + ... + }, + "panels": { + ... + } + }, + "message": "Create a new test dashboard" + }' +""" + +helps['grafana dashboard update'] = """ + type: command + short-summary: Update a dashboard. + examples: + - name: Update a dashboard with definition in a json file. For quick start, get existing configuration from "az grafana dashboard show", and apply changes. + "version" field need to be updated, and "overwrite" field should be true. + text: | + az grafana dashboard update -g MyResourceGroup -n MyGrafana --definition @c:\\temp\\dashboard.json +""" + +helps['grafana dashboard import'] = """ + type: command + short-summary: import a dashboard. + long-summary: CLI command will fill in required parameters for data sources if configured + examples: + - name: import the dashboard of "AKS Container Insights" from Grafana gallery. + text: | + az grafana dashboard import -g MyResourceGroup -n MyGrafana --definition 12180 + - name: import a dashboard from a file. + text: | + az grafana dashboard import -g MyResourceGroup -n MyGrafana --definition @c:\\temp\\dashboard.json +""" + +helps['grafana dashboard list'] = """ + type: command + short-summary: List all dashboards of an instance. + examples: + - name: Find the dashboard for K8s API Server and retrieve the unique identifier(in order to invoke "az grafana dashboard show" command) + text: | + az grafana dashboard list -g MyResourceGroup -n MyGrafana --query "[?contains(@.title, 'API server')].uid" +""" + +helps['grafana dashboard show'] = """ + type: command + short-summary: show the detail of a dashboard. + examples: + - name: Get details of a dashboard specified by an unique identifier(use "az grafana dashboard list" command to retrieve the uid) + text: | + az grafana dashboard show -g MyResourceGroup -n MyGrafana --dashboard VdrOA7jGz +""" + +helps['grafana dashboard delete'] = """ + type: command + short-summary: delete a dashboard + examples: + - name: Delete a dashboard specified by an unique identifier(use "az grafana dashboard list" command to retrieve the uid) + text: | + az grafana dashboard delete -g MyResourceGroup -n MyGrafana --dashboard VdrOA7jGz +""" + +helps['grafana folder'] = """ + type: group + short-summary: Commands to manage folders of an instance. +""" + +helps['grafana folder create'] = """ + type: command + short-summary: create a new folder. +""" + +helps['grafana folder show'] = """ + type: command + short-summary: show the details of a folder. +""" + +helps['grafana folder list'] = """ + type: command + short-summary: list all folders of an instance. +""" + +helps['grafana folder update'] = """ + type: command + short-summary: update a folder. +""" + +helps['grafana folder delete'] = """ + type: command + short-summary: delete a folder. +""" + +helps['grafana user'] = """ + type: group + short-summary: Commands to manage users of an instance. +""" + +helps['grafana user actual-user'] = """ + type: command + short-summary: show details of current user. +""" + +helps['grafana user list'] = """ + type: command + short-summary: list users. +""" + +helps['grafana user show'] = """ + type: command + short-summary: show detail of a user. +""" diff --git a/src/amg/azext_amg/_params.py b/src/amg/azext_amg/_params.py new file mode 100644 index 00000000000..dcb984ffe13 --- /dev/null +++ b/src/amg/azext_amg/_params.py @@ -0,0 +1,57 @@ +# -------------------------------------------------------------------------------------------- +# 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 + + +def load_arguments(self, _): + + from knack.arguments import CLIArgumentType + from azure.cli.core.commands.parameters import tags_type, get_three_state_flag + from azure.cli.core.commands.validators import get_default_location_from_resource_group + from ._validators import process_missing_resource_group_parameter + + grafana_name_type = CLIArgumentType(options_list="--grafana-name", + help="Name of the Azure Managed Dashboard for Grafana.", + id_part="name") + + with self.argument_context("grafana") as c: + c.argument("tags", tags_type) + c.argument("location", validator=get_default_location_from_resource_group) + c.argument("grafana_name", grafana_name_type, options_list=["--name", "-n"], id_part=None, validator=process_missing_resource_group_parameter) + c.argument("id", help=("The identifier (id) of a dashboard/data source is an auto-incrementing " + "numeric value and is only unique per Grafana install.")) + c.argument("folder", help="id, uid, title which can identify a folder. CLI will search in the order of id, uid, and title, till finds a match") + + with self.argument_context("grafana create") as c: + c.argument("grafana_name", grafana_name_type, options_list=["--name", "-n"], validator=None) + c.argument("skip_system_assigned_identity", options_list=["-s", "--skip-system-assigned-identity"], arg_type=get_three_state_flag(), help="Do not enable system assigned identity") + c.argument("skip_role_assignments", arg_type=get_three_state_flag(), help="Do not create role assignments for managed identity and the current login user") + + with self.argument_context("grafana dashboard") as c: + c.argument("uid", options_list=["--dashboard"], help="dashboard uid") + c.argument("definition", help="The complete dashboard model in json string, a path or url to a file with such content") + c.argument("title", help="title of a dashboard") + c.argument('overwrite', arg_type=get_three_state_flag(), help='Overwrite a dashboard with same uid') + + with self.argument_context("grafana dashboard import") as c: + c.argument("definition", help="The complete dashboard model in json string, Grafana gallery id, a path or url to a file with such content") + + with self.argument_context("grafana data-source") as c: + c.argument("data_source", help="name, id, uid which can identify a data source. CLI will search in the order of name, id, and uid, till finds a match") + c.argument("definition", help="json string with data source definition, or a path to a file with such content") + + with self.argument_context("grafana data-source query") as c: + c.argument("conditions", nargs="+", help="space-separated condition in a format of `=`") + c.argument("time_from", options_list=["--from"], help="start time in iso 8601, e.g. '2022-01-02T16:15:00'. Default: 1 hour early") + c.argument("time_to", options_list=["--to"], help="end time in iso 8601, e.g. '2022-01-02T17:15:00'. Default: current time ") + c.argument("max_data_points", help="Maximum amount of data points that dashboard panel can render") + c.argument("query_format", help="format of the resule, e.g. table, time_series") + c.argument("internal_ms", help="The time interval in milliseconds of time series") + + with self.argument_context("grafana folder") as c: + c.argument("title", help="title of the folder") + + with self.argument_context("grafana user") as c: + c.argument("user", help="user login name or email") diff --git a/src/amg/azext_amg/_validators.py b/src/amg/azext_amg/_validators.py new file mode 100644 index 00000000000..e905c58afe1 --- /dev/null +++ b/src/amg/azext_amg/_validators.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from msrestazure.tools import parse_resource_id + +from knack.util import CLIError + +from azure.cli.core.commands.validators import get_default_location_from_resource_group, validate_tags +from azure.cli.core.commands.client_factory import get_mgmt_service_client +from azure.cli.core.profiles import ResourceType + + +def process_grafana_create_namespace(cmd, namespace): + validate_tags(namespace) + if not namespace.location: + get_default_location_from_resource_group(cmd, namespace) + + +def process_missing_resource_group_parameter(cmd, namespace): + if not namespace.resource_group_name and namespace.grafana_name: + client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES) + resources = client.resources.list(filter="resourceType eq 'Microsoft.Dashboard/grafana'") + resources = list(resources) + match = next((i for i in resources if i.name == namespace.grafana_name), None) + if match: + namespace.resource_group_name = parse_resource_id(match.id)["resource_group"] + else: + raise CLIError((f"Not able to find the Grafana instance: '{namespace.grafana_name}'. Please " + f"correct the name, or provide resource group name, or set CLI " + f"subscription the workspace belongs to")) diff --git a/src/amg/azext_amg/azext_metadata.json b/src/amg/azext_amg/azext_metadata.json new file mode 100644 index 00000000000..044f0f3f3f3 --- /dev/null +++ b/src/amg/azext_amg/azext_metadata.json @@ -0,0 +1,5 @@ +{ + "azext.isPreview": true, + "azext.minCliCoreVersion": "2.30.0", + "azext.maxCliCoreVersion": "2.99.0" +} \ No newline at end of file diff --git a/src/amg/azext_amg/commands.py b/src/amg/azext_amg/commands.py new file mode 100644 index 00000000000..515b0f408b2 --- /dev/null +++ b/src/amg/azext_amg/commands.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------------------------- +# 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 + +from ._validators import process_grafana_create_namespace + + +def load_command_table(self, _): + + with self.command_group('grafana', is_preview=True) as g: + g.custom_command('create', 'create_grafana', validator=process_grafana_create_namespace) + g.custom_command('delete', 'delete_grafana', confirmation=True) + g.custom_command('list', 'list_grafana') + g.custom_show_command('show', 'show_grafana') + + with self.command_group('grafana dashboard') as g: + g.custom_command('create', 'create_dashboard') + g.custom_command('delete', 'delete_dashboard') + g.custom_command('list', 'list_dashboards') + g.custom_show_command('show', 'show_dashboard') + g.custom_command('update', 'update_dashboard') + g.custom_command('import', 'import_dashboard') + + with self.command_group('grafana data-source') as g: + g.custom_command('create', 'create_data_source') + g.custom_command('list', 'list_data_sources') + g.custom_show_command('show', 'show_data_source') + g.custom_command('delete', 'delete_data_source') + g.custom_command('query', 'query_data_source') + g.custom_command('update', 'update_data_source') + + with self.command_group('grafana folder') as g: + g.custom_command('create', 'create_folder') + g.custom_command('list', 'list_folders') + g.custom_show_command('show', 'show_folder') + g.custom_command('delete', 'delete_folder') + g.custom_command('update', 'update_folder') + + with self.command_group('grafana user') as g: + g.custom_command('list', 'list_users') + g.custom_show_command('show', 'show_user') + g.custom_command('actual-user', 'get_actual_user') diff --git a/src/amg/azext_amg/custom.py b/src/amg/azext_amg/custom.py new file mode 100644 index 00000000000..63a90f6b552 --- /dev/null +++ b/src/amg/azext_amg/custom.py @@ -0,0 +1,440 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import json +import requests + +from msrestazure.azure_exceptions import CloudError + +from knack.log import get_logger + +from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_subscription_id +from azure.cli.core.profiles import ResourceType, get_sdk +from azure.cli.core.util import should_disable_connection_verify +from azure.cli.core.azclierror import ArgumentUsageError, CLIInternalError + +from ._client_factory import cf_amg + +logger = get_logger(__name__) + + +grafana_endpoints = {} + + +def create_grafana(cmd, resource_group_name, grafana_name, + location=None, skip_system_assigned_identity=False, skip_role_assignments=False, tags=None): + from azure.cli.core.commands.arm import resolve_role_id + from azure.cli.core.commands import LongRunningOperation + client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES) + resource = { + "sku": { + "name": "standard" + }, + "location": location, + "identity": None if skip_system_assigned_identity else {"type": "SystemAssigned"}, + "tags": tags + } + poller = client.resources.begin_create_or_update(resource_group_name, "Microsoft.Dashboard", "", + "grafana", grafana_name, "2021-09-01-preview", resource) + + if skip_role_assignments: + return poller + resource = LongRunningOperation(cmd.cli_ctx)(poller) + + logger.warning("Grafana instance of '%s' was created. Now creating default role assignments for its " + "managed identity and current CLI user", grafana_name) + + subscription_scope = '/subscriptions/' + client._config.subscription_id # pylint: disable=protected-access + + user_principal_id = _get_login_account_principal_id(cmd.cli_ctx) + grafana_admin_role_id = resolve_role_id(cmd.cli_ctx, "Grafana Admin", subscription_scope) + _create_role_assignment(cmd.cli_ctx, user_principal_id, grafana_admin_role_id, resource.id) + + if resource.identity: + monitoring_reader_role_id = resolve_role_id(cmd.cli_ctx, "Monitoring Reader", subscription_scope) + _create_role_assignment(cmd.cli_ctx, resource.identity.principal_id, monitoring_reader_role_id, + subscription_scope) + + return resource + + +def _get_login_account_principal_id(cli_ctx): + from azure.cli.core._profile import Profile + from azure.graphrbac import GraphRbacManagementClient + profile = Profile(cli_ctx=cli_ctx) + cred, _, tenant_id = profile.get_login_credentials( + resource=cli_ctx.cloud.endpoints.active_directory_graph_resource_id) + client = GraphRbacManagementClient(cred, tenant_id, + base_url=cli_ctx.cloud.endpoints.active_directory_graph_resource_id) + assignee = profile.get_current_account_user() + result = list(client.users.list(filter=f"userPrincipalName eq '{assignee}'")) + if not result: + result = list(client.service_principals.list( + filter=f"servicePrincipalNames/any(c:c eq '{assignee}')")) + if not result: + raise CLIInternalError((f"Failed to retrieve principal id for '{assignee}', which is needed to create a " + f"role assignment")) + return result[0].object_id + + +def _create_role_assignment(cli_ctx, principal_id, role_definition_id, scope): + import time + import uuid + assignments_client = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_AUTHORIZATION).role_assignments + RoleAssignmentCreateParameters = get_sdk(cli_ctx, ResourceType.MGMT_AUTHORIZATION, + 'RoleAssignmentCreateParameters', mod='models', + operation_group='role_assignments') + parameters = RoleAssignmentCreateParameters(role_definition_id=role_definition_id, principal_id=principal_id) + + logger.info("Creating an assignment with a role '%s' on the scope of '%s'", role_definition_id, scope) + retry_times = 36 + assignment_name = uuid.uuid4() + for retry_time in range(0, retry_times): + try: + assignments_client.create(scope=scope, role_assignment_name=assignment_name, + parameters=parameters) + break + except CloudError as ex: + if 'role assignment already exists' in ex.message: + logger.info('Role assignment already exists') + break + if retry_time < retry_times and ' does not exist in the directory ' in ex.message: + time.sleep(5) + logger.warning('Retrying role assignment creation: %s/%s', retry_time + 1, + retry_times) + continue + raise + + +def list_grafana(cmd, resource_group_name=None): + client = cf_amg(cmd.cli_ctx) + if resource_group_name: + return client.grafana.list_by_resource_group(resource_group_name) + return client.grafana.list() + + +def show_grafana(cmd, grafana_name, resource_group_name=None): + client = cf_amg(cmd.cli_ctx) + return client.grafana.get(resource_group_name, grafana_name) + + +def delete_grafana(cmd, grafana_name, resource_group_name=None): + client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES) + return client.resources.begin_delete(resource_group_name, "Microsoft.Dashboard", + "", "grafana", grafana_name, "2021-09-01-preview") + + +def show_dashboard(cmd, grafana_name, uid, resource_group_name=None): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/dashboards/uid/" + uid) + return json.loads(response.content) + + +def list_dashboards(cmd, grafana_name, resource_group_name=None): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/search?type=dash-db") + return json.loads(response.content) + + +def create_dashboard(cmd, grafana_name, definition, title=None, folder=None, resource_group_name=None, overwrite=None): + data = _try_load_dashboard_definition(cmd, resource_group_name, grafana_name, definition, for_import=False) + if "dashboard" in data: + payload = data + else: + logger.info("Adjust input by adding 'dashboard' field") + payload = {} + payload["dashboard"] = data + + if title: + payload['dashboard']['title'] = title + + if folder: + folder = _find_folder(cmd, resource_group_name, grafana_name, folder) + payload['folderId'] = folder["id"] + + payload["overwrite"] = overwrite or False + + if "id" in payload["dashboard"]: + logger.warning("Removing 'id' from dashboard to prevent the error of 'Not Found'") + del payload["dashboard"]["id"] + + response = _send_request(cmd, resource_group_name, grafana_name, "post", "/api/dashboards/db", + payload) + return json.loads(response.content) + + +def update_dashboard(cmd, grafana_name, definition, folder=None, resource_group_name=None, overwrite=None): + return create_dashboard(cmd, grafana_name, definition, folder=folder, + resource_group_name=resource_group_name, + overwrite=overwrite) + + +def import_dashboard(cmd, grafana_name, definition, folder=None, resource_group_name=None, overwrite=None): + import copy + data = _try_load_dashboard_definition(cmd, resource_group_name, grafana_name, definition, for_import=True) + if "dashboard" in data: + payload = data + else: + logger.info("Adjust input by adding 'dashboard' field") + payload = {} + payload["dashboard"] = data + + if folder: + folder = _find_folder(cmd, resource_group_name, grafana_name, folder) + payload['folderId'] = folder["id"] + + payload["overwrite"] = overwrite or False + + payload["inputs"] = [] + + # provide parameter values for datasource + data_sources = list_data_sources(cmd, grafana_name, resource_group_name) + for parameter in payload["dashboard"].get('__inputs', []): + if parameter.get("type") == "datasource": + match = next((d for d in data_sources if d["type"] == parameter["pluginId"]), None) + if match: + clone = copy.deepcopy(parameter) + clone["value"] = match["uid"] + payload["inputs"].append(clone) + else: + logger.warning("No data source was found matching the required parameter of %s", parameter['pluginId']) + + response = _send_request(cmd, resource_group_name, grafana_name, "post", "/api/dashboards/import", + payload) + return json.loads(response.content) + + +def _try_load_dashboard_definition(cmd, resource_group_name, grafana_name, definition, for_import): + import re + + if for_import: + try: # see whether it is a gallery id + int(definition) + response = _send_request(cmd, resource_group_name, grafana_name, "get", + "/api/gnet/dashboards/" + definition) + return json.loads(response.content)["json"] + except ValueError: + pass + + if re.match(r"^[a-z]+://", definition.lower()): + response = requests.get(definition, verify=(not should_disable_connection_verify())) + if response.status_code == 200: + definition = json.loads(response.content.decode()) + else: + raise ArgumentUsageError(f"Failed to dashboard definition from '{definition}'. Error: '{response}'.") + else: + definition = json.loads(_try_load_file_content(definition)) + + return definition + + +def delete_dashboard(cmd, grafana_name, uid, resource_group_name=None): + _send_request(cmd, resource_group_name, grafana_name, "delete", "/api/dashboards/uid/" + uid) + + +def create_data_source(cmd, grafana_name, definition, resource_group_name=None): + definition = _try_load_file_content(definition) + payload = json.loads(definition) + response = _send_request(cmd, resource_group_name, grafana_name, "post", "/api/datasources", payload) + return json.loads(response.content) + + +def show_data_source(cmd, grafana_name, data_source, resource_group_name=None): + return _find_data_source(cmd, resource_group_name, grafana_name, data_source) + + +def delete_data_source(cmd, grafana_name, data_source, resource_group_name=None): + data = _find_data_source(cmd, resource_group_name, grafana_name, data_source) + _send_request(cmd, resource_group_name, grafana_name, "delete", "/api/datasources/uid/" + data["uid"]) + + +def list_data_sources(cmd, grafana_name, resource_group_name=None): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/datasources") + return json.loads(response.content) + + +def update_data_source(cmd, grafana_name, data_source, definition, resource_group_name=None): + definition = _try_load_file_content(definition) + data = _find_data_source(cmd, resource_group_name, grafana_name, data_source) + response = _send_request(cmd, resource_group_name, grafana_name, "put", "/api/datasources/" + str(data['id']), + json.loads(definition)) + return json.loads(response.content) + + +def create_folder(cmd, grafana_name, title, resource_group_name=None): + payload = { + "title": title + } + response = _send_request(cmd, resource_group_name, grafana_name, "post", "/api/folders", payload) + return json.loads(response.content) + + +def list_folders(cmd, grafana_name, resource_group_name=None): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/folders") + return json.loads(response.content) + + +def update_folder(cmd, grafana_name, folder, title, resource_group_name=None): + f = show_folder(cmd, grafana_name, folder, resource_group_name) + version = f['version'] + data = { + "title": title, + "version": int(version) + } + response = _send_request(cmd, resource_group_name, grafana_name, "put", "/api/folders/" + f["uid"], data) + return json.loads(response.content) + + +def show_folder(cmd, grafana_name, folder, resource_group_name=None): + return _find_folder(cmd, resource_group_name, grafana_name, folder) + + +def delete_folder(cmd, grafana_name, folder, resource_group_name=None): + data = _find_folder(cmd, resource_group_name, grafana_name, folder) + _send_request(cmd, resource_group_name, grafana_name, "delete", "/api/folders/" + data['uid']) + + +def _find_folder(cmd, resource_group_name, grafana_name, folder): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/folders/id/" + folder, + raise_for_error_status=False) + if response.status_code >= 400 or not json.loads(response.content)['uid']: + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/folders/" + folder, + raise_for_error_status=False) + if response.status_code >= 400: + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/folders") + if response.status_code >= 400: + raise ArgumentUsageError(f"Could't find the folder '{folder}'. Ex: {response.status_code}") + result = json.loads(response.content) + result = [f for f in result if f["title"] == folder] + if len(result) == 0: + raise ArgumentUsageError(f"Could't find the folder '{folder}'. Ex: {response.status_code}") + if len(result) > 1: + raise ArgumentUsageError((f"More than one folder has the same title of '{folder}'. Please use other " + f"unique identifiers")) + return result[0] + + return json.loads(response.content) + + +def get_actual_user(cmd, grafana_name, resource_group_name=None): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/user") + return json.loads(response.content) + + +def list_users(cmd, grafana_name, resource_group_name=None): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/org/users") + return json.loads(response.content) + + +def show_user(cmd, grafana_name, user, resource_group_name=None): + users = list_users(cmd, grafana_name, resource_group_name=resource_group_name) + match = next((u for u in users if u['name'].lower() == user.lower()), None) + + if match: + return match + raise ArgumentUsageError(f"Could't find the user '{user}'") + + +def query_data_source(cmd, grafana_name, data_source, time_from=None, time_to=None, + max_data_points=100, internal_ms=1000, query_format=None, + conditions=None, resource_group_name=None): + import datetime + import time + from dateutil import parser + right_now = datetime.datetime.now() + + if time_from: + time_from = parser.parse(time_from) + else: + time_from = right_now - datetime.timedelta(hours=1) + time_from_epoch = str(time.mktime(time_from.timetuple()) * 1000) + + if time_to: + time_to = parser.parse(time_to) + else: + time_to = right_now + time_to_epoch = str(time.mktime(time_to.timetuple()) * 1000) + + data_source_id = _find_data_source(cmd, resource_group_name, grafana_name, data_source)["id"] + + data = { + "from": time_from_epoch, + "to": time_to_epoch, + "queries": [{ + "intervalMs": internal_ms, + "maxDataPoints": max_data_points, + "datasourceId": data_source_id, + "format": query_format or "time_series", + "refId": "A" + }] + } + + if conditions: + for c in conditions: + k, v = c.split("=", 1) + data["queries"][0][k] = v + + response = _send_request(cmd, resource_group_name, grafana_name, "post", "/api/ds/query", data) + return json.loads(response.content) + + +def _find_data_source(cmd, resource_group_name, grafana_name, data_source): + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/datasources/name/" + data_source, + raise_for_error_status=False) + if response.status_code >= 400: + response = _send_request(cmd, resource_group_name, grafana_name, "get", "/api/datasources/" + data_source, + raise_for_error_status=False) + if response.status_code >= 400: + response = _send_request(cmd, resource_group_name, grafana_name, + "get", "/api/datasources/uid/" + data_source, + raise_for_error_status=False) + if response.status_code >= 400: + raise ArgumentUsageError(f"Couldn't found data source {data_source}. Ex: {response.status_code}") + return json.loads(response.content) + + +# For UX: we accept a file path for complex payload such as dashboard/data-source definition +def _try_load_file_content(file_content): + import os + potentail_file_path = os.path.expanduser(file_content) + if os.path.exists(potentail_file_path): + from azure.cli.core.util import read_file_content + file_content = read_file_content(potentail_file_path) + return file_content + + +def _send_request(cmd, resource_group_name, grafana_name, http_method, path, body=None, raise_for_error_status=True): + endpoint = grafana_endpoints.get(grafana_name) + if not endpoint: + grafana = show_grafana(cmd, grafana_name, resource_group_name) + endpoint = grafana.properties.endpoint + grafana_endpoints[grafana_name] = endpoint + + from azure.cli.core._profile import Profile + profile = Profile(cli_ctx=cmd.cli_ctx) + # this might be a cross tenant scenario, so pass subscription to get_raw_token + subscription = get_subscription_id(cmd.cli_ctx) + amg_first_party_app = ("7f525cdc-1f08-4afa-af7c-84709d42f5d3" + if "-ppe." in cmd.cli_ctx.cloud.endpoints.active_directory + else "ce34e7e5-485f-4d76-964f-b3d2b16d1e4f") + creds, _, _ = profile.get_raw_token(subscription=subscription, + resource=amg_first_party_app) + + headers = { + "content-type": "application/json", + "authorization": "Bearer " + creds[1] + } + + # TODO: handle re-try on 429 + response = requests.request(http_method, + url=endpoint + path, + headers=headers, + json=body, + timeout=60, + verify=(not should_disable_connection_verify())) + if response.status_code >= 400: + if raise_for_error_status: + logger.warning(str(response.content)) + response.raise_for_status() + # TODO: log headers, requests and response + return response diff --git a/src/amg/azext_amg/tests/__init__.py b/src/amg/azext_amg/tests/__init__.py new file mode 100644 index 00000000000..2dcf9bb68b3 --- /dev/null +++ b/src/amg/azext_amg/tests/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/amg/azext_amg/tests/latest/__init__.py b/src/amg/azext_amg/tests/latest/__init__.py new file mode 100644 index 00000000000..2dcf9bb68b3 --- /dev/null +++ b/src/amg/azext_amg/tests/latest/__init__.py @@ -0,0 +1,5 @@ +# ----------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# ----------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/amg/azext_amg/tests/latest/recordings/test_amg_e2e.yaml b/src/amg/azext_amg/tests/latest/recordings/test_amg_e2e.yaml new file mode 100644 index 00000000000..0c2582e8ac6 --- /dev/null +++ b/src/amg/azext_amg/tests/latest/recordings/test_amg_e2e.yaml @@ -0,0 +1,1303 @@ +interactions: +- request: + body: '{"location": "westeurope", "tags": {"foo": "doo"}, "sku": {"name": "standard"}, + "identity": {"type": "SystemAssigned"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","name":"clitestamg","type":"microsoft.dashboard/grafana","sku":{"name":"standard"},"location":"westeurope","tags":{"foo":"doo"},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-06T19:05:53.5783015Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-06T19:05:53.5783015Z"},"identity":{"principalId":"1112f52a-4439-44af-9ec2-7989874c0498","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Accepted","grafanaVersion":null,"endpoint":"https://clitestamg.weu.azgrafana.io","zoneRedundancy":"Disabled"}}' + headers: + api-supported-versions: + - 2021-09-01-preview + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + cache-control: + - no-cache + content-length: + - '790' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:05:56 GMT + etag: + - '"8f00739e-0000-0d00-0000-622506140000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + pragma: + - no-cache + request-context: + - appId=cid-v1:54fcb76e-7bac-4b3e-96f8-8868676d3826 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:06:26 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:06:57 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:07:27 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:07:57 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:08:27 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:08:57 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:09:29 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:09:59 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Accepted","startTime":"2022-03-06T19:05:56.1407573Z"}' + headers: + cache-control: + - no-cache + content-length: + - '504' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:10:29 GMT + etag: + - '"82005e6a-0000-0d00-0000-622506140000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"348cd2bc-114b-49f5-bf1d-9acb1eb76476*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Succeeded","startTime":"2022-03-06T19:05:56.1407573Z","endTime":"2022-03-06T19:10:38.0793744Z","error":{},"properties":null}' + headers: + cache-control: + - no-cache + content-length: + - '575' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:10:59 GMT + etag: + - '"8200a96d-0000-0d00-0000-6225072e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana create + Connection: + - keep-alive + ParameterSetName: + - -g -n -l --tags --skip-role-assignments + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","name":"clitestamg","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"westeurope","tags":{"foo":"doo"},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-06T19:05:53.5783015Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-06T19:05:53.5783015Z"},"identity":{"principalId":"1112f52a-4439-44af-9ec2-7989874c0498","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://clitestamg.weu.azgrafana.io","zoneRedundancy":"Disabled"}}' + headers: + cache-control: + - no-cache + content-length: + - '794' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:11:00 GMT + etag: + - '"8f0051a2-0000-0d00-0000-6225072e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana list + Connection: + - keep-alive + ParameterSetName: + - -g + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-mgmt-dashboard/1.0.0b1 Python/3.8.8 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana?api-version=2021-09-01-preview + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","name":"clitestamg","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"westeurope","tags":{"foo":"doo"},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-06T19:05:53.5783015Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-06T19:05:53.5783015Z"},"identity":{"principalId":"1112f52a-4439-44af-9ec2-7989874c0498","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://clitestamg.weu.azgrafana.io","zoneRedundancy":"Disabled"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '806' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:11:02 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-original-request-ids: + - f0d5c86c-28c9-418b-9387-e33f57984498 + - faf967bf-a804-400b-ab2e-c7173d24aa0a + - a7937dc1-2511-4272-bbc1-9e71e65da2e5 + - 17bb15fe-d548-4ea0-9b99-866bf8f2d3b0 + - 42e53806-1812-4704-8089-6cd88018f139 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-mgmt-dashboard/1.0.0b1 Python/3.8.8 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Dashboard/grafana?api-version=2021-09-01-preview + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/yugangw/providers/Microsoft.Dashboard/grafana/yugangweus2e","name":"yugangweus2e","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"eastus2euap","tags":{},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-04T03:45:10.1825533Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-04T03:45:10.1825533Z"},"identity":{"principalId":"f462ffcd-951a-4521-82b0-0cff25c5c18a","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://yugangweus2e.eus2e.azgrafana.io","zoneRedundancy":"Disabled"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/yugangw/providers/Microsoft.Dashboard/grafana/yugangwcus3","name":"yugangwcus3","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"centraluseuap","tags":{},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-02-26T04:13:32.6306926Z","lastModifiedBy":"ce34e7e5-485f-4d76-964f-b3d2b16d1e4f","lastModifiedByType":"Application","lastModifiedAt":"2022-02-26T04:17:52.2265322Z"},"identity":{"principalId":"a2bd0803-4837-42e5-a1b8-d63bfa4f6a90","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://yugangwcus3.cuse.azgrafana.io","zoneRedundancy":"Disabled"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","name":"clitestamg","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"westeurope","tags":{"foo":"doo"},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-06T19:05:53.5783015Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-06T19:05:53.5783015Z"},"identity":{"principalId":"1112f52a-4439-44af-9ec2-7989874c0498","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://clitestamg.weu.azgrafana.io","zoneRedundancy":"Disabled"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/yugangw/providers/Microsoft.Dashboard/grafana/yugangweus","name":"yugangweus","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"eastus","tags":{"doo":"foo"},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-06T18:29:10.4356225Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-06T18:29:10.4356225Z"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://yugangweus.eus.azgrafana.io","zoneRedundancy":"Disabled"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '3030' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:11:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-original-request-ids: + - f0472afa-d6bf-41be-891b-9bb0a7b50d13 + - 6040023f-5cdd-4c49-8bd6-ee2dcc37c1d1 + - 4ff9f9e4-803e-4e44-85b7-3b2aef5c0813 + - cc127ace-79ee-4663-ab05-63ddd2bebd63 + - 6707790a-1247-41f9-b964-abfc71a91c10 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana show + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-mgmt-dashboard/1.0.0b1 Python/3.8.8 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","name":"clitestamg","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"westeurope","tags":{"foo":"doo"},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-06T19:05:53.5783015Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-06T19:05:53.5783015Z"},"identity":{"principalId":"1112f52a-4439-44af-9ec2-7989874c0498","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://clitestamg.weu.azgrafana.io","zoneRedundancy":"Disabled"}}' + headers: + cache-control: + - no-cache + content-length: + - '794' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:11:04 GMT + etag: + - '"8f0051a2-0000-0d00-0000-6225072e0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg?api-version=2021-09-01-preview + response: + body: + string: 'null' + headers: + api-supported-versions: + - 2021-09-01-preview + azure-asyncoperation: + - https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + cache-control: + - no-cache + content-length: + - '4' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:11:06 GMT + etag: + - '"8f00c3a2-0000-0d00-0000-6225074a0000"' + expires: + - '-1' + location: + - https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + pragma: + - no-cache + request-context: + - appId=cid-v1:54fcb76e-7bac-4b3e-96f8-8868676d3826 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:11:36 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:12:06 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:12:36 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:13:06 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:13:37 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:14:07 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:14:37 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:15:07 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:15:37 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Deleting","startTime":"2022-03-06T19:11:05.8767667Z","error":{}}' + headers: + cache-control: + - no-cache + content-length: + - '515' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:16:07 GMT + etag: + - '"8200f06d-0000-0d00-0000-6225074b0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana delete + Connection: + - keep-alive + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-azure-mgmt-resource/20.0.0 Python/3.8.8 + (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97?api-version=2021-09-01-preview + response: + body: + string: '{"id":"/providers/Microsoft.Dashboard/locations/WESTEUROPE/operationStatuses/dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","name":"dc1f4407-4966-48c7-9ceb-425b17116e61*C607E3A5F1C17CECD2978FCB885153A785E95679378145314D9E4E43EAE14F97","resourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_amg000001/providers/Microsoft.Dashboard/grafana/clitestamg","status":"Succeeded","startTime":"2022-03-06T19:11:05.8767667Z","endTime":"2022-03-06T19:16:26.3790885Z","error":{},"properties":null}' + headers: + cache-control: + - no-cache + content-length: + - '575' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:16:37 GMT + etag: + - '"82002d71-0000-0d00-0000-6225088a0000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - grafana list + Connection: + - keep-alive + User-Agent: + - AZURECLI/2.33.0 (MSI) azsdk-python-mgmt-dashboard/1.0.0b1 Python/3.8.8 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Dashboard/grafana?api-version=2021-09-01-preview + response: + body: + string: '{"value":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/yugangw/providers/Microsoft.Dashboard/grafana/yugangweus2e","name":"yugangweus2e","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"eastus2euap","tags":{},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-04T03:45:10.1825533Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-04T03:45:10.1825533Z"},"identity":{"principalId":"f462ffcd-951a-4521-82b0-0cff25c5c18a","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://yugangweus2e.eus2e.azgrafana.io","zoneRedundancy":"Disabled"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/yugangw/providers/Microsoft.Dashboard/grafana/yugangwcus3","name":"yugangwcus3","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"centraluseuap","tags":{},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-02-26T04:13:32.6306926Z","lastModifiedBy":"ce34e7e5-485f-4d76-964f-b3d2b16d1e4f","lastModifiedByType":"Application","lastModifiedAt":"2022-02-26T04:17:52.2265322Z"},"identity":{"principalId":"a2bd0803-4837-42e5-a1b8-d63bfa4f6a90","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","type":"SystemAssigned"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://yugangwcus3.cuse.azgrafana.io","zoneRedundancy":"Disabled"}},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/yugangw/providers/Microsoft.Dashboard/grafana/yugangweus","name":"yugangweus","type":"microsoft.dashboard/grafana","sku":{"name":"Standard"},"location":"eastus","tags":{"doo":"foo"},"systemData":{"createdBy":"yugangw@microsoft.com","createdByType":"User","createdAt":"2022-03-06T18:29:10.4356225Z","lastModifiedBy":"yugangw@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-03-06T18:29:10.4356225Z"},"properties":{"provisioningState":"Succeeded","grafanaVersion":"8.4.1","endpoint":"https://yugangweus.eus.azgrafana.io","zoneRedundancy":"Disabled"}}]}' + headers: + cache-control: + - no-cache + content-length: + - '2235' + content-type: + - application/json; charset=utf-8 + date: + - Sun, 06 Mar 2022 19:16:39 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-original-request-ids: + - 391f4478-64fa-4311-8704-0350b9e18e2b + - ab52290e-ac8b-4be7-b377-7eda188afe4a + - 0d2d4deb-715c-45ca-9bc6-15be1e190b58 + - 31a5c63b-0536-484a-8dcc-1ce72fc82ca6 + - 80b9ac79-b98c-42d1-bba1-ba719e3c07af + status: + code: 200 + message: OK +version: 1 diff --git a/src/amg/azext_amg/tests/latest/test_amg_scenario.py b/src/amg/azext_amg/tests/latest/test_amg_scenario.py new file mode 100644 index 00000000000..bf9f603f27e --- /dev/null +++ b/src/amg/azext_amg/tests/latest/test_amg_scenario.py @@ -0,0 +1,39 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import unittest + +from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +class AgsScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_amg') + def test_amg_e2e(self, resource_group): + + self.kwargs.update({ + 'name': 'clitestamg', + 'location': 'westeurope' + }) + + self.cmd('grafana create -g {rg} -n {name} -l {location} --tags foo=doo --skip-role-assignments', checks=[ + self.check('tags.foo', 'doo'), + self.check('name', '{name}') + ]) + self.cmd('grafana list -g {rg}') + count = len(self.cmd('grafana list').get_output_in_json()) + self.cmd('grafana show -g {rg} -n {name}', checks=[ + self.check('name', '{name}'), + self.check('resourceGroup', '{rg}'), + self.check('tags.foo', 'doo') + ]) + + self.cmd('grafana delete -g {rg} -n {name} --yes') + final_count = len(self.cmd('grafana list').get_output_in_json()) + self.assertTrue(final_count, count - 1) \ No newline at end of file diff --git a/src/amg/azext_amg/vendored_sdks/__init__.py b/src/amg/azext_amg/vendored_sdks/__init__.py new file mode 100644 index 00000000000..df8a6cb70ab --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/__init__.py @@ -0,0 +1,18 @@ +# 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 ._dashboard_management_client import DashboardManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['DashboardManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/src/amg/azext_amg/vendored_sdks/_configuration.py b/src/amg/azext_amg/vendored_sdks/_configuration.py new file mode 100644 index 00000000000..08abd2ffed1 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/_configuration.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class DashboardManagementClientConfiguration(Configuration): + """Configuration for DashboardManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DashboardManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-09-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dashboard/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/amg/azext_amg/vendored_sdks/_dashboard_management_client.py b/src/amg/azext_amg/vendored_sdks/_dashboard_management_client.py new file mode 100644 index 00000000000..4401d7f476b --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/_dashboard_management_client.py @@ -0,0 +1,97 @@ +# 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 copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import DashboardManagementClientConfiguration +from .operations import GrafanaOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class DashboardManagementClient: + """The Microsoft.Dashboard Rest API spec. + + :ivar operations: Operations operations + :vartype operations: dashboard_management_client.operations.Operations + :ivar grafana: GrafanaOperations operations + :vartype grafana: dashboard_management_client.operations.GrafanaOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is ''. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "", + **kwargs: Any + ) -> None: + self._config = DashboardManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **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._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.grafana = GrafanaOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> DashboardManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/amg/azext_amg/vendored_sdks/_patch.py b/src/amg/azext_amg/vendored_sdks/_patch.py new file mode 100644 index 00000000000..74e48ecd07c --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/src/amg/azext_amg/vendored_sdks/_vendor.py b/src/amg/azext_amg/vendored_sdks/_vendor.py new file mode 100644 index 00000000000..138f663c53a --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/src/amg/azext_amg/vendored_sdks/_version.py b/src/amg/azext_amg/vendored_sdks/_version.py new file mode 100644 index 00000000000..e5754a47ce6 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/src/amg/azext_amg/vendored_sdks/aio/__init__.py b/src/amg/azext_amg/vendored_sdks/aio/__init__.py new file mode 100644 index 00000000000..30cf3e032d9 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/aio/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._dashboard_management_client import DashboardManagementClient +__all__ = ['DashboardManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/src/amg/azext_amg/vendored_sdks/aio/_configuration.py b/src/amg/azext_amg/vendored_sdks/aio/_configuration.py new file mode 100644 index 00000000000..c8c1228bcc4 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class DashboardManagementClientConfiguration(Configuration): + """Configuration for DashboardManagementClient. + + 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_async.AsyncTokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(DashboardManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-09-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-dashboard/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/amg/azext_amg/vendored_sdks/aio/_dashboard_management_client.py b/src/amg/azext_amg/vendored_sdks/aio/_dashboard_management_client.py new file mode 100644 index 00000000000..63d918012b1 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/aio/_dashboard_management_client.py @@ -0,0 +1,94 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import DashboardManagementClientConfiguration +from .operations import GrafanaOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class DashboardManagementClient: + """The Microsoft.Dashboard Rest API spec. + + :ivar operations: Operations operations + :vartype operations: dashboard_management_client.aio.operations.Operations + :ivar grafana: GrafanaOperations operations + :vartype grafana: dashboard_management_client.aio.operations.GrafanaOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is ''. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "", + **kwargs: Any + ) -> None: + self._config = DashboardManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **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._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.grafana = GrafanaOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "DashboardManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/amg/azext_amg/vendored_sdks/aio/_patch.py b/src/amg/azext_amg/vendored_sdks/aio/_patch.py new file mode 100644 index 00000000000..74e48ecd07c --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/src/amg/azext_amg/vendored_sdks/aio/operations/__init__.py b/src/amg/azext_amg/vendored_sdks/aio/operations/__init__.py new file mode 100644 index 00000000000..81c85b3399f --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._grafana_operations import GrafanaOperations + +__all__ = [ + 'Operations', + 'GrafanaOperations', +] diff --git a/src/amg/azext_amg/vendored_sdks/aio/operations/_grafana_operations.py b/src/amg/azext_amg/vendored_sdks/aio/operations/_grafana_operations.py new file mode 100644 index 00000000000..e6f4512da87 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/aio/operations/_grafana_operations.py @@ -0,0 +1,534 @@ +# 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 functools +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._grafana_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GrafanaOperations: + """GrafanaOperations 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: ~dashboard_management_client.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 + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.GrafanaResourceListResponse"]: + """List all resources of workspaces for Grafana under the specified subscription. + + List all resources of workspaces for Grafana under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GrafanaResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dashboard_management_client.models.GrafanaResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GrafanaResourceListResponse", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.GrafanaResourceListResponse"]: + """List all resources of workspaces for Grafana under the specified resource group. + + List all resources of workspaces for Grafana under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 GrafanaResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dashboard_management_client.models.GrafanaResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GrafanaResourceListResponse", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + 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.Dashboard/grafana'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> "_models.GrafanaResource": + """Get the properties of a specific workspace for Grafana resource. + + Get the properties of a specific workspace for Grafana resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GrafanaResource, or the result of cls(response) + :rtype: ~dashboard_management_client.models.GrafanaResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + async def _create_initial( + self, + resource_group_name: str, + workspace_name: str, + body: Optional["_models.GrafanaResource"] = None, + **kwargs: Any + ) -> "_models.GrafanaResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'GrafanaResource') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + workspace_name: str, + body: Optional["_models.GrafanaResource"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.GrafanaResource"]: + """Create or update a workspace for Grafana resource. This API is idempotent, so user can either + create a new grafana or update an existing grafana. + + Create or update a workspace for Grafana resource. This API is idempotent, so user can either + create a new grafana or update an existing grafana. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :param body: + :type body: ~dashboard_management_client.models.GrafanaResource + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GrafanaResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~dashboard_management_client.models.GrafanaResource] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('GrafanaResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + workspace_name: str, + body: Optional["_models.GrafanaResourceUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.GrafanaResource": + """Update a workspace for Grafana resource. + + Update a workspace for Grafana resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :param body: + :type body: ~dashboard_management_client.models.GrafanaResourceUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GrafanaResource, or the result of cls(response) + :rtype: ~dashboard_management_client.models.GrafanaResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'GrafanaResourceUpdateParameters') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + async def _delete_initial( + self, + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a workspace for Grafana resource. + + Delete a workspace for Grafana resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore diff --git a/src/amg/azext_amg/vendored_sdks/aio/operations/_operations.py b/src/amg/azext_amg/vendored_sdks/aio/operations/_operations.py new file mode 100644 index 00000000000..91559e425d8 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/aio/operations/_operations.py @@ -0,0 +1,112 @@ +# 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 functools +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations 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: ~dashboard_management_client.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 + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """List all available API operations provided by Microsoft.Dashboard. + + List all available API operations provided by Microsoft.Dashboard. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~dashboard_management_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Dashboard/operations'} # type: ignore diff --git a/src/amg/azext_amg/vendored_sdks/models/__init__.py b/src/amg/azext_amg/vendored_sdks/models/__init__.py new file mode 100644 index 00000000000..f79c863e098 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/models/__init__.py @@ -0,0 +1,57 @@ +# 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 ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GrafanaResource +from ._models_py3 import GrafanaResourceListResponse +from ._models_py3 import GrafanaResourceProperties +from ._models_py3 import GrafanaResourceUpdateParameters +from ._models_py3 import ManagedIdentity +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationResult +from ._models_py3 import ResourceSku +from ._models_py3 import SystemData +from ._models_py3 import UserAssignedIdentity + + +from ._dashboard_management_client_enums import ( + ActionType, + CreatedByType, + IdentityType, + LastModifiedByType, + Origin, + ProvisioningState, + ZoneRedundancy, +) + +__all__ = [ + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'GrafanaResource', + 'GrafanaResourceListResponse', + 'GrafanaResourceProperties', + 'GrafanaResourceUpdateParameters', + 'ManagedIdentity', + 'OperationDisplay', + 'OperationListResult', + 'OperationResult', + 'ResourceSku', + 'SystemData', + 'UserAssignedIdentity', + 'ActionType', + 'CreatedByType', + 'IdentityType', + 'LastModifiedByType', + 'Origin', + 'ProvisioningState', + 'ZoneRedundancy', +] diff --git a/src/amg/azext_amg/vendored_sdks/models/_dashboard_management_client_enums.py b/src/amg/azext_amg/vendored_sdks/models/_dashboard_management_client_enums.py new file mode 100644 index 00000000000..bd3a3641b2d --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/models/_dashboard_management_client_enums.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set + of user assigned identities. The type 'None' will remove any identities from the resource. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + +class LastModifiedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation. + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + ACCEPTED = "Accepted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + DELETED = "Deleted" + NOT_SPECIFIED = "NotSpecified" + +class ZoneRedundancy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + DISABLED = "Disabled" + ENABLED = "Enabled" diff --git a/src/amg/azext_amg/vendored_sdks/models/_models_py3.py b/src/amg/azext_amg/vendored_sdks/models/_models_py3.py new file mode 100644 index 00000000000..0b72d973be7 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/models/_models_py3.py @@ -0,0 +1,623 @@ +# 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 datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._dashboard_management_client_enums import * + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~dashboard_management_client.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~dashboard_management_client.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~dashboard_management_client.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~dashboard_management_client.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class GrafanaResource(msrest.serialization.Model): + """The grafana resource type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: ARM id of the grafana resource. + :vartype id: str + :ivar name: Name of the grafana resource. + :vartype name: str + :ivar type: The type of the grafana resource. + :vartype type: str + :ivar sku: The Sku of the grafana resource. + :vartype sku: ~dashboard_management_client.models.ResourceSku + :ivar properties: Properties specific to the grafana resource. + :vartype properties: ~dashboard_management_client.models.GrafanaResourceProperties + :ivar identity: The managed identity of the grafana resource. + :vartype identity: ~dashboard_management_client.models.ManagedIdentity + :ivar system_data: The system meta data relating to this grafana resource. + :vartype system_data: ~dashboard_management_client.models.SystemData + :ivar tags: A set of tags. The tags for grafana resource. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the grafana resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'ResourceSku'}, + 'properties': {'key': 'properties', 'type': 'GrafanaResourceProperties'}, + 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + sku: Optional["ResourceSku"] = None, + properties: Optional["GrafanaResourceProperties"] = None, + identity: Optional["ManagedIdentity"] = None, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword sku: The Sku of the grafana resource. + :paramtype sku: ~dashboard_management_client.models.ResourceSku + :keyword properties: Properties specific to the grafana resource. + :paramtype properties: ~dashboard_management_client.models.GrafanaResourceProperties + :keyword identity: The managed identity of the grafana resource. + :paramtype identity: ~dashboard_management_client.models.ManagedIdentity + :keyword tags: A set of tags. The tags for grafana resource. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the grafana resource lives. + :paramtype location: str + """ + super(GrafanaResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.sku = sku + self.properties = properties + self.identity = identity + self.system_data = None + self.tags = tags + self.location = location + + +class GrafanaResourceListResponse(msrest.serialization.Model): + """GrafanaResourceListResponse. + + :ivar value: + :vartype value: list[~dashboard_management_client.models.GrafanaResource] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GrafanaResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GrafanaResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: + :paramtype value: list[~dashboard_management_client.models.GrafanaResource] + :keyword next_link: + :paramtype next_link: str + """ + super(GrafanaResourceListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GrafanaResourceProperties(msrest.serialization.Model): + """Properties specific to the grafana resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: Provisioning state of the resource. Possible values include: + "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", + "NotSpecified". + :vartype provisioning_state: str or ~dashboard_management_client.models.ProvisioningState + :ivar grafana_version: The Grafana software version. + :vartype grafana_version: str + :ivar endpoint: The endpoint of the Grafana instance. + :vartype endpoint: str + :ivar zone_redundancy: Possible values include: "Disabled", "Enabled". Default value: + "Disabled". + :vartype zone_redundancy: str or ~dashboard_management_client.models.ZoneRedundancy + """ + + _validation = { + 'grafana_version': {'readonly': True}, + 'endpoint': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'grafana_version': {'key': 'grafanaVersion', 'type': 'str'}, + 'endpoint': {'key': 'endpoint', 'type': 'str'}, + 'zone_redundancy': {'key': 'zoneRedundancy', 'type': 'str'}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + zone_redundancy: Optional[Union[str, "ZoneRedundancy"]] = "Disabled", + **kwargs + ): + """ + :keyword provisioning_state: Provisioning state of the resource. Possible values include: + "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", + "NotSpecified". + :paramtype provisioning_state: str or ~dashboard_management_client.models.ProvisioningState + :keyword zone_redundancy: Possible values include: "Disabled", "Enabled". Default value: + "Disabled". + :paramtype zone_redundancy: str or ~dashboard_management_client.models.ZoneRedundancy + """ + super(GrafanaResourceProperties, self).__init__(**kwargs) + self.provisioning_state = provisioning_state + self.grafana_version = None + self.endpoint = None + self.zone_redundancy = zone_redundancy + + +class GrafanaResourceUpdateParameters(msrest.serialization.Model): + """The parameters for a PATCH request to a grafana resource. + + :ivar identity: The managed identity of the grafana resource. + :vartype identity: ~dashboard_management_client.models.ManagedIdentity + :ivar tags: A set of tags. The new tags of the grafana resource. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + identity: Optional["ManagedIdentity"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword identity: The managed identity of the grafana resource. + :paramtype identity: ~dashboard_management_client.models.ManagedIdentity + :keyword tags: A set of tags. The new tags of the grafana resource. + :paramtype tags: dict[str, str] + """ + super(GrafanaResourceUpdateParameters, self).__init__(**kwargs) + self.identity = identity + self.tags = tags + + +class ManagedIdentity(msrest.serialization.Model): + """The managed identity of a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type 'SystemAssigned, UserAssigned' includes both an implicitly created + identity and a set of user assigned identities. The type 'None' will remove any identities from + the resource. Possible values include: "None", "SystemAssigned". + :vartype type: str or ~dashboard_management_client.models.IdentityType + :ivar principal_id: The principal id of the system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant id of the system assigned identity. + :vartype tenant_id: str + :ivar user_assigned_identities: Dictionary of user assigned identities. + :vartype user_assigned_identities: dict[str, + ~dashboard_management_client.models.UserAssignedIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "IdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The type 'SystemAssigned, UserAssigned' includes both an implicitly created + identity and a set of user assigned identities. The type 'None' will remove any identities from + the resource. Possible values include: "None", "SystemAssigned". + :paramtype type: str or ~dashboard_management_client.models.IdentityType + :keyword user_assigned_identities: Dictionary of user assigned identities. + :paramtype user_assigned_identities: dict[str, + ~dashboard_management_client.models.UserAssignedIdentity] + """ + super(ManagedIdentity, self).__init__(**kwargs) + self.type = type + self.principal_id = None + self.tenant_id = None + self.user_assigned_identities = user_assigned_identities + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, i.e., + Microsoft.Dashboard. + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation, + e.g., 'grafana'. + :vartype resource: str + :ivar operation: Operation type, e.g., read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation, e.g., 'Read grafana'. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by Microsoft.Dashboard provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the Microsoft.Dashboard provider. + :vartype value: list[~dashboard_management_client.models.OperationResult] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationResult(msrest.serialization.Model): + """A Microsoft.Dashboard REST API operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Operation name, i.e., {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation applies to data-plane. Set "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~dashboard_management_client.models.OperationDisplay + :ivar origin: The intended executor of the operation. Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~dashboard_management_client.models.Origin + :ivar action_type: Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~dashboard_management_client.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~dashboard_management_client.models.OperationDisplay + """ + super(OperationResult, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class ResourceSku(msrest.serialization.Model): + """ResourceSku. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. + :vartype name: str + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + """ + :keyword name: Required. + :paramtype name: str + """ + super(ResourceSku, self).__init__(**kwargs) + self.name = name + + +class SystemData(msrest.serialization.Model): + """SystemData. + + :ivar created_by: + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~dashboard_management_client.models.CreatedByType + :ivar created_at: + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: + :vartype last_modified_by: str + :ivar last_modified_by_type: Possible values include: "User", "Application", "ManagedIdentity", + "Key". + :vartype last_modified_by_type: str or ~dashboard_management_client.models.LastModifiedByType + :ivar last_modified_at: + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "LastModifiedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~dashboard_management_client.models.CreatedByType + :keyword created_at: + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: + :paramtype last_modified_by: str + :keyword last_modified_by_type: Possible values include: "User", "Application", + "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~dashboard_management_client.models.LastModifiedByType + :keyword last_modified_at: + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class UserAssignedIdentity(msrest.serialization.Model): + """UserAssignedIdentity. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedIdentity, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/src/amg/azext_amg/vendored_sdks/operations/__init__.py b/src/amg/azext_amg/vendored_sdks/operations/__init__.py new file mode 100644 index 00000000000..81c85b3399f --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/operations/__init__.py @@ -0,0 +1,15 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._grafana_operations import GrafanaOperations + +__all__ = [ + 'Operations', + 'GrafanaOperations', +] diff --git a/src/amg/azext_amg/vendored_sdks/operations/_grafana_operations.py b/src/amg/azext_amg/vendored_sdks/operations/_grafana_operations.py new file mode 100644 index 00000000000..ca5fa25aaf3 --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/operations/_grafana_operations.py @@ -0,0 +1,758 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + workspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + workspace_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + workspace_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + workspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', min_length=1), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class GrafanaOperations(object): + """GrafanaOperations 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: ~dashboard_management_client.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 + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.GrafanaResourceListResponse"]: + """List all resources of workspaces for Grafana under the specified subscription. + + List all resources of workspaces for Grafana under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GrafanaResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dashboard_management_client.models.GrafanaResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GrafanaResourceListResponse", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Dashboard/grafana'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.GrafanaResourceListResponse"]: + """List all resources of workspaces for Grafana under the specified resource group. + + List all resources of workspaces for Grafana under the specified resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :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 GrafanaResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~dashboard_management_client.models.GrafanaResourceListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResourceListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GrafanaResourceListResponse", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + 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.Dashboard/grafana'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> "_models.GrafanaResource": + """Get the properties of a specific workspace for Grafana resource. + + Get the properties of a specific workspace for Grafana resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GrafanaResource, or the result of cls(response) + :rtype: ~dashboard_management_client.models.GrafanaResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + def _create_initial( + self, + resource_group_name: str, + workspace_name: str, + body: Optional["_models.GrafanaResource"] = None, + **kwargs: Any + ) -> "_models.GrafanaResource": + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'GrafanaResource') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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 HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + workspace_name: str, + body: Optional["_models.GrafanaResource"] = None, + **kwargs: Any + ) -> LROPoller["_models.GrafanaResource"]: + """Create or update a workspace for Grafana resource. This API is idempotent, so user can either + create a new grafana or update an existing grafana. + + Create or update a workspace for Grafana resource. This API is idempotent, so user can either + create a new grafana or update an existing grafana. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :param body: + :type body: ~dashboard_management_client.models.GrafanaResource + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GrafanaResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~dashboard_management_client.models.GrafanaResource] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + body=body, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('GrafanaResource', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + @distributed_trace + def update( + self, + resource_group_name: str, + workspace_name: str, + body: Optional["_models.GrafanaResourceUpdateParameters"] = None, + **kwargs: Any + ) -> "_models.GrafanaResource": + """Update a workspace for Grafana resource. + + Update a workspace for Grafana resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :param body: + :type body: ~dashboard_management_client.models.GrafanaResourceUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GrafanaResource, or the result of cls(response) + :rtype: ~dashboard_management_client.models.GrafanaResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GrafanaResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + _json = self._serialize.body(body, 'GrafanaResourceUpdateParameters') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GrafanaResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + def _delete_initial( + self, + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + workspace_name=workspace_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a workspace for Grafana resource. + + Delete a workspace for Grafana resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param workspace_name: The name of Azure Managed Workspace for Grafana. + :type workspace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + workspace_name=workspace_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Dashboard/grafana/{workspaceName}'} # type: ignore diff --git a/src/amg/azext_amg/vendored_sdks/operations/_operations.py b/src/amg/azext_amg/vendored_sdks/operations/_operations.py new file mode 100644 index 00000000000..9102d9ad46f --- /dev/null +++ b/src/amg/azext_amg/vendored_sdks/operations/_operations.py @@ -0,0 +1,137 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Dashboard/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +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: ~dashboard_management_client.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 + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """List all available API operations provided by Microsoft.Dashboard. + + List all available API operations provided by Microsoft.Dashboard. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~dashboard_management_client.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Dashboard/operations'} # type: ignore diff --git a/src/amg/dist/amg-0.1.0-py3-none-any.whl b/src/amg/dist/amg-0.1.0-py3-none-any.whl new file mode 100644 index 00000000000..221243c3a78 Binary files /dev/null and b/src/amg/dist/amg-0.1.0-py3-none-any.whl differ diff --git a/src/amg/setup.cfg b/src/amg/setup.cfg new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/amg/setup.py b/src/amg/setup.py new file mode 100644 index 00000000000..fd6c7c34872 --- /dev/null +++ b/src/amg/setup.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='amg', + version=VERSION, + description='Microsoft Azure Command-Line Tools Azure Managed Grafana Extension', + author='Microsoft Corporation', + author_email='ad4g@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/amg', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_amg': ['azext_metadata.json']}, +) diff --git a/src/service_name.json b/src/service_name.json index 86789b14ed9..e8ab509ca95 100644 --- a/src/service_name.json +++ b/src/service_name.json @@ -569,7 +569,12 @@ "AzureServiceName": "Azure Stack HCI", "URL": "https://docs.microsoft.com/en-us/cli/azure/azurestackhci?view=azure-cli-latest" }, - { + { + "Command": "az grafana", + "AzureServiceName": "Azure Managed Grafana", + "URL": "" + }, + { "Command": "az quota", "AzureServiceName": "Reserved VM Instances", "URL": "https://docs.microsoft.com/en-us/rest/api/reserved-vm-instances/quotaapi"