From be30d783b80ff4fb900a8a7ccf592b25667a0482 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 10 Mar 2022 03:35:15 +0000 Subject: [PATCH] CodeGen from PR 17923 in Azure/azure-rest-api-specs Merge 7d1b7dc08e4dbb1a9e8d569ee29ed59e5731757c into 791255f0c5dd775015cd51f3e642549190fb3803 --- .../azure-mgmt-loganalytics/_meta.json | 4 +- .../_log_analytics_management_client.py | 32 +- .../azure/mgmt/loganalytics/_metadata.json | 14 +- .../azure/mgmt/loganalytics/_version.py | 2 +- .../aio/_log_analytics_management_client.py | 32 +- .../loganalytics/aio/operations/__init__.py | 20 +- .../aio/operations/_queries_operations.py | 483 +++++++++++ .../aio/operations/_query_packs_operations.py | 406 ++++++++++ .../mgmt/loganalytics/models/__init__.py | 22 + .../_log_analytics_management_client_enums.py | 6 +- .../mgmt/loganalytics/models/_models_py3.py | 572 ++++++++++++- .../mgmt/loganalytics/operations/__init__.py | 20 +- .../operations/_queries_operations.py | 749 ++++++++++++++++++ .../operations/_query_packs_operations.py | 630 +++++++++++++++ 14 files changed, 2931 insertions(+), 61 deletions(-) create mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py create mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py create mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py create mode 100644 sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json b/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json index 8c13adfd1daa..ada7cad155b9 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json +++ b/sdk/loganalytics/azure-mgmt-loganalytics/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.12.0", "@autorest/modelerfour@4.19.3" ], - "commit": "24b1f9ed9a0768a55b14cced1761a40f7c12b6d2", + "commit": "651ef3152ad598119c7c6ba4f3a7d303f643b9bf", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/operationalinsights/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/operationalinsights/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/operationalinsights/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py index 5717dd1dc590..fc8c3e8d04a4 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_log_analytics_management_client.py @@ -15,7 +15,7 @@ from . import models from ._configuration import LogAnalyticsManagementClientConfiguration -from .operations import AvailableServiceTiersOperations, ClustersOperations, DataExportsOperations, DataSourcesOperations, DeletedWorkspacesOperations, GatewaysOperations, IntelligencePacksOperations, LinkedServicesOperations, LinkedStorageAccountsOperations, ManagementGroupsOperations, OperationStatusesOperations, Operations, SavedSearchesOperations, SchemaOperations, SharedKeysOperations, StorageInsightConfigsOperations, TablesOperations, UsagesOperations, WorkspacePurgeOperations, WorkspacesOperations +from .operations import AvailableServiceTiersOperations, ClustersOperations, DataExportsOperations, DataSourcesOperations, DeletedWorkspacesOperations, GatewaysOperations, IntelligencePacksOperations, LinkedServicesOperations, LinkedStorageAccountsOperations, ManagementGroupsOperations, OperationStatusesOperations, Operations, QueriesOperations, QueryPacksOperations, SavedSearchesOperations, SchemaOperations, SharedKeysOperations, StorageInsightConfigsOperations, TablesOperations, UsagesOperations, WorkspacePurgeOperations, WorkspacesOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -24,14 +24,10 @@ class LogAnalyticsManagementClient: """Operational Insights Client. - :ivar operations: Operations operations - :vartype operations: azure.mgmt.loganalytics.operations.Operations - :ivar workspaces: WorkspacesOperations operations - :vartype workspaces: azure.mgmt.loganalytics.operations.WorkspacesOperations - :ivar deleted_workspaces: DeletedWorkspacesOperations operations - :vartype deleted_workspaces: azure.mgmt.loganalytics.operations.DeletedWorkspacesOperations - :ivar tables: TablesOperations operations - :vartype tables: azure.mgmt.loganalytics.operations.TablesOperations + :ivar query_packs: QueryPacksOperations operations + :vartype query_packs: azure.mgmt.loganalytics.operations.QueryPacksOperations + :ivar queries: QueriesOperations operations + :vartype queries: azure.mgmt.loganalytics.operations.QueriesOperations :ivar data_exports: DataExportsOperations operations :vartype data_exports: azure.mgmt.loganalytics.operations.DataExportsOperations :ivar data_sources: DataSourcesOperations operations @@ -67,6 +63,14 @@ class LogAnalyticsManagementClient: :vartype workspace_purge: azure.mgmt.loganalytics.operations.WorkspacePurgeOperations :ivar clusters: ClustersOperations operations :vartype clusters: azure.mgmt.loganalytics.operations.ClustersOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.loganalytics.operations.Operations + :ivar workspaces: WorkspacesOperations operations + :vartype workspaces: azure.mgmt.loganalytics.operations.WorkspacesOperations + :ivar deleted_workspaces: DeletedWorkspacesOperations operations + :vartype deleted_workspaces: azure.mgmt.loganalytics.operations.DeletedWorkspacesOperations + :ivar tables: TablesOperations operations + :vartype tables: azure.mgmt.loganalytics.operations.TablesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. @@ -91,10 +95,8 @@ def __init__( 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.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_workspaces = DeletedWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.tables = TablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.query_packs = QueryPacksOperations(self._client, self._config, self._serialize, self._deserialize) + self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) self.data_exports = DataExportsOperations(self._client, self._config, self._serialize, self._deserialize) self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.intelligence_packs = IntelligencePacksOperations(self._client, self._config, self._serialize, self._deserialize) @@ -111,6 +113,10 @@ def __init__( self.schema = SchemaOperations(self._client, self._config, self._serialize, self._deserialize) self.workspace_purge = WorkspacePurgeOperations(self._client, self._config, self._serialize, self._deserialize) self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_workspaces = DeletedWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tables = TablesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request( diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json index 964622710cbe..0d6a20f7de89 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_metadata.json @@ -1,6 +1,6 @@ { "chosen_version": "", - "total_api_version_list": ["2020-08-01", "2021-06-01", "2021-12-01-preview"], + "total_api_version_list": ["2019-09-01", "2020-08-01", "2021-06-01", "2021-12-01-preview"], "client": { "name": "LogAnalyticsManagementClient", "filename": "_log_analytics_management_client", @@ -97,10 +97,8 @@ "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { - "operations": "Operations", - "workspaces": "WorkspacesOperations", - "deleted_workspaces": "DeletedWorkspacesOperations", - "tables": "TablesOperations", + "query_packs": "QueryPacksOperations", + "queries": "QueriesOperations", "data_exports": "DataExportsOperations", "data_sources": "DataSourcesOperations", "intelligence_packs": "IntelligencePacksOperations", @@ -116,6 +114,10 @@ "gateways": "GatewaysOperations", "schema": "SchemaOperations", "workspace_purge": "WorkspacePurgeOperations", - "clusters": "ClustersOperations" + "clusters": "ClustersOperations", + "operations": "Operations", + "workspaces": "WorkspacesOperations", + "deleted_workspaces": "DeletedWorkspacesOperations", + "tables": "TablesOperations" } } \ No newline at end of file diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py index 28cf8b467ac5..efe7276fe05f 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.0.0b2" +VERSION = "7.0.0b1" diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py index 6256f9c72c32..d0bea923329e 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/_log_analytics_management_client.py @@ -15,7 +15,7 @@ from .. import models from ._configuration import LogAnalyticsManagementClientConfiguration -from .operations import AvailableServiceTiersOperations, ClustersOperations, DataExportsOperations, DataSourcesOperations, DeletedWorkspacesOperations, GatewaysOperations, IntelligencePacksOperations, LinkedServicesOperations, LinkedStorageAccountsOperations, ManagementGroupsOperations, OperationStatusesOperations, Operations, SavedSearchesOperations, SchemaOperations, SharedKeysOperations, StorageInsightConfigsOperations, TablesOperations, UsagesOperations, WorkspacePurgeOperations, WorkspacesOperations +from .operations import AvailableServiceTiersOperations, ClustersOperations, DataExportsOperations, DataSourcesOperations, DeletedWorkspacesOperations, GatewaysOperations, IntelligencePacksOperations, LinkedServicesOperations, LinkedStorageAccountsOperations, ManagementGroupsOperations, OperationStatusesOperations, Operations, QueriesOperations, QueryPacksOperations, SavedSearchesOperations, SchemaOperations, SharedKeysOperations, StorageInsightConfigsOperations, TablesOperations, UsagesOperations, WorkspacePurgeOperations, WorkspacesOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -24,14 +24,10 @@ class LogAnalyticsManagementClient: """Operational Insights Client. - :ivar operations: Operations operations - :vartype operations: azure.mgmt.loganalytics.aio.operations.Operations - :ivar workspaces: WorkspacesOperations operations - :vartype workspaces: azure.mgmt.loganalytics.aio.operations.WorkspacesOperations - :ivar deleted_workspaces: DeletedWorkspacesOperations operations - :vartype deleted_workspaces: azure.mgmt.loganalytics.aio.operations.DeletedWorkspacesOperations - :ivar tables: TablesOperations operations - :vartype tables: azure.mgmt.loganalytics.aio.operations.TablesOperations + :ivar query_packs: QueryPacksOperations operations + :vartype query_packs: azure.mgmt.loganalytics.aio.operations.QueryPacksOperations + :ivar queries: QueriesOperations operations + :vartype queries: azure.mgmt.loganalytics.aio.operations.QueriesOperations :ivar data_exports: DataExportsOperations operations :vartype data_exports: azure.mgmt.loganalytics.aio.operations.DataExportsOperations :ivar data_sources: DataSourcesOperations operations @@ -67,6 +63,14 @@ class LogAnalyticsManagementClient: :vartype workspace_purge: azure.mgmt.loganalytics.aio.operations.WorkspacePurgeOperations :ivar clusters: ClustersOperations operations :vartype clusters: azure.mgmt.loganalytics.aio.operations.ClustersOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.loganalytics.aio.operations.Operations + :ivar workspaces: WorkspacesOperations operations + :vartype workspaces: azure.mgmt.loganalytics.aio.operations.WorkspacesOperations + :ivar deleted_workspaces: DeletedWorkspacesOperations operations + :vartype deleted_workspaces: azure.mgmt.loganalytics.aio.operations.DeletedWorkspacesOperations + :ivar tables: TablesOperations operations + :vartype tables: azure.mgmt.loganalytics.aio.operations.TablesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. @@ -91,10 +95,8 @@ def __init__( 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.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_workspaces = DeletedWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.tables = TablesOperations(self._client, self._config, self._serialize, self._deserialize) + self.query_packs = QueryPacksOperations(self._client, self._config, self._serialize, self._deserialize) + self.queries = QueriesOperations(self._client, self._config, self._serialize, self._deserialize) self.data_exports = DataExportsOperations(self._client, self._config, self._serialize, self._deserialize) self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize) self.intelligence_packs = IntelligencePacksOperations(self._client, self._config, self._serialize, self._deserialize) @@ -111,6 +113,10 @@ def __init__( self.schema = SchemaOperations(self._client, self._config, self._serialize, self._deserialize) self.workspace_purge = WorkspacePurgeOperations(self._client, self._config, self._serialize, self._deserialize) self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_workspaces = DeletedWorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.tables = TablesOperations(self._client, self._config, self._serialize, self._deserialize) def _send_request( diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py index 479da079c9c5..72e307c7d6e6 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/__init__.py @@ -6,10 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._operations import Operations -from ._workspaces_operations import WorkspacesOperations -from ._deleted_workspaces_operations import DeletedWorkspacesOperations -from ._tables_operations import TablesOperations +from ._query_packs_operations import QueryPacksOperations +from ._queries_operations import QueriesOperations from ._data_exports_operations import DataExportsOperations from ._data_sources_operations import DataSourcesOperations from ._intelligence_packs_operations import IntelligencePacksOperations @@ -26,12 +24,14 @@ from ._schema_operations import SchemaOperations from ._workspace_purge_operations import WorkspacePurgeOperations from ._clusters_operations import ClustersOperations +from ._operations import Operations +from ._workspaces_operations import WorkspacesOperations +from ._deleted_workspaces_operations import DeletedWorkspacesOperations +from ._tables_operations import TablesOperations __all__ = [ - 'Operations', - 'WorkspacesOperations', - 'DeletedWorkspacesOperations', - 'TablesOperations', + 'QueryPacksOperations', + 'QueriesOperations', 'DataExportsOperations', 'DataSourcesOperations', 'IntelligencePacksOperations', @@ -48,4 +48,8 @@ 'SchemaOperations', 'WorkspacePurgeOperations', 'ClustersOperations', + 'Operations', + 'WorkspacesOperations', + 'DeletedWorkspacesOperations', + 'TablesOperations', ] diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py new file mode 100644 index 000000000000..03ebb04d26ed --- /dev/null +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_queries_operations.py @@ -0,0 +1,483 @@ +# 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._queries_operations import build_delete_request, build_get_request, build_list_request, build_put_request, build_search_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class QueriesOperations: + """QueriesOperations 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: ~azure.mgmt.loganalytics.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, + resource_group_name: str, + query_pack_name: str, + top: Optional[int] = None, + include_body: Optional[bool] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LogAnalyticsQueryPackQueryListResult"]: + """Gets a list of Queries defined within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param top: Maximum items returned in page. + :type top: long + :param include_body: Flag indicating whether or not to return the body of each applicable + query. If false, only return the query information. + :type include_body: bool + :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] + 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, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + top=top, + include_body=include_body, + skip_token=skip_token, + 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, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + top=top, + include_body=include_body, + skip_token=skip_token, + 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("LogAnalyticsQueryPackQueryListResult", 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries'} # type: ignore + + @distributed_trace + def search( + self, + resource_group_name: str, + query_pack_name: str, + query_search_properties: "_models.LogAnalyticsQueryPackQuerySearchProperties", + top: Optional[int] = None, + include_body: Optional[bool] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.LogAnalyticsQueryPackQueryListResult"]: + """Search a list of Queries defined within a Log Analytics QueryPack according to given search + properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param query_search_properties: Properties by which to search queries in the given Log + Analytics QueryPack. + :type query_search_properties: + ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuerySearchProperties + :param top: Maximum items returned in page. + :type top: long + :param include_body: Flag indicating whether or not to return the body of each applicable + query. If false, only return the query information. + :type include_body: bool + :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] + 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: + _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') + + request = build_search_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + top=top, + include_body=include_body, + skip_token=skip_token, + template_url=self.search.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') + + request = build_search_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + top=top, + include_body=include_body, + skip_token=skip_token, + 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("LogAnalyticsQueryPackQueryListResult", 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 + ) + search.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPackQuery": + """Gets a specific Log Analytics Query defined within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPackQuery, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] + 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, + query_pack_name=query_pack_name, + id=id, + 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('LogAnalyticsQueryPackQuery', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + query_payload: "_models.LogAnalyticsQueryPackQuery", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPackQuery": + """Adds or Updates a specific Query within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :param query_payload: Properties that need to be specified to create a new query and add it to + a Log Analytics QueryPack. + :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPackQuery, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] + 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] + + _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') + + request = build_put_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + id=id, + content_type=content_type, + json=_json, + template_url=self.put.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('LogAnalyticsQueryPackQuery', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + query_payload: "_models.LogAnalyticsQueryPackQuery", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPackQuery": + """Adds or Updates a specific Query within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :param query_payload: Properties that need to be specified to create a new query and add it to + a Log Analytics QueryPack. + :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPackQuery, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] + 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] + + _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + id=id, + 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('LogAnalyticsQueryPackQuery', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + **kwargs: Any + ) -> None: + """Deletes a specific Query defined within an Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + id=id, + template_url=self.delete.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, 204]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py new file mode 100644 index 000000000000..ebc1d0be1bcb --- /dev/null +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/aio/operations/_query_packs_operations.py @@ -0,0 +1,406 @@ +# 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._query_packs_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_tags_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class QueryPacksOperations: + """QueryPacksOperations 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: ~azure.mgmt.loganalytics.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.LogAnalyticsQueryPackListResult"]: + """Gets a list of all Log Analytics QueryPacks within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogAnalyticsQueryPackListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + 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("LogAnalyticsQueryPackListResult", 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.OperationalInsights/queryPacks'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.LogAnalyticsQueryPackListResult"]: + """Gets a list of Log Analytics QueryPacks within a 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 LogAnalyticsQueryPackListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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( + resource_group_name=resource_group_name, + 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("LogAnalyticsQueryPackListResult", 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.OperationalInsights/queryPacks'} # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + query_pack_name: str, + **kwargs: Any + ) -> None: + """Deletes a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_name, + template_url=self.delete.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, 204]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + query_pack_name: str, + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPack": + """Returns a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPack, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_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('LogAnalyticsQueryPack', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + query_pack_name: str, + log_analytics_query_pack_payload: "_models.LogAnalyticsQueryPack", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPack": + """Creates (or updates) a Log Analytics QueryPack. Note: You cannot specify a different value for + InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param log_analytics_query_pack_payload: Properties that need to be specified to create or + update a Log Analytics QueryPack. + :type log_analytics_query_pack_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPack, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] + 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] + + _json = self._serialize.body(log_analytics_query_pack_payload, 'LogAnalyticsQueryPack') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + template_url=self.create_or_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('LogAnalyticsQueryPack', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + + + @distributed_trace_async + async def update_tags( + self, + resource_group_name: str, + query_pack_name: str, + query_pack_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPack": + """Updates an existing QueryPack's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param query_pack_tags: Updated tag information to set into the QueryPack instance. + :type query_pack_tags: ~azure.mgmt.loganalytics.models.TagsResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPack, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] + 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] + + _json = self._serialize.body(query_pack_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.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('LogAnalyticsQueryPack', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py index 37678e63343a..9902fdc4c1f9 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/__init__.py @@ -9,6 +9,7 @@ from ._models_py3 import AssociatedWorkspace from ._models_py3 import AvailableServiceTier from ._models_py3 import AzureEntityResource +from ._models_py3 import AzureResourceProperties from ._models_py3 import CapacityReservationProperties from ._models_py3 import Cluster from ._models_py3 import ClusterListResult @@ -31,6 +32,13 @@ from ._models_py3 import LinkedServiceListResult from ._models_py3 import LinkedStorageAccountsListResult from ._models_py3 import LinkedStorageAccountsResource +from ._models_py3 import LogAnalyticsQueryPack +from ._models_py3 import LogAnalyticsQueryPackListResult +from ._models_py3 import LogAnalyticsQueryPackQuery +from ._models_py3 import LogAnalyticsQueryPackQueryListResult +from ._models_py3 import LogAnalyticsQueryPackQueryPropertiesRelated +from ._models_py3 import LogAnalyticsQueryPackQuerySearchProperties +from ._models_py3 import LogAnalyticsQueryPackQuerySearchPropertiesRelated from ._models_py3 import ManagementGroup from ._models_py3 import MetricName from ._models_py3 import Operation @@ -39,6 +47,7 @@ from ._models_py3 import OperationStatus from ._models_py3 import PrivateLinkScopedResource from ._models_py3 import ProxyResource +from ._models_py3 import QueryPacksResource from ._models_py3 import Resource from ._models_py3 import RestoredLogs from ._models_py3 import ResultStatistics @@ -57,9 +66,11 @@ from ._models_py3 import StorageInsightListResult from ._models_py3 import StorageInsightStatus from ._models_py3 import SystemData +from ._models_py3 import SystemDataAutoGenerated from ._models_py3 import Table from ._models_py3 import TablesListResult from ._models_py3 import Tag +from ._models_py3 import TagsResource from ._models_py3 import TrackedResource from ._models_py3 import UsageMetric from ._models_py3 import UserIdentityProperties @@ -110,6 +121,7 @@ 'AssociatedWorkspace', 'AvailableServiceTier', 'AzureEntityResource', + 'AzureResourceProperties', 'CapacityReservationProperties', 'Cluster', 'ClusterListResult', @@ -132,6 +144,13 @@ 'LinkedServiceListResult', 'LinkedStorageAccountsListResult', 'LinkedStorageAccountsResource', + 'LogAnalyticsQueryPack', + 'LogAnalyticsQueryPackListResult', + 'LogAnalyticsQueryPackQuery', + 'LogAnalyticsQueryPackQueryListResult', + 'LogAnalyticsQueryPackQueryPropertiesRelated', + 'LogAnalyticsQueryPackQuerySearchProperties', + 'LogAnalyticsQueryPackQuerySearchPropertiesRelated', 'ManagementGroup', 'MetricName', 'Operation', @@ -140,6 +159,7 @@ 'OperationStatus', 'PrivateLinkScopedResource', 'ProxyResource', + 'QueryPacksResource', 'Resource', 'RestoredLogs', 'ResultStatistics', @@ -158,9 +178,11 @@ 'StorageInsightListResult', 'StorageInsightStatus', 'SystemData', + 'SystemDataAutoGenerated', 'Table', 'TablesListResult', 'Tag', + 'TagsResource', 'TrackedResource', 'UsageMetric', 'UserIdentityProperties', diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py index 65a784c72eeb..58a535011f16 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_log_analytics_management_client_enums.py @@ -163,9 +163,13 @@ class DataSourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ALERTS = "Alerts" class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of managed service identity. + """The type of identity that creates/modifies resources """ + USER = "user" + APPLICATION = "application" + MANAGED_IDENTITY = "managedIdentity" + KEY = "key" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" NONE = "None" diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py index dc180fd51d1f..85b9a107ee15 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/models/_models_py3.py @@ -197,6 +197,48 @@ def __init__( self.etag = None +class AzureResourceProperties(msrest.serialization.Model): + """An Azure resource QueryPack-Query object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar system_data: Read only system data. + :vartype system_data: ~azure.mgmt.loganalytics.models.SystemData + """ + + _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'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AzureResourceProperties, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + class CapacityReservationProperties(msrest.serialization.Model): """The Capacity Reservation properties. @@ -1094,8 +1136,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. Type of managed service identity. Possible values include: - "SystemAssigned", "UserAssigned", "None". + :ivar type: Required. Type of managed service identity. Possible values include: "user", + "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". :vartype type: str or ~azure.mgmt.loganalytics.models.IdentityType :ivar user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1125,8 +1167,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. Type of managed service identity. Possible values include: - "SystemAssigned", "UserAssigned", "None". + :keyword type: Required. Type of managed service identity. Possible values include: "user", + "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". :paramtype type: str or ~azure.mgmt.loganalytics.models.IdentityType :keyword user_assigned_identities: The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: @@ -1399,6 +1441,426 @@ def __init__( self.storage_account_ids = storage_account_ids +class QueryPacksResource(msrest.serialization.Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(QueryPacksResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class LogAnalyticsQueryPack(QueryPacksResource): + """An Log Analytics QueryPack definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar query_pack_id: The unique ID of your application. This field cannot be changed. + :vartype query_pack_id: str + :ivar time_created: Creation Date for the Log Analytics QueryPack, in ISO 8601 format. + :vartype time_created: ~datetime.datetime + :ivar time_modified: Last modified date of the Log Analytics QueryPack, in ISO 8601 format. + :vartype time_modified: ~datetime.datetime + :ivar provisioning_state: Current state of this QueryPack: whether or not is has been + provisioned within the resource group it is defined. Users cannot change this value but are + able to read from it. Values will include Succeeded, Deploying, Canceled, and Failed. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'query_pack_id': {'readonly': True}, + 'time_created': {'readonly': True}, + 'time_modified': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'query_pack_id': {'key': 'properties.queryPackId', 'type': 'str'}, + 'time_created': {'key': 'properties.timeCreated', 'type': 'iso-8601'}, + 'time_modified': {'key': 'properties.timeModified', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(LogAnalyticsQueryPack, self).__init__(location=location, tags=tags, **kwargs) + self.query_pack_id = None + self.time_created = None + self.time_modified = None + self.provisioning_state = None + + +class LogAnalyticsQueryPackListResult(msrest.serialization.Model): + """Describes the list of Log Analytics QueryPack resources. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. List of Log Analytics QueryPack definitions. + :vartype value: list[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack] + :ivar next_link: The URI to get the next set of Log Analytics QueryPack definitions if too many + QueryPacks where returned in the result set. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogAnalyticsQueryPack]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["LogAnalyticsQueryPack"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. List of Log Analytics QueryPack definitions. + :paramtype value: list[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack] + :keyword next_link: The URI to get the next set of Log Analytics QueryPack definitions if too + many QueryPacks where returned in the result set. + :paramtype next_link: str + """ + super(LogAnalyticsQueryPackListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LogAnalyticsQueryPackQuery(AzureResourceProperties): + """A Log Analytics QueryPack-Query definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Azure resource Id. + :vartype id: str + :ivar name: Azure resource name. + :vartype name: str + :ivar type: Azure resource type. + :vartype type: str + :ivar system_data: Read only system data. + :vartype system_data: ~azure.mgmt.loganalytics.models.SystemData + :ivar id_properties_id: The unique ID of your application. This field cannot be changed. + :vartype id_properties_id: str + :ivar display_name: Unique display name for your query within the Query Pack. + :vartype display_name: str + :ivar time_created: Creation Date for the Log Analytics Query, in ISO 8601 format. + :vartype time_created: ~datetime.datetime + :ivar time_modified: Last modified date of the Log Analytics Query, in ISO 8601 format. + :vartype time_modified: ~datetime.datetime + :ivar author: Object Id of user creating the query. + :vartype author: str + :ivar description: Description of the query. + :vartype description: str + :ivar body: Body of the query. + :vartype body: str + :ivar related: The related metadata items for the function. + :vartype related: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryPropertiesRelated + :ivar tags: A set of tags. Tags associated with the query. + :vartype tags: dict[str, list[str]] + :ivar properties: Additional properties that can be set for the query. + :vartype properties: any + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'id_properties_id': {'readonly': True}, + 'time_created': {'readonly': True}, + 'time_modified': {'readonly': True}, + 'author': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'time_created': {'key': 'properties.timeCreated', 'type': 'iso-8601'}, + 'time_modified': {'key': 'properties.timeModified', 'type': 'iso-8601'}, + 'author': {'key': 'properties.author', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'body': {'key': 'properties.body', 'type': 'str'}, + 'related': {'key': 'properties.related', 'type': 'LogAnalyticsQueryPackQueryPropertiesRelated'}, + 'tags': {'key': 'properties.tags', 'type': '{[str]}'}, + 'properties': {'key': 'properties.properties', 'type': 'object'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + body: Optional[str] = None, + related: Optional["LogAnalyticsQueryPackQueryPropertiesRelated"] = None, + tags: Optional[Dict[str, List[str]]] = None, + properties: Optional[Any] = None, + **kwargs + ): + """ + :keyword display_name: Unique display name for your query within the Query Pack. + :paramtype display_name: str + :keyword description: Description of the query. + :paramtype description: str + :keyword body: Body of the query. + :paramtype body: str + :keyword related: The related metadata items for the function. + :paramtype related: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryPropertiesRelated + :keyword tags: A set of tags. Tags associated with the query. + :paramtype tags: dict[str, list[str]] + :keyword properties: Additional properties that can be set for the query. + :paramtype properties: any + """ + super(LogAnalyticsQueryPackQuery, self).__init__(**kwargs) + self.id_properties_id = None + self.display_name = display_name + self.time_created = None + self.time_modified = None + self.author = None + self.description = description + self.body = body + self.related = related + self.tags = tags + self.properties = properties + + +class LogAnalyticsQueryPackQueryListResult(msrest.serialization.Model): + """Describes the list of Log Analytics QueryPack-Query resources. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. List of Log Analytics QueryPack Query definitions. + :vartype value: list[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery] + :ivar next_link: The URI to get the next set of Log Analytics QueryPack definitions if too many + QueryPack-Queries where returned in the result set. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LogAnalyticsQueryPackQuery]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["LogAnalyticsQueryPackQuery"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. List of Log Analytics QueryPack Query definitions. + :paramtype value: list[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery] + :keyword next_link: The URI to get the next set of Log Analytics QueryPack definitions if too + many QueryPack-Queries where returned in the result set. + :paramtype next_link: str + """ + super(LogAnalyticsQueryPackQueryListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LogAnalyticsQueryPackQueryPropertiesRelated(msrest.serialization.Model): + """The related metadata items for the function. + + :ivar categories: The related categories for the function. + :vartype categories: list[str] + :ivar resource_types: The related resource types for the function. + :vartype resource_types: list[str] + :ivar solutions: The related Log Analytics solutions for the function. + :vartype solutions: list[str] + """ + + _attribute_map = { + 'categories': {'key': 'categories', 'type': '[str]'}, + 'resource_types': {'key': 'resourceTypes', 'type': '[str]'}, + 'solutions': {'key': 'solutions', 'type': '[str]'}, + } + + def __init__( + self, + *, + categories: Optional[List[str]] = None, + resource_types: Optional[List[str]] = None, + solutions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword categories: The related categories for the function. + :paramtype categories: list[str] + :keyword resource_types: The related resource types for the function. + :paramtype resource_types: list[str] + :keyword solutions: The related Log Analytics solutions for the function. + :paramtype solutions: list[str] + """ + super(LogAnalyticsQueryPackQueryPropertiesRelated, self).__init__(**kwargs) + self.categories = categories + self.resource_types = resource_types + self.solutions = solutions + + +class LogAnalyticsQueryPackQuerySearchProperties(msrest.serialization.Model): + """Properties that define an Log Analytics QueryPack-Query search properties. + + :ivar related: The related metadata items for the function. + :vartype related: + ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuerySearchPropertiesRelated + :ivar tags: A set of tags. Tags associated with the query. + :vartype tags: dict[str, list[str]] + """ + + _attribute_map = { + 'related': {'key': 'related', 'type': 'LogAnalyticsQueryPackQuerySearchPropertiesRelated'}, + 'tags': {'key': 'tags', 'type': '{[str]}'}, + } + + def __init__( + self, + *, + related: Optional["LogAnalyticsQueryPackQuerySearchPropertiesRelated"] = None, + tags: Optional[Dict[str, List[str]]] = None, + **kwargs + ): + """ + :keyword related: The related metadata items for the function. + :paramtype related: + ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuerySearchPropertiesRelated + :keyword tags: A set of tags. Tags associated with the query. + :paramtype tags: dict[str, list[str]] + """ + super(LogAnalyticsQueryPackQuerySearchProperties, self).__init__(**kwargs) + self.related = related + self.tags = tags + + +class LogAnalyticsQueryPackQuerySearchPropertiesRelated(msrest.serialization.Model): + """The related metadata items for the function. + + :ivar categories: The related categories for the function. + :vartype categories: list[str] + :ivar resource_types: The related resource types for the function. + :vartype resource_types: list[str] + :ivar solutions: The related Log Analytics solutions for the function. + :vartype solutions: list[str] + """ + + _attribute_map = { + 'categories': {'key': 'categories', 'type': '[str]'}, + 'resource_types': {'key': 'resourceTypes', 'type': '[str]'}, + 'solutions': {'key': 'solutions', 'type': '[str]'}, + } + + def __init__( + self, + *, + categories: Optional[List[str]] = None, + resource_types: Optional[List[str]] = None, + solutions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword categories: The related categories for the function. + :paramtype categories: list[str] + :keyword resource_types: The related resource types for the function. + :paramtype resource_types: list[str] + :keyword solutions: The related Log Analytics solutions for the function. + :paramtype solutions: list[str] + """ + super(LogAnalyticsQueryPackQuerySearchPropertiesRelated, self).__init__(**kwargs) + self.categories = categories + self.resource_types = resource_types + self.solutions = solutions + + class ManagementGroup(msrest.serialization.Model): """A management group that is connected to a workspace. @@ -2609,6 +3071,73 @@ def __init__( class SystemData(msrest.serialization.Model): + """Read only system data. + + :ivar created_by: An identifier for the identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", "None". + :vartype created_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: An identifier for the identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "user", "application", "managedIdentity", "key", "SystemAssigned", + "UserAssigned", "None". + :vartype last_modified_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :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, "IdentityType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "IdentityType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: An identifier for the identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "user", "application", "managedIdentity", "key", "SystemAssigned", "UserAssigned", + "None". + :paramtype created_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: An identifier for the identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "user", "application", "managedIdentity", "key", "SystemAssigned", + "UserAssigned", "None". + :paramtype last_modified_by_type: str or ~azure.mgmt.loganalytics.models.IdentityType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :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 SystemDataAutoGenerated(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. @@ -2663,7 +3192,7 @@ def __init__( :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super(SystemDataAutoGenerated, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -2686,7 +3215,7 @@ class Table(ProxyResource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.loganalytics.models.SystemData + :vartype system_data: ~azure.mgmt.loganalytics.models.SystemDataAutoGenerated :ivar retention_in_days: The table retention in days, between 4 and 730. Setting this property to -1 will default to the workspace retention. :vartype retention_in_days: int @@ -2731,7 +3260,7 @@ class Table(ProxyResource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'system_data': {'key': 'systemData', 'type': 'SystemDataAutoGenerated'}, 'retention_in_days': {'key': 'properties.retentionInDays', 'type': 'int'}, 'total_retention_in_days': {'key': 'properties.totalRetentionInDays', 'type': 'int'}, 'archive_retention_in_days': {'key': 'properties.archiveRetentionInDays', 'type': 'int'}, @@ -2853,6 +3382,31 @@ def __init__( self.value = value +class TagsResource(msrest.serialization.Model): + """A container holding only the Tags for a resource, allowing the user to update the tags on a QueryPack instance. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(TagsResource, self).__init__(**kwargs) + self.tags = tags + + class UsageMetric(msrest.serialization.Model): """A metric describing the usage of a resource. @@ -2966,7 +3520,7 @@ class Workspace(TrackedResource): :ivar location: Required. The geo-location where the resource lives. :vartype location: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.loganalytics.models.SystemData + :vartype system_data: ~azure.mgmt.loganalytics.models.SystemDataAutoGenerated :ivar e_tag: The ETag of the workspace. :vartype e_tag: str :ivar provisioning_state: The provisioning state of the workspace. Possible values include: @@ -3027,7 +3581,7 @@ class Workspace(TrackedResource): 'type': {'key': 'type', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'system_data': {'key': 'systemData', 'type': 'SystemDataAutoGenerated'}, 'e_tag': {'key': 'eTag', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py index 479da079c9c5..72e307c7d6e6 100644 --- a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/__init__.py @@ -6,10 +6,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._operations import Operations -from ._workspaces_operations import WorkspacesOperations -from ._deleted_workspaces_operations import DeletedWorkspacesOperations -from ._tables_operations import TablesOperations +from ._query_packs_operations import QueryPacksOperations +from ._queries_operations import QueriesOperations from ._data_exports_operations import DataExportsOperations from ._data_sources_operations import DataSourcesOperations from ._intelligence_packs_operations import IntelligencePacksOperations @@ -26,12 +24,14 @@ from ._schema_operations import SchemaOperations from ._workspace_purge_operations import WorkspacePurgeOperations from ._clusters_operations import ClustersOperations +from ._operations import Operations +from ._workspaces_operations import WorkspacesOperations +from ._deleted_workspaces_operations import DeletedWorkspacesOperations +from ._tables_operations import TablesOperations __all__ = [ - 'Operations', - 'WorkspacesOperations', - 'DeletedWorkspacesOperations', - 'TablesOperations', + 'QueryPacksOperations', + 'QueriesOperations', 'DataExportsOperations', 'DataSourcesOperations', 'IntelligencePacksOperations', @@ -48,4 +48,8 @@ 'SchemaOperations', 'WorkspacePurgeOperations', 'ClustersOperations', + 'Operations', + 'WorkspacesOperations', + 'DeletedWorkspacesOperations', + 'TablesOperations', ] diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py new file mode 100644 index 000000000000..ab2bb81ddbb8 --- /dev/null +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_queries_operations.py @@ -0,0 +1,749 @@ +# 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, _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, + resource_group_name: str, + query_pack_name: str, + *, + top: Optional[int] = None, + include_body: Optional[bool] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_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') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'long') + if include_body is not None: + query_parameters['includeBody'] = _SERIALIZER.query("include_body", include_body, 'bool') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, '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_search_request( + subscription_id: str, + resource_group_name: str, + query_pack_name: str, + *, + json: JSONType = None, + content: Any = None, + top: Optional[int] = None, + include_body: Optional[bool] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_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') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'long') + if include_body is not None: + query_parameters['includeBody'] = _SERIALIZER.query("include_body", include_body, 'bool') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, '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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + query_pack_name: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), + "id": _SERIALIZER.url("id", id, '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_put_request( + subscription_id: str, + resource_group_name: str, + query_pack_name: str, + id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), + "id": _SERIALIZER.url("id", id, '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, + query_pack_name: str, + id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), + "id": _SERIALIZER.url("id", id, '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( + subscription_id: str, + resource_group_name: str, + query_pack_name: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_name, 'str'), + "id": _SERIALIZER.url("id", id, '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 QueriesOperations(object): + """QueriesOperations 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: ~azure.mgmt.loganalytics.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, + resource_group_name: str, + query_pack_name: str, + top: Optional[int] = None, + include_body: Optional[bool] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.LogAnalyticsQueryPackQueryListResult"]: + """Gets a list of Queries defined within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param top: Maximum items returned in page. + :type top: long + :param include_body: Flag indicating whether or not to return the body of each applicable + query. If false, only return the query information. + :type include_body: bool + :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] + 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, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + top=top, + include_body=include_body, + skip_token=skip_token, + 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, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + top=top, + include_body=include_body, + skip_token=skip_token, + 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("LogAnalyticsQueryPackQueryListResult", 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries'} # type: ignore + + @distributed_trace + def search( + self, + resource_group_name: str, + query_pack_name: str, + query_search_properties: "_models.LogAnalyticsQueryPackQuerySearchProperties", + top: Optional[int] = None, + include_body: Optional[bool] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.LogAnalyticsQueryPackQueryListResult"]: + """Search a list of Queries defined within a Log Analytics QueryPack according to given search + properties. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param query_search_properties: Properties by which to search queries in the given Log + Analytics QueryPack. + :type query_search_properties: + ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuerySearchProperties + :param top: Maximum items returned in page. + :type top: long + :param include_body: Flag indicating whether or not to return the body of each applicable + query. If false, only return the query information. + :type include_body: bool + :param skip_token: Base64 encoded token used to fetch the next page of items. Default is null. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogAnalyticsQueryPackQueryListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQueryListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQueryListResult"] + 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: + _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') + + request = build_search_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + top=top, + include_body=include_body, + skip_token=skip_token, + template_url=self.search.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + _json = self._serialize.body(query_search_properties, 'LogAnalyticsQueryPackQuerySearchProperties') + + request = build_search_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + top=top, + include_body=include_body, + skip_token=skip_token, + 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("LogAnalyticsQueryPackQueryListResult", 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 + ) + search.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/search'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPackQuery": + """Gets a specific Log Analytics Query defined within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPackQuery, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] + 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, + query_pack_name=query_pack_name, + id=id, + 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('LogAnalyticsQueryPackQuery', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + + + @distributed_trace + def put( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + query_payload: "_models.LogAnalyticsQueryPackQuery", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPackQuery": + """Adds or Updates a specific Query within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :param query_payload: Properties that need to be specified to create a new query and add it to + a Log Analytics QueryPack. + :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPackQuery, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] + 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] + + _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') + + request = build_put_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + id=id, + content_type=content_type, + json=_json, + template_url=self.put.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('LogAnalyticsQueryPackQuery', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + query_payload: "_models.LogAnalyticsQueryPackQuery", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPackQuery": + """Adds or Updates a specific Query within a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :param query_payload: Properties that need to be specified to create a new query and add it to + a Log Analytics QueryPack. + :type query_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPackQuery, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackQuery + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackQuery"] + 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] + + _json = self._serialize.body(query_payload, 'LogAnalyticsQueryPackQuery') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + id=id, + 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('LogAnalyticsQueryPackQuery', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + query_pack_name: str, + id: str, + **kwargs: Any + ) -> None: + """Deletes a specific Query defined within an Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param id: The id of a specific query defined in the Log Analytics QueryPack. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + query_pack_name=query_pack_name, + id=id, + template_url=self.delete.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, 204]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}/queries/{id}'} # type: ignore + diff --git a/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py new file mode 100644 index 000000000000..0ce4c437dd4a --- /dev/null +++ b/sdk/loganalytics/azure-mgmt-loganalytics/azure/mgmt/loganalytics/operations/_query_packs_operations.py @@ -0,0 +1,630 @@ +# 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, _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 = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OperationalInsights/queryPacks') + 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( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_delete_request( + resource_group_name: str, + subscription_id: str, + query_pack_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_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 + ) + + +def build_get_request( + resource_group_name: str, + subscription_id: str, + query_pack_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_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_or_update_request( + resource_group_name: str, + subscription_id: str, + query_pack_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_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_tags_request( + resource_group_name: str, + subscription_id: str, + query_pack_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queryPackName": _SERIALIZER.url("query_pack_name", query_pack_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 + ) + +class QueryPacksOperations(object): + """QueryPacksOperations 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: ~azure.mgmt.loganalytics.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.LogAnalyticsQueryPackListResult"]: + """Gets a list of all Log Analytics QueryPacks within a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LogAnalyticsQueryPackListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + 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("LogAnalyticsQueryPackListResult", 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.OperationalInsights/queryPacks'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.LogAnalyticsQueryPackListResult"]: + """Gets a list of Log Analytics QueryPacks within a 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 LogAnalyticsQueryPackListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.loganalytics.models.LogAnalyticsQueryPackListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPackListResult"] + 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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( + resource_group_name=resource_group_name, + 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("LogAnalyticsQueryPackListResult", 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.OperationalInsights/queryPacks'} # type: ignore + + @distributed_trace + def delete( + self, + resource_group_name: str, + query_pack_name: str, + **kwargs: Any + ) -> None: + """Deletes a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_name, + template_url=self.delete.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, 204]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + query_pack_name: str, + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPack": + """Returns a Log Analytics QueryPack. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPack, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_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('LogAnalyticsQueryPack', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + query_pack_name: str, + log_analytics_query_pack_payload: "_models.LogAnalyticsQueryPack", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPack": + """Creates (or updates) a Log Analytics QueryPack. Note: You cannot specify a different value for + InstrumentationKey nor AppId in the Put operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param log_analytics_query_pack_payload: Properties that need to be specified to create or + update a Log Analytics QueryPack. + :type log_analytics_query_pack_payload: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPack, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] + 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] + + _json = self._serialize.body(log_analytics_query_pack_payload, 'LogAnalyticsQueryPack') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + template_url=self.create_or_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('LogAnalyticsQueryPack', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore + + + @distributed_trace + def update_tags( + self, + resource_group_name: str, + query_pack_name: str, + query_pack_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.LogAnalyticsQueryPack": + """Updates an existing QueryPack's tags. To update other fields use the CreateOrUpdate method. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_pack_name: The name of the Log Analytics QueryPack resource. + :type query_pack_name: str + :param query_pack_tags: Updated tag information to set into the QueryPack instance. + :type query_pack_tags: ~azure.mgmt.loganalytics.models.TagsResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LogAnalyticsQueryPack, or the result of cls(response) + :rtype: ~azure.mgmt.loganalytics.models.LogAnalyticsQueryPack + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsQueryPack"] + 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] + + _json = self._serialize.body(query_pack_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + query_pack_name=query_pack_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.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('LogAnalyticsQueryPack', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/queryPacks/{queryPackName}'} # type: ignore +